Images are not showing in PDF after upgrade to 4.1.6

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
dhananay.patil
Posts: 4
Joined: Tue May 28, 2019 2:22 pm

Images are not showing in PDF after upgrade to 4.1.6

Post by dhananay.patil »

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

 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
Bidouille
Volunteer
Posts: 577
Joined: Mon Nov 19, 2007 10:58 am
Location: France

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

Post by Bidouille »

sxw is clearly obsolete now.

Did you have same result if you use UI?
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

Post by dhananay.patil »

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

Post by dhananay.patil »

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
User avatar
robleyd
Moderator
Posts: 5082
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

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

Post by robleyd »

UI = User Interface. Bidouille means what happens if you use AOO from the user interface to perform the same task?
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

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

Post by Zizi64 »

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; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
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.
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

Post by dhananay.patil »

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
Post Reply