Java PDF conversion issue

Java, C++, C#, Delphi, ??? - Using the UNO bridges

Java PDF conversion issue

Postby michele ricciardi » Thu Sep 05, 2019 4:21 pm

Hi,
I've an issue when a try to convert an ODT file to PDF.
What happens is that, when the text spans across two pages part of it goes hidden by the header logo.

Here my java snippet code:

Code: Select all   Expand viewCollapse view
   
public void convertToPDF(String sourceURL, String destURL, Map<String, Object> properties) throws Exception {
      XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, this.xDesktop);
      XComponent xComponent = xComponentLoader.loadComponentFromURL(sourceURL, "_blank", 0,
            getPropertyValues(new Property[] { new Property("Hidden", new Boolean(true)) }));
      XStorable xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xComponent);
      xStorable.storeToURL(destURL,
            getPropertyValues(new Property[] { new Property("FilterName", "writer_pdf_Export"),
                  new Property("FilterData", getPropertyValues(properties)) }));
      xComponent.dispose();
}


Here the odt file:
Here the pdf file:

Has anyone ever seen this behavior?
If anyone knows please help me.

Thanks.
Kind regards,
Michele
OpenOffice 4.1
michele ricciardi
 
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Postby YODA » Thu Sep 05, 2019 4:56 pm

I do not know Java but you could try File > export as PDF then fill in the options you want and click on export.
Openoffice4.16 on windows 10 Libreoffice Version: 6.1.3.2 (x64)
YODA
 
Posts: 60
Joined: Fri Aug 10, 2018 4:06 am

Re: Java PDF conversion issue

Postby RoryOF » Thu Sep 05, 2019 6:53 pm

/File /Export as PDF worked correctly for me, using "out of the box" settings.
Apache OpenOffice 4.1.7 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29789
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Java PDF conversion issue

Postby Villeroy » Thu Sep 05, 2019 7:49 pm

Try without property "Hidden"
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27306
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Java PDF conversion issue

Postby Villeroy » Sat Sep 07, 2019 5:39 pm

With https://libreoffice.org/ I get a correct PDF with this shell command:
>"C:\Program Files\LibreOffice\program\soffice.exe" --convert-to pdf:writer_pdf_Export File_example.odt
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27306
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Java PDF conversion issue

Postby Hagar Delest » Sun Sep 08, 2019 9:32 pm

Your files seems genuine. I've deleted them to prevent private data from being shared publicly.
If you need to upload a file, please make sure it does not contain any personal data. Or anonymize it, see How to attach a document here.
AOO 4.1.7 on Xubuntu 19.10 and 4.1.5 on Windows 10 (with winPenPack port).
User avatar
Hagar Delest
Moderator
 
Posts: 28595
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Java PDF conversion issue

Postby michele ricciardi » Thu Sep 12, 2019 2:47 pm

YODA wrote:I do not know Java but you could try File > export as PDF then fill in the options you want and click on export.


Thank you for your answer, but I need to do it in programmatically in Java.
OpenOffice 4.1
michele ricciardi
 
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Postby michele ricciardi » Thu Sep 12, 2019 2:50 pm

RoryOF wrote:/File /Export as PDF worked correctly for me, using "out of the box" settings.


Thank you for your answer, but I need to do it in programmatically in Java.
OpenOffice 4.1
michele ricciardi
 
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Postby RoryOF » Thu Sep 12, 2019 2:54 pm

While you consider how to do this, as a quick workaround, you might drop to a shell from Java and use a command line PDF conversion.
Apache OpenOffice 4.1.7 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29789
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Java PDF conversion issue

Postby michele ricciardi » Thu Sep 12, 2019 5:02 pm

RoryOF wrote:While you consider how to do this, as a quick workaround, you might drop to a shell from Java and use a command line PDF conversion.


How can I do this? Do you know how to convert an odt to pdf via command line?

Thanks in advance.
Michele
OpenOffice 4.1
michele ricciardi
 
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Postby michele ricciardi » Thu Sep 12, 2019 5:04 pm

Hagar Delest wrote:Your files seems genuine. I've deleted them to prevent private data from being shared publicly.
If you need to upload a file, please make sure it does not contain any personal data. Or anonymize it, see How to attach a document here.


Actually they were already totally anonymized.

Michele
OpenOffice 4.1
michele ricciardi
 
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Postby RoryOF » Thu Sep 12, 2019 5:39 pm

In his posting of 07 Sept 2019 at 16:39, earlier in this thread, Villeroy gives you the command line.
Apache OpenOffice 4.1.7 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29789
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Java PDF conversion issue

Postby michele ricciardi » Thu Sep 12, 2019 6:10 pm

RoryOF wrote:In his posting of 07 Sept 2019 at 16:39, earlier in this thread, Villeroy gives you the command line.


Yes, I saw it, but it doesn't works with open office but it works just with libreoffice.

Michele
OpenOffice 4.1
michele ricciardi
 
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Postby RoryOF » Thu Sep 12, 2019 6:12 pm

Have you tried replacing the libreoffice with openoffice?
Apache OpenOffice 4.1.7 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29789
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Java PDF conversion issue

Postby michele ricciardi » Thu Sep 12, 2019 6:16 pm

RoryOF wrote:Have you tried replacing the libreoffice with openoffice?


Yes I've, but it get worse.
OpenOffice 4.1
michele ricciardi
 
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Postby michele ricciardi » Wed Sep 18, 2019 3:13 pm

Hi guys, do you have any suggestion on this problem?
OpenOffice 4.1
michele ricciardi
 
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Postby robleyd » Wed Sep 18, 2019 3:26 pm

michele ricciardi wrote:
RoryOF wrote:Have you tried replacing the libreoffice with openoffice?


Yes I've, but it get worse.


What does this mean? What is the command you are running? Is there an error message?
Cheers
David
Apache OpenOffice 420m2(Build:9821) - 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: 3040
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Java PDF conversion issue

Postby michele ricciardi » Wed Sep 18, 2019 3:41 pm

robleyd wrote:
michele ricciardi wrote:
RoryOF wrote:Have you tried replacing the libreoffice with openoffice?


Yes I've, but it get worse.


What does this mean? What is the command you are running? Is there an error message?


It means that the number of wrong pdf documents created from an odt document, with Libreoffice was higher, instead with OpenOffice is lower. But the problem is present with both the technology.

But I don't understand why the error happens just programmatically and not manually.
OpenOffice 4.1
michele ricciardi
 
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm


Return to External Programs

Who is online

Users browsing this forum: No registered users and 0 guests