How to convert xlsx to pdf on one page

649 views Asked by At

I have a 13 column xlsx and I want convert to pdf. I use this code: "soffice" ,"--headless","--convert-to", "pdf" , filepath ,"--outdir",outpath. I can convert to pdf but the columns too many so they have been showed on four pages. I need they show on one page. And it show on straight , I need it show on horizontal. Thanks

2

There are 2 answers

3
K J On

XLSX printout settings (PDF export) are part of the file contents so here is the same file saved with different settings but same export command. (convert-to implies headless, so not generally needed. The author decides a cell content and shape and also sets how many rows and columns will fit in a standard page such as A4 portrait or A4 Landscape etc. Thus only a macro can change print layout area. The best that may be possible externally is to scale it up or down on to bigger or smaller paper.

soffice --convert-to pdf:calc_pdf_Export "DataTables example Default.xlsx"
soffice --convert-to pdf:calc_pdf_Export "DataTables example A3.xlsx"

You need to change layout for printing and export in the preview screen if you want 13 columns you set area from A:1 to M:Y where Y is your desired number of lines (whatever their variable height may be.)

enter image description here

enter image description here

0
utrucceh On

From https://ask.libreoffice.org/t/libreoffice-xls-to-pdf-conversion-breaks-single-page-content-into-multiple-pages-on-ubuntu-18-04/49104/2

Linux:

soffice --convert-to 'pdf:calc_pdf_Export:{"SinglePageSheets":{"type":"boolean","value":"true"}}' test.ods

Windows:

soffice --convert-to "pdf:calc_pdf_Export:{\"SinglePageSheets\":{\"type\":\"boolean\",\"value\":\"true\"}}" test.ods