Page 1 of 1

Java PDF conversion issue

Posted: Thu Sep 05, 2019 4:21 pm
by michele ricciardi
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

	
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

Re: Java PDF conversion issue

Posted: Thu Sep 05, 2019 4:56 pm
by YODA
I do not know Java but you could try File > export as PDF then fill in the options you want and click on export.

Re: Java PDF conversion issue

Posted: Thu Sep 05, 2019 6:53 pm
by RoryOF
/File /Export as PDF worked correctly for me, using "out of the box" settings.

Re: Java PDF conversion issue

Posted: Thu Sep 05, 2019 7:49 pm
by Villeroy
Try without property "Hidden"

Re: Java PDF conversion issue

Posted: Sat Sep 07, 2019 5:39 pm
by Villeroy
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

Re: Java PDF conversion issue

Posted: Sun Sep 08, 2019 9:32 pm
by Hagar Delest
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.

Re: Java PDF conversion issue

Posted: Thu Sep 12, 2019 2:47 pm
by michele ricciardi
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.

Re: Java PDF conversion issue

Posted: Thu Sep 12, 2019 2:50 pm
by michele ricciardi
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.

Re: Java PDF conversion issue

Posted: Thu Sep 12, 2019 2:54 pm
by RoryOF
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.

Re: Java PDF conversion issue

Posted: Thu Sep 12, 2019 5:02 pm
by michele ricciardi
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

Re: Java PDF conversion issue

Posted: Thu Sep 12, 2019 5:04 pm
by michele ricciardi
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

Re: Java PDF conversion issue

Posted: Thu Sep 12, 2019 5:39 pm
by RoryOF
In his posting of 07 Sept 2019 at 16:39, earlier in this thread, Villeroy gives you the command line.

Re: Java PDF conversion issue

Posted: Thu Sep 12, 2019 6:10 pm
by michele ricciardi
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

Re: Java PDF conversion issue

Posted: Thu Sep 12, 2019 6:12 pm
by RoryOF
Have you tried replacing the libreoffice with openoffice?

Re: Java PDF conversion issue

Posted: Thu Sep 12, 2019 6:16 pm
by michele ricciardi
RoryOF wrote:Have you tried replacing the libreoffice with openoffice?
Yes I've, but it get worse.

Re: Java PDF conversion issue

Posted: Wed Sep 18, 2019 3:13 pm
by michele ricciardi
Hi guys, do you have any suggestion on this problem?

Re: Java PDF conversion issue

Posted: Wed Sep 18, 2019 3:26 pm
by robleyd
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?

Re: Java PDF conversion issue

Posted: Wed Sep 18, 2019 3:41 pm
by michele ricciardi
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.

Re: Java PDF conversion issue

Posted: Wed May 12, 2021 4:31 pm
by BrianBPK
I'm having the same problem with LibreOffice on CentOS as well. It's all that is available from yum. I tried to install Open Office the manual way without yum and OO doesn't even do the conversion...no errors either although the soffice program is running headless.