Opening the file in MS Word, linked images wrong size

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Opening the file in MS Word, linked images wrong size

cdfleischmann
Hello, I am hoping someone can help me... I am using OpenOffice SDK 3.3 with OpenOffice, (I also tried with LibreOffice), and find that after I insert an image using code like:

Object newImage = xWriterFactory_dest.createInstance("com.sun.star.text.TextGraphicObject");
XTextContent xNewTextContent = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, newImage);
XPropertySet xProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, newImage);


xProps.setPropertyValue("GraphicURL", strImgFileName);
xProps.setPropertyValue("AnchorType", TextContentAnchorType.AS_CHARACTER);

xText.insertTextContent(xTextCursor, xNewTextContent, false);

xProps.getPropertyValue("IsPixelContour");

xProps.setPropertyValue("Width", width);
xProps.setPropertyValue("Height", height);

xProps.setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE));
xProps.setPropertyValue("VertOrient", new Short(VertOrientation.NONE));
xProps.setPropertyValue("HoriOrientPosition", new Integer(x));
xProps.setPropertyValue("VertOrientPosition", new Integer(y));

to insert an image at a certain character position...

After inserting, I then set the size which seems to work for OpenOffice. The images are sized correctly and linked accordingly. However when I try to save/export the document to it's MS Word format. I see that the picture frame (the frame prior to having its contents loaded/prior to fetching the URL), are set to the correct size, however after Word fetches the actual picture file, the image no longer fit within the image size I set and seems to reflect the images true file size (the actual image size) rather than the width and height that I set the image to open in.

If you know of a way to set the actual image size once it has loaded/fetched for Word, I'd appreciate any assistance.

Kind Regards,

Chris
Reply | Threaded
Open this post in threaded view
|

Re: [api-dev] Opening the file in MS Word, linked images wrong size

Fernand Vanrie
cdfleischmann,

xProps.getPropertyValue("IsPixelContour") have no sence when using "linked" images, this property only works with embeded images. Maybe thats the reason for your problems.
When setting xProps.setPropertyValue("Width", width); to a percentage and not a fixed value, can also be the reason why you have different sizes in the Word Document.

Hope it helps a bit

Fernand
 


> Hello, I am hoping someone can help me... I am using OpenOffice SDK 3.3 with
> OpenOffice, (I also tried with LibreOffice), and find that after I insert an
> image using code like:
>
> Object newImage =
> xWriterFactory_dest.createInstance("com.sun.star.text.TextGraphicObject");
> XTextContent xNewTextContent = (XTextContent)
> UnoRuntime.queryInterface(XTextContent.class, newImage);
> XPropertySet xProps =
> (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, newImage);
>
>
> xProps.setPropertyValue("GraphicURL", strImgFileName);
> xProps.setPropertyValue("AnchorType", TextContentAnchorType.AS_CHARACTER);
>
> xText.insertTextContent(xTextCursor, xNewTextContent, false);
>
> xProps.getPropertyValue("IsPixelContour");
>
> xProps.setPropertyValue("Width", width);
> xProps.setPropertyValue("Height", height);
>
> xProps.setPropertyValue("HoriOrient", new Short(HoriOrientation.NONE));
> xProps.setPropertyValue("VertOrient", new Short(VertOrientation.NONE));
> xProps.setPropertyValue("HoriOrientPosition", new Integer(x));
> xProps.setPropertyValue("VertOrientPosition", new Integer(y));
>
> to insert an image at a certain character position...
>
> After inserting, I then set the size which seems to work for OpenOffice. The
> images are sized correctly and linked accordingly. However when I try to
> save/export the document to it's MS Word format. I see that the picture
> frame (the frame prior to having its contents loaded/prior to fetching the
> URL), are set to the correct size, however after Word fetches the actual
> picture file, the image no longer fit within the image size I set and seems
> to reflect the images true file size (the actual image size) rather than the
> width and height that I set the image to open in.
>
> If you know of a way to set the actual image size once it has loaded/fetched
> for Word, I'd appreciate any assistance.
>
> Kind Regards,
>
> Chris


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [api-dev] Opening the file in MS Word, linked images wrong size

cdfleischmann
Hello thanks Fernand,

Unfortunately unsetting the IsPixelContour still doesn't make things work. I tried that after some experiments...

My width and height are "fixed" values, for example 4000 (4 cm's) in height and 2000 (2 cm's) in width.

