Java PDF conversion issue

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
michele ricciardi
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Java PDF conversion issue

Post 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
OpenOffice 4.1
YODA
Posts: 65
Joined: Fri Aug 10, 2018 4:06 am

Re: Java PDF conversion issue

Post 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.
Openoffice4.16 on windows 10 Libreoffice Version: 6.1.3.2 (x64)
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Java PDF conversion issue

Post by RoryOF »

/File /Export as PDF worked correctly for me, using "out of the box" settings.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Java PDF conversion issue

Post by Villeroy »

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 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Java PDF conversion issue

Post 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
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
Hagar Delest
Moderator
Posts: 32627
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Java PDF conversion issue

Post 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.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
michele ricciardi
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Post 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.
OpenOffice 4.1
michele ricciardi
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Post 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.
OpenOffice 4.1
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Java PDF conversion issue

Post 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.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
michele ricciardi
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Post 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
OpenOffice 4.1
michele ricciardi
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Post 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
OpenOffice 4.1
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Java PDF conversion issue

Post by RoryOF »

In his posting of 07 Sept 2019 at 16:39, earlier in this thread, Villeroy gives you the command line.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
michele ricciardi
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Post 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
OpenOffice 4.1
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Java PDF conversion issue

Post by RoryOF »

Have you tried replacing the libreoffice with openoffice?
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
michele ricciardi
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Post by michele ricciardi »

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

Post by michele ricciardi »

Hi guys, do you have any suggestion on this problem?
OpenOffice 4.1
User avatar
robleyd
Moderator
Posts: 5055
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Java PDF conversion issue

Post 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?
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.1.2; SlackBuild for 24.2.1 by Eric Hameleers
michele ricciardi
Posts: 9
Joined: Thu Sep 05, 2019 3:50 pm

Re: Java PDF conversion issue

Post 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.
OpenOffice 4.1
BrianBPK
Posts: 5
Joined: Fri Nov 09, 2018 9:00 pm

Re: Java PDF conversion issue

Post 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.
Windows 10 Open Office 4.1.2
Post Reply