1

I've read following and many more:

  1. print xlsx file from command line using ghostscript and libreoffice
  2. Print chosen worksheets in excel files to pdf in python
  3. Python Converting an Excel file (.xlsx) to a PDF (.pdf)
  4. Python - Converting XLSX to PDF
  5. Can you hard print an .xlsx file on Linux with Python? (unasnwered)
  6. Python library to open existing .xlsx workbook with charts

  • I have an xlsx file that contains lots of charts, tables and pictures (png watermarks inserted into the excel sheet as picture). E.g. see this sample template.
  • I want to print this to a pdf.
  • I'm on Linux and preferably want to use Python.

Closest I came was using libreoffice as described in answer #1 (Command used: libreoffice --headless --invisible --convert-to pdf ./Book1.xlsx) in list above. But all the text/formatting is messed up (whether I open the pdf file on Linux where I printed it or on Windows where I created the original xlsx file):

enter image description here

Same xlsx file printed on Windows using Excel App's print to pdf: enter image description here

File does look ok when I open it in libreoffice-calc on linux: enter image description here

Kashyap
  • 15,354
  • 13
  • 64
  • 103
  • Does the file look OK when you open the it with LibreOffice manually? – Bodo Jan 12 '23 at 18:18
  • @Bodo, yes, unfortunately it does look almost OK. I added a pic to the post. – Kashyap Jan 12 '23 at 18:41
  • The [answer to #1](https://askubuntu.com/a/437346/1186757) suggests two commands. Please show the command you used. Can you share an xlsx file to reproduce the problem? – Bodo Jan 13 '23 at 13:27
  • @Bodo, added "Command used" and link to a "Sample template" that you can use. You can use any excel with a chart. Only difference is mine was simpler and had just one sheet. – Kashyap Jan 13 '23 at 18:08
  • @Bodo, just checking in case you had ideas..? Thanks! – Kashyap Jan 18 '23 at 18:28

0 Answers0