I have uploaded a few images representing the issue I experience. This image is set to 7000, (7 cm's) in width, and just over 0.4 cm's in height (set to 409):

OpenOffice showing correctly.


MS Word not showing correctly:


and the image properties in question:


Thanks for any help you may be able to provide.

Regards,

Chris
Reply | Threaded
Open this post in threaded view
|

Re: [api-dev] Opening the file in MS Word, linked images wrong size

Fernand Vanrie
cdfleischmann ,

in OO or LO the "Keep Ratio" must been active before you start the
export to MS word. When "nothing" is set i supose the Converting go's
back to the original ratio's who are this we find back in MS word.
I supose this can been done with the API to ?

Hope it Helps

Fernand

> Hello thanks Fernand,
>
> Unfortunately unsetting the IsPixelContour still doesn't make things work. I
> tried that after some experiments...
>
> My width and height are "fixed" values, for example 4000 (4 cm's) in height
> and 2000 (2 cm's) in width.
>
> I have uploaded a few images representing the issue I experience. This image
> is set to 7000, (7 cm's) in width, and just over 0.4 cm's in height (set to
> 409):
>
> OpenOffice showing correctly.
> http://openoffice.2283327.n4.nabble.com/file/n3263721/oo_properties.jpg
>
> MS Word not showing correctly:
> http://openoffice.2283327.n4.nabble.com/file/n3263721/word_properties.jpg
>
> and the image properties in question:
> http://openoffice.2283327.n4.nabble.com/file/n3263721/image_properties.jpg
>
> Thanks for any help you may be able to provide.
>
> Regards,
>
> Chris


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [api-dev] Opening the file in MS Word, linked images wrong size

cdfleischmann
Hrm, hrm.... not sure how to do that. Thus far I tried:

IsSyncWidthToHeight set to false, and at the same time also tried IsSyncHeightToWidth setting to false.

Lastly, trying IsSyncWidthToHeight to TRUE also fails?

In OOo I see:

[The image is meant to be 7 cm's wide, and 0.41 cm's in height].



and in MS Word I see the aspect also set, but not the same dimensions as it should be set to?



Any other ideas? I am really at a loss here? I have tried embedding the images but still suffer from bug 32638 (and in particular bug: 103356) that was marked as a duplicate although it is a different issue, so now trying linked images... :-(

Kind Regards,

Chris

Reply | Threaded
Open this post in threaded view
|

Re: [api-dev] Opening the file in MS Word, linked images wrong size

Marc Santhoff
Am Montag, den 07.02.2011, 04:18 -0800 schrieb cdfleischmann:

> Hrm, hrm.... not sure how to do that. Thus far I tried:
>
> IsSyncWidthToHeight set to false, and at the same time also tried
> IsSyncHeightToWidth setting to false.
>
> Lastly, trying IsSyncWidthToHeight to TRUE also fails?
>
> In OOo I see:
>
> [The image is meant to be 7 cm's wide, and 0.41 cm's in height].
>
> http://openoffice.2283327.n4.nabble.com/file/n3264004/ooimage.jpg 
>
> and in MS Word I see the aspect also set, but not the same dimensions as it
> should be set to?
>
> http://openoffice.2283327.n4.nabble.com/file/n3264004/msword.jpg 
>
> Any other ideas? I am really at a loss here?

Maybe you can try this:
- insert an image manually into a document
- then export and see if it looks OK in the target program
- read out how OO.o has set the properties and use them at the api

>From my experience it is sometimes important to use working combinations
of multiple properties, not only one setting.

HTH anyhow,
Marc

--
Ihr Suchbegriff >OO.o<  könnte fehlerhaft oder unbekannt sein: Ob Zoo
besser ist? (Suchmaschine)


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [api-dev] Opening the file in MS Word, linked images wrong size

cdfleischmann
Thanks Marc unfortunately, I have already gone down that route, thus far, have tried the following:

Inserting the picture (not linked but embedded) as the backgroundURL for the TextFrame. Inside the textFrame, I insert an image (any image), again embedded, and set the size. When I save it to MS Word, I hit bug http://www.openoffice.org/issues/show_bug.cgi?id=32638 That is, I get an error, There is not enough memory when opening the file in Word.

A sample ODT file: test.odt
And the resultant MS Word doc file test.doc

However, when I link the images rather than embed, ie., I use file:/// to link to an absolute filename (with absolute). The document opens correctly and the scaling/sizing works as it should. However the file is then not portable, ie., refers to locations on my machine.

If however, I try to host the images (on a server), and try to include images via URL hyperlinks (http://...) rather than to local files, (files:/ / /) The images don't seem to scale no matter what I try and remain 100% of the original file size...

Is there a known workaround to insert images via hyperlinks and have the resultant image load, and correctly (re)size?


Reply | Threaded
Open this post in threaded view
|

Re: [api-dev] Opening the file in MS Word, linked images wrong size

Marc Santhoff
Am Dienstag, den 08.02.2011, 03:04 -0800 schrieb cdfleischmann:

> Thanks Marc unfortunately, I have already gone down that route, thus far,
> have tried the following:
>
> Inserting the picture (not linked but embedded) as the backgroundURL for the
> TextFrame. Inside the textFrame, I insert an image (any image), again
> embedded, and set the size. When I save it to MS Word, I hit bug
> http://www.openoffice.org/issues/show_bug.cgi?id=32638 That is, I get an
> error, There is not enough memory when opening the file in Word.
>
> A sample ODT file:
> http://openoffice.2283327.n4.nabble.com/file/n3275734/test.odt test.odt
> And the resultant MS Word doc file
> http://openoffice.2283327.n4.nabble.com/file/n3275734/test.doc test.doc
>
> However, when I link the images rather than embed, ie., I use file:/// to
> link to an absolute filename (with absolute). The document opens correctly
> and the scaling/sizing works as it should. However the file is then not
> portable, ie., refers to locations on my machine.
>
> If however, I try to host the images (on a server), and try to include
> images via URL hyperlinks (http://...) rather than to local files, (files:/
> / /) The images don't seem to scale no matter what I try and remain 100% of
> the original file size...
>
> Is there a known workaround to insert images via hyperlinks and have the
> resultant image load, and correctly (re)size?

If you're hit by an API bug the only workaround I can think of is to
unpack the document zip file, fix the paths or what is wrong and not
settable correctly by API using sed/awk/perl/java/whatever and pack
things up again.

Since you're building docs by using the sdk that would only be one -
although ugly - additional step. And you caan omit it when the bug is
fixed.

Good luck,
Marc

--
Ihr Suchbegriff >OO.o<  könnte fehlerhaft oder unbekannt sein: Ob Zoo
besser ist? (Suchmaschine)


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]