Controlling PDF Export Paper Size in LibreOffice Headless Mode

Hi,

I have a .docx file that contains a table with images. When I open the file in the LibreOffice UI, the table and consequently the image get truncated due to the size is more than the default page size.

We are using LibreOffice in --headless mode to convert the document to PDF, Since the export defaults to a paper size of 8.5 x 11 inches, the same truncation issue occurs in the exported PDF as well.
I searched existing questions on ask.libreoffice.org but couldn’t get the correct answer.

Is there a way to control or specify the paper size for PDF export via the command-line interface in LibreOffice?

Best regards,
Satya

1 Like

Test_Image Issue in Table.docx (54.0 KB)
Attaching the sample file.

API/Tutorials/PDF export - The Document Foundation Wiki
Passing in JSON parameters into Writer for the --convert-to option

@mikekaganski When I use the following command with the unoconv, I can get the PDF with desired paper size.
python unoconv -f pdf -P PaperOrientation=landscape -P PaperFormat=TABLOID c:\Dev\Files\ImageIssue.docx
Do we have the same option to specify for soffice --headless , I couldn’t find one at PDF CLI Parameters

No we haven’t. As far as I understand, unoconv is not just a wrapper around --convert-to, it also edits exported files.

I assume your used format (8.5 x 11 inches), is the last setting used in the user-profile (or default, if this was never used). So to have more than one size availabe in headless mode, you need to use several profiles.
.
The following thread covers how to use several profiles:

@Wanderer Thank you for your help. I know how to use multiple user profiles for different purposes. But there is noway to control the Page format using user profiles.

How would that help, when you can’t assign sizes to existing documents? --convert-to is designed to not be an editing feature, simply taking data as already defined in the document.

Sorry I was mislead by the use of “default”, but as Mike already wrote (and I should know from my files): The size comes with the document…
.
This leaves a macro to edit paper-size as the only option I can think of (inside LibreOffice), and this can change the complete layout of the document.