Convert .xlsx to .pdf via command line

When I convert the .xlsx file to .pdf the page is broken and the content of one page is displayed in two different pages.

This only happens when I do it from CLI:

$ libreoffice --headless --convert-to pdf:calc_pdf_Export --outdir pdf/ template.xlsx

alt text

However, if I do it directly from “Export to PDF” from the GUI, the result is correct:

alt text

The same document with the same settings is used for both tests. This is the test file: https://ufile.io/jvfpm

I’m using version 5.4.6.2 of LibreOffice and 18 version of Linux Mint.

Any possible solution?

Thanks!

Please provide the sample to test. And what LO version is used?

This is the file: https://ufile.io/jvfpm

I’m using version 5.4.6.2 of LibreOffice.

Thank you!

Very strange - I can’t reproduce with 5.4.6.2 (x64) on Win10 neither using pdf:calc_pdf_Export, nor using simple pdf

mm I don’t think it’s related to the LO version, I’ve updated a moment ago since version 4 to see if it fixed the problem.

Of course: I specifically chose your version to test. More possible that it’s platform-dependent…

I’ve tried with Version: 6.0.2.1
Build ID: 1:6.0.2~rc1-0ubuntu0.16.04.1~lo1
CPU threads: 2; OS: Linux 4.4; UI render: default; VCL: gtk2;
Locale: en-US (en_US.UTF-8); Calc: group

and reproduce this - but both using command line and UI. So - are you sure you are using the same LO in both your testings, or is it possible that you have different installations/user profiles for your UI vs CLI tests?

Could be in relation with tdf#65848 FILEOPEN: CALC doesn’t import scaling factor set on xlsx files

My testing shows the following. The spreadsheet opens with different column widths in Windows vs Ubuntu, e.g. column A width being 0.65 cm vs 0.81 cm resp. And the other important difference between them is that Ubuntu lacks Calibri font used in the spreadsheet.

MS Excel defines column widths in units of characters, column A width being 2.57 characters of the used font. So, it looks like this is the reason for different column width readings on the two platforms. However, this is also clearly a bug, since LibreOffice bundles a metrically compatible font Carlito, which is substituted for Calibri when required. So, either it is not used when cell width is determined, or the font’s metrics are still somewhat incompatible in some detail.

However, this does not explain why you see the correct result when using GUI. I can only guess that you could have Calibri on your system installed locally, which isn’t used when you use CLI… still a mystery actually.

Filed tdf#116738.

I have tested CLI result on my Ubuntu box after installing Calibri locally, and it works correctly for me now. So - still have to find out why you see the different results.

EDIT: now I have closed the bug mentioned above as NOTABUG, since I found out that I had not the Carlito font installed on my testing Ubuntu box. After installing it, I have correct column widths (both in GUI, and CLI). The substitution works correctly, and not having a proper font inevitably results in incorrect width due to XLSX format specifics (I wonder which bright mind could invent the idea of using char widths in used font for column widths). Your different results still wait for an explanation.

As a related information: of course, the spreadsheet is formatted fundamentally incorrectly (according to principles spreadsheets are based on). Spreadsheet applications (both Calc and Excel) have means of defining how many pages should the printout take, or how many pages should width/height take on print (in Calc, you use FormatPage for that, Sheet tab, Scale controls). Relying on defining some column widths in hope to get some fixed page layout is bound to result in problems like this, also when e.g. printer would have different margins.

Thank you very much Mike,

As you so rightly say, it was all due to something as simple as the lack of some text fonts on my system…the file was sent to me after it was created in Windows.