How can i convert a .xlsx (with an image on header) to PDF on Unix?

419 Views Asked by At

I have a .xlsx file with an image on header. When i try to convert to PDF via terminal using libreoffice it converts but the image doesn't appear on the generated PDF.

Here is a screenshot of the main .xlsx file on Excel (print mode):

enter image description here

And the Screenshot of the generated PDF: enter image description here

The command that im using is: soffice --headless --convert-to pdf --outdir /home/output /home/input/headers_footers.xlsx

Note: To display the header image of the .xlsx on excel we need to put it into print view mode (ctrl+p)

I tested the conversion of the headers_footers.xlsx with an online convertion tool to PDF and the final result was as expected: the image appeared.

But i need to do this programatically, so im not sure if its libreoffice or if i need to use other tool, or maybe manipulate the final PDF and add an image on it?

1

There are 1 best solutions below

0
On

This is not only an UNIX problem. I can reproduce the malfunction running MS Windows 10. The header image appears in print view and in manually exported PDF. But when you call

soffice --headless --convert-to pdf --outdir . sample.xlsx

on command line it won't show up. I will keep on searching for an answer but this seems to be a bug to me.

Is using a LO Basic Macro an acceptable approach for you, too?

Sub ExportCalcToPDF
  sURL = convertToURL("d:\temp\lo_calc.pdf")
  dim mFileType(0)
  mFileType(0) = createUnoStruct("com.sun.star.beans.PropertyValue")
  mFileType(0).Name = "FilterName"
  mFileType(0).Value = "calc_pdf_Export"
  thisComponent.storeToURL(sURL, mFileType())
End Sub

When executed this macro exports the spreadsheet to pdf. To run the macro automatically e.g. on file open assign it to "Open Document" in Tools > Customize > Events.

Doing a test by double clicking the xlsx file the image appears in the header of the pdf. However, no success from command line so far.