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: (.png)
Why would this happen and how to fix this?
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/LRaPbvwd.png)
Why would this happen and how to fix this?
Share Improve this question edited Mar 17 at 14:25 Timus 11.4k5 gold badges17 silver badges31 bronze badges asked Mar 17 at 13:06 IvanIvan 112 bronze badges 5 |1 Answer
Reset to default 1I 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'])
libreoffice
application. – Mark Ransom Commented Mar 17 at 18:10