Print 2 pages per paper sheet in Calc

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
mikele
Posts: 72
Joined: Wed Nov 21, 2018 11:11 am
Location: Germany

Print 2 pages per paper sheet in Calc

Post by mikele »

Hello,
when I'm printing a calc document there is a section in the print dialog where I can choose the pages per sheet.
How can I do this per macro? I want to print a calc document the way: 2 pages per paper sheet.
Unfortunately the XPagePrintable Interface doesn't exist for calc documents (for textdocuments it would be easy...) so it seems that this option is only in the build-in dialog. :crazy:
Attachments
Bild_2022-08-28_123919969.png
Bild_2022-08-28_123919969.png (70.44 KiB) Viewed 943 times
LibreOffice 5.4, 7.0, 7.2 on LinuxMint/Win10
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Print 2 pages per paper sheet in Calc

Post by Lupp »

I wouldn't expect OOo (any younger branch or version) or any ordinary software to know all the printers and their features/abilities/shortcomings.

If a printer can print many pages on a single sheet of paper or not, and in what way it can accept information about the intentions of the user will depend. The printer driver should be the instance knowing the details, and therefore I would assume that it's that driver telling OOo (or any software) what options to offer to the user asking him for his choices. My desktop PC still has more than one printer drivers installed, but the dialogs look very different.

As long as there isn't a mandatory standard concerning printer settings, neither AOO nor LibO (nor MSware) may be able to offer an interface (uniform printing dialog) covering all the thinkable variants. And as soon as there is one, everybody would ask for enhancements.

Currently in OOo (...) there are very few settings represented by clear-named fields of a structure provided by XPrinterPropertySet. All the rest seems to be delegated to a cryptic variable taking (and telling) binary information as a sequence of Byte. In case of my printer the length is about 13000 (uncompressed) when saved to the file. You may look at it for your case in the settings.xml wrapped into one of your .ods files.

Please tell me (anybody) if I only had a bad dream - and how it actually is.

Also somebody may try to intercept a print job, and to set the binary information as taken from an example file. If this works as intended, please report - and if it fails, report in what way.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Print 2 pages per paper sheet in Calc

Post by JeJe »

If there's no other way then in Useful Macro Information For OpenOffice.org By Andrew Pitonyak there's information about how to access the accessiblecontext of dialogs where you might be able to set the combo box as required.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
mikele
Posts: 72
Joined: Wed Nov 21, 2018 11:11 am
Location: Germany

Re: Print 2 pages per paper sheet in Calc

Post by mikele »

Hello,
thanks for your reply.
The mystery is that it seems completely independed from the printer and its feature.
I can also choose 2 pages per paper sheet when I selected 2 calc sheets with different layout (one portrait and the other one landscape).
screen.jpg
screen.jpg (41.05 KiB) Viewed 838 times
Just tested with LO 7.0.4.2 Win10
LibreOffice 5.4, 7.0, 7.2 on LinuxMint/Win10
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Print 2 pages per paper sheet in Calc

Post by Lupp »

Well, I know these dialogs. But if I edit the printer settings, different options are shown for different printers.
Anyway, I shouldn't have posted without actually knowing a lot of facts about printing I' actuall rather badly am informed about.

What I told about the settings.xml is correct, however, and I can add that additional information contained in an .ods (the wrapped-in files) doesn't explicitly state anything about printer settings you are interested in.

Hints or links concerning API srevices and interfaces I give are also generally correct.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
mikele
Posts: 72
Joined: Wed Nov 21, 2018 11:11 am
Location: Germany

Re: Print 2 pages per paper sheet in Calc

Post by mikele »

Hello,
thanks. I guess it is (somehow) hard coded but not supported via API.
LibreOffice 5.4, 7.0, 7.2 on LinuxMint/Win10
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Print 2 pages per paper sheet in Calc

Post by Lupp »

See also: https://ask.libreoffice.org/t/what-abou ... -job/81235 .
(MikeKaganski is a developer of LibreOffice for Collabora.)
If you are good friend with C (C++) you may take advantage of the links into the code given in his post.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply