LibreOffice 7.6 XLS to PDF Bad Page layout

Hello, I am using libreoffice to convert from .XLS to .PDF.

I am using the CLI command:

/usr/bin/libreoffice7.6 --headless --invisible --nodefault --view --nolockcheck --nologo --norestore --convert-to pdf:calc_pdf_Export --outdir /tmp /tmp/file.xls

If I open the file in MS Excel GUI and try to print it as a PDF, I get the correct formatting.

Whenever I try to use it through LibreOffice on my linux terminal, I get more pages because what I expected would fit into one page, does not fit (See image below).


On the left is exported using Excel, and on the right is the result of the LibreOffice conversion.

LibreOffice generated 8 pages instead of two, and this is because the content didn’t fit horizontally and vertically.

What might be going wrong here?

  1. Is it inherently the case that XLS files will never have the same “PDF export layout” in LibreOffice as they do in Windows?
  2. Are there settings or something I’m missing in LibreOffice terminal command?

XLS(X) files not only are “foreign” - which means, that LibreOffice only supports some subset of it, and also that LibreOffice feature set is not necessarily compatible with potential features found in these documents. Not only that: the very interesting detail is how the width (of columns) is stored in these Excel files. Specifically, the Excel file defines a “Normal” style (its font face and size); and then, all cell widths are kept in number of “characters” (reference).

That means, that the column width will vary depending on the font; the application must find the font, then measure the “width of character” (indeed, if it needed to use a substitute font, that would be different size! Are you sure that your Linux box has all the required fonts?). Of course, life would be so boring, if MS decided to use some dull units like millimeters, inches and so on.

There is a good feature in both Excel and Calc, where user can define that the document fits exactly N pages wide (of high), so that the pages would auto-scale, undoing that black magic of odd units - but only fools would use that. Normal users will bravely ignore that feature, and hope that their manual settings of column widths that they set on one system in one application will fit everyone :slight_smile: