When I am trying to run this code on an excel document:
import subprocess
subprocess.run(['libreoffice', '--headless', '--convert-to', 'pdf',
'test_docs/doc.xls', '--outdir', 'tmp_docs'])
My document splits by width on 2 pages with the second page as shown below: (https://i.sstatic.net/LRaPbvwd.png)
Why would this happen and how to fix this?
I have found an answer:
Basically it looks like this is a common issue with excel conversion to pdf, so the solution is to add this line below. It converts a full excel sheet to single pdf page, but I am satisfied with this solution:
'pdf:calc_pdf_Export:{"SinglePageSheets":{"type":"boolean","value":"true"}}'
subprocess.run(['libreoffice', '--headless', '--convert-to', 'pdf:calc_pdf_Export:{"SinglePageSheets":{"type":"boolean","value":"true"}}',
f'test_docs/{file}', '--outdir', 'tmp_docs'])