How to convert excel to pdf with page format - user (user defined height and width), in landscape

we are converting excel to pdf using libreOffice, in python using this command.
['/Applications/LibreOffice.app/Contents/MacOS/soffice', '--headless', '--convert-to', 'pdf', '--outdir', 'temp/upload_o3lu510o', 'temp/upload_o3lu510o/report-card.xlsx']

it is working fine for predefined page formats like A4, converting both in landscape and portrait as selected in page layout settings.
but when we are giving custom height and width to page (which sets the page layout to user), it is only converting to pdf in portrait mode, even if landscape is selected.
How can I get the required output ? I want it to convert excel to pdf also in landscape when user defined height and width are provided.

Page settings are inside the document. If they are set in the document correctly, but not exported (or maybe even imported?) as defined in the document, it would be a bug. A sample document, which has the settings, but ignores them on export, would be required.

template.xlsx (178.2 KB)
in this excel in sheet Neo SA2,
page layout is set to user defined with landscape value. In print preview, it shows correctly, but on converting to pdf through code, it is converting in portrait mode.

Yes, this is a bug; open it in GUI, and check that it correctly shows Landscape in FormatPage StylePage, but shows portrait orientation there; and when you toggle the portrait/landscape there, it toggles to the incorrect representation.

You might want to file a bug report.

On the other hand: Excel has the Landscape, yes; but it doesn’t show any custom page format - it shows A4 for me (and Calc shows “Custom”, but seemingly Letter page size). Something is phishy with the file. Is it generated? Is the generator broken?

in page style, first I selected A4, and then changed the height width a little according to the need.

You don’t even tell which application you used in the process. And what “according to the need” means exactly in millimeters (so that it could be tested).

I used libreOffice, and changed the width and height different from the predefined for A4 layout here just for testing. In real scenerio user would be changing width and height of the page to fit the inside content perfectly. in this case width: 28.9 cm, height : 21.9 cm.

Just to clarify: in which dialog have you changed the page size?

format → page style → page tab

here there are 4 options in paper format which i am changing.
format : changing it to A4,
then changing orientation to landscape,
then altering height and width a little.

… and after save-and-reload, the size is wrong? At least that’s what I see. A bug.

oh yes, got it, it is resetting the page format in some weird way. so it is a bug