How to set landscape/portrait when printing headless?

I configured my default printer (via CUPS) to do: A4 paper format, draft mode.
I.e. libreoffice -p prints my XLSX files as I wish.
But there is no option for landscape vs. portrait in CUPS, and unfortunately it prints portrait, while I need landscape right now.
As it does work from the UI, I assume, that this is a setting by libreoffice, not CUPS, right?
Can I set landscape as default somehow?
Or is there a command line option to force landscape?

Thank you!

Ask/Guide - How to use the Ask site - The Document Foundation Wiki #Are_there_any_answers_to_my_question_yet

1 Like

I’m not yet sure, if this would help me, as I’m not trying to export to PDF.
I did now export a file to PDF, just for test, but I can’t see any landscape option there.
It seems, I would have to set the landscape option for every single file below Format/Page Style, right?Opening every single file was exactly what I would like to avoid.

You might give the community a further idea about what you are trying to accomplish. Do you have a directory (folder) with hundreds of single-page files you need to print? There might be a python solution to, in fact, loop through all the files in a directory and change their page orientation. That’s not my expertise (if I even have one), but more information about your scenario might lead to something.

1 Like

lp(1) - Linux manual page :wink:

1 Like

@joshua4

I had to print 33 documents in landscape.

Lacking a simple solution for the command line, I ended up opening and printing them one by one, setting landscape printing 33 times :grinning:

@fpy

I don’t know how to combine libreoffice -p and lp in a useful way :person_shrugging:

https://unix.stackexchange.com/questions/711338/how-do-i-loop-over-the-first-several-files-in-directory

for f in /some/path/*.xlsx 
 do
   soffice --headless --convert-to pdf $f
   lp  -o 4  $(basename $f .xlsx).pdf 
done    
1 Like

@fpy

The first step, --convert-to pdf generates a portrait orientated PDF for me. I.e. even if I print it with lp as landscape then, the layout would be broken. Is there a way to convert to a landscape PDF from the command line?

so, is your problem : Frequently asked questions - Calc - The Document Foundation Wiki - How to print only part of a sheet ?
Using Print Ranges on a Spreadsheet


please, upload hereby a sample to clarify.

1 Like

It doesn’t look like any of this would work on the command line, does it?

Well, I printed all 33 documents meanwhile, one by one from the UI.
I don’t expect to have a similar task to do in the near future :grinning:

Thanks anyway for the various hints!