Images are not showing in PDF after upgrade to 4.1.6

Creating a macro - Writing a Script - Using the API

Images are not showing in PDF after upgrade to 4.1.6

Postby dhananay.patil » Tue May 28, 2019 2:26 pm

we are using open office api's and .sxw files which contains variables and static text to generate pdf's .erlier we were using open office version 3.2.1 now we are migrating to
open office version 4.1.6 . issues which we are facing is in many of the templates we have used bookmarks those will hold the images passed at runtime.
but we observed that images are sometimes comming on in the pdf and sometimes they are not comming . can you please provide some idea why this issue
can be occurred

below is the sample code written for the same


Code: Select all   Expand viewCollapse view
public void placeImage(XComponent aDoc, String szImageURL_1,String szImageURL_2, int lHeight, int lWidth) throws java.lang.Exception
    {
        OOCommonUtils.logMessage("Entry:OOImageProcessing:placeImage()");
        try{
            XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, aDoc);
            XBookmarksSupplier xBookmarksSupplier = (XBookmarksSupplier) UnoRuntime.queryInterface(XBookmarksSupplier.class, xTextDocument);
            XNameAccess xNamedBookmarks = xBookmarksSupplier.getBookmarks();
            String [] szArrBookmarkNames =new String[2];
            szArrBookmarkNames= xNamedBookmarks.getElementNames();
            Object objBookMarks=null;
            String[] szImageURL=new String[]{szImageURL_1,szImageURL_2};

            if (szArrBookmarkNames!=null && szImageURL_1 !=null && szImageURL_2 !=null )
            {
                for(int i=0;i<szArrBookmarkNames.length;i++)
                {
                    objBookMarks = xNamedBookmarks.getByName(szArrBookmarkNames[i]);
                    XTextContent xBookmarkContent = (XTextContent)UnoRuntime.queryInterface(XTextContent.class,objBookMarks );

                    XMultiServiceFactory mxDocFactory = (XMultiServiceFactory)
                    UnoRuntime.queryInterface( XMultiServiceFactory.class, xTextDocument );

                    Object oGraphicObject = mxDocFactory.createInstance("com.sun.star.text.GraphicObject");
                    XTextContent xGraphicContent = (XTextContent)UnoRuntime.queryInterface(
                    XTextContent.class, oGraphicObject);

                    XPropertySet xGraphicProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xGraphicContent );
                    xGraphicProps.setPropertyValue("AnchorType", TextContentAnchorType.AT_CHARACTER);
                    xGraphicProps.setPropertyValue("BackTransparent", new Boolean(true));
                    com.sun.star.awt.Size aSize = new com.sun.star.awt.Size();
                    aSize.Height = lHeight;
                    aSize.Width = lWidth;
                    xGraphicProps.setPropertyValue("Size", aSize);

                    xGraphicProps.setPropertyValue("GraphicURL","file:///"+szImageURL[i] );
                    XTextRange xBookmarkRange = xBookmarkContent.getAnchor();
                    XText xText = xBookmarkRange.getText();
                    XTextCursor curText = xText.createTextCursor();
                    xText.insertTextContent(xBookmarkRange, xGraphicContent, false);

                    xBookmarkContent = null;
                    xGraphicContent = null;
                    xGraphicProps = null;
                    oGraphicObject = null;
                    xBookmarkRange = null;
                    xText = null;
                    //curText = null;
                }
            }
        }
        catch(java.lang.Exception e)
        {
            OOCommonUtils.logError("Exception:OOImageProcessing:placeImage()"+e);
            OOCommonUtils.traceException(e);
            throw e;
        }
        OOCommonUtils.logMessage("Exit:OOImageProcessing:placeImage()");

    }
Last edited by Hagar Delest on Wed May 29, 2019 8:00 am, edited 2 times in total.
Reason: Added Code tags
OpenOffice 4.1.6 . on Linux RHEL 7.X
dhananay.patil
 
Posts: 4
Joined: Tue May 28, 2019 2:22 pm

Re: images are not showing in PDF after upgrade to 4.1.6

Postby Bidouille » Tue May 28, 2019 3:15 pm

sxw is clearly obsolete now.

Did you have same result if you use UI?
User avatar
Bidouille
Volunteer
 
Posts: 258
Joined: Mon Nov 19, 2007 10:58 am
Location: France

Re: images are not showing in PDF after upgrade to 4.1.6

Postby dhananay.patil » Tue May 28, 2019 3:36 pm

Hello Bidouille,
thank you for reply . since the number of templates are huge around 450 we have to stick to .sxw .
btw can you provide some more information on UI ?
Regards,
Dhananjay
OpenOffice 4.1.6 . on Linux RHEL 7.X
dhananay.patil
 
Posts: 4
Joined: Tue May 28, 2019 2:22 pm

Re: images are not showing in PDF after upgrade to 4.1.6

Postby dhananay.patil » Tue May 28, 2019 3:51 pm

Bidouille wrote:sxw is clearly obsolete now.

Did you have same result if you use UI?



Hello Bidouille,
thank you for reply . since the number of templates are huge around 450 we have to stick to .sxw .
btw can you provide some more information on UI ?
Regards,
Dhananja
OpenOffice 4.1.6 . on Linux RHEL 7.X
dhananay.patil
 
Posts: 4
Joined: Tue May 28, 2019 2:22 pm

Re: images are not showing in PDF after upgrade to 4.1.6

Postby robleyd » Wed May 29, 2019 2:16 am

UI = User Interface. Bidouille means what happens if you use AOO from the user interface to perform the same task?
Cheers
David
Apache OpenOffice Developer Build 4.2.0 9820 - Slackware 14.2 - 64 bit
LibreOffice 6.0.7.3 - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
robleyd
Moderator
 
Posts: 2807
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: images are not showing in PDF after upgrade to 4.1.6

Postby Zizi64 » Wed May 29, 2019 6:25 am

but we observed that images are sometimes comming on in the pdf and sometimes they are not comming .


What types of the image files are you using? (.bmp?, .jpg?, gif?, png?) Please check wich ones will be appeared and which ones will not...

Maybe you must convert all them into a well supported file format like the .png.

And use the ODF fileformats for the templates and the documents. (Yes, you must udate your system sometimes.)
Tibor Kovacs, Hungary; LO4.4.7, LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.4; AOO4.1.5
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 8054
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: images are not showing in PDF after upgrade to 4.1.6

Postby dhananay.patil » Wed May 29, 2019 2:31 pm

Zizi64 wrote:
but we observed that images are sometimes comming on in the pdf and sometimes they are not comming .


What types of the image files are you using? (.bmp?, .jpg?, gif?, png?) Please check wich ones will be appeared and which ones will not...

Maybe you must convert all them into a well supported file format like the .png.

And use the ODF fileformats for the templates and the documents. (Yes, you must udate your system sometimes.)

Hello Zizi64,
Thank you for replying.
We are using .bmp,.tiff etc but as per you suggestion we changed it to png and also change the template type to odt,ott etc but the result is still unexpected.
regards,
Dhananjay
OpenOffice 4.1.6 . on Linux RHEL 7.X
dhananay.patil
 
Posts: 4
Joined: Tue May 28, 2019 2:22 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 5 guests