How to set up orientation using soffice command line

Hi,
(first question for me).
Can you please help me understand how can I set up orientation landscape when printing with soffice bash command?

Currently I’m using this command:

soffice --headless --convert-to pdf:"calc_pdf_Export" /Users/path/to/file/.xlsx

but it prints the PDF vertically/portrait (with the shortest side align with the page below) while I need to print in landscape mode (with the longest page side aligned with the page below).

I already tried to modify the .xlsx file settings for orientation landscape but no positive results.

Thanks for your help

I already tried to modify the .xlsx

  • How?
  • What is the result, if you use File -> Export as PDF... to save as PDF using the GUI?
  • What does Print Preview show (Portrait or Landscape)?

Generally speaking: PDF export tries to produce a pdf document, which is as close as possible to what you’d get, when printing / exporting the document within the GUI. Two things to keep in mind:

  • There are no command line options to modify your document
  • Last settings being made in dialog File -> Export as PDF... get applied during export (Since these settings are stored in the user profile and if you need special settings from that dialog, you might want to create a special user profile (e.g. MyPDFExportProfile) and to use that special profile in conjunction with -env:UserInstallation=file://<full_path_to_profile>

Just tested on my LibreOffice 7.1.3.2 (TDF version) on openSUSE Leap 15.2 with no issue regarding “landscape”-export (setting in Format -> Page -> Tab: Page)

Thank you very much Opaque for your help. The last point is what solved my situation because setting up a manual export (with the right orientation) led to programmatically print with the right orientation.

Second question: Now I’m setting up on my laptop, do you think migrating the MyPDFExportProfile to a remote cloud server (without printer installed) will works?

Second question: …

If your remote cloud server is running same type of operating system, than this generally works (I do that every day on my GNU/Linux system). According to your path mentioned above ( /Users/path/to/file/.xlsx) you seem to work on macOS and then the story may (!) be a different one because most likely your remote cloud server does not run macOS. Just give it a try (chances are good die macOS is similar to *nix systems) or simply create a new MyPDFExportProfile on the cloud server (The fact that your cloud server got no printer installed should not play a role here).

About the MyPDFExportProfile I’m not able to find this file. May be the case this configuration profile is stored into the file (on macOS)

/Users/myuser/Library/Application Support/LibreOffice/4/user/registrymodifications.xcu

which seems to be modified each time I export a new PDF with a different configuration?
Otherwise can you point me in the right direction of how to create a new MyPDFExportProfile ?
Thanks again.

A user profile is not a single file but a full directory, which by default on macOS is everything in directory /Users/myuser/Library/Application Support/LibreOffice/4/.

See also: TDF -Wiki - LibreOffice user profile