Ask Your Question
0

Convert .xlsx to .pdf via command line

asked 2018-04-02 04:53:41 +0200

Jossius gravatar image

updated 2018-04-02 05:25:07 +0200

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!

edit retag flag offensive close merge delete

Comments

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

Mike Kaganski gravatar imageMike Kaganski ( 2018-04-02 04:56:55 +0200 )edit

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

I'm using version 5.4.6.2 of LibreOffice.

Thank you!

Jossius gravatar imageJossius ( 2018-04-02 05:03:13 +0200 )edit

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

Mike Kaganski gravatar imageMike Kaganski ( 2018-04-02 05:13:10 +0200 )edit

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.

Jossius gravatar imageJossius ( 2018-04-02 05:18:39 +0200 )edit

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

Mike Kaganski gravatar imageMike Kaganski ( 2018-04-02 06:26:27 +0200 )edit

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?

Mike Kaganski gravatar imageMike Kaganski ( 2018-04-02 07:18:46 +0200 )edit
m.a.riosv gravatar imagem.a.riosv ( 2018-04-02 13:25:21 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2018-04-02 07:38:12 +0200

updated 2018-04-02 08:36:18 +0200

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 Format->Page 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.

edit flag offensive delete link more

Comments

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.

Jossius gravatar imageJossius ( 2018-04-03 22:12:27 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-04-02 04:53:41 +0200

Seen: 3,961 times

Last updated: Apr 02 '18