Libreoffice excel to pdf conversion problem

I have a large number of documents to be converted both in excel and doc format and they are being created not by me. When I am trying to run this python code on an excel document(basically the same as running in bash):

import subprocess

subprocess.run(['libreoffice', '--headless', '--convert-to', 'pdf',
                'test_docs/doc.xls', '--outdir', 'tmp_docs'])

My document splits by width on 2 pages with the second page as shown below:
(https://i.sstatic.net/LRaPbvwd.png)

Why would this happen and how to fix this?

Your link does not grant permissions to “strangers”; your screenshot is not visible. Why don’t you paste it directly into the question?

Wild guess: your spreadsheet is quite large, more than can fit in a printed page width (which is the paper format selected in the original?). As PDF is similar to printing, within the limit of the chosen sheet size, the overflow part of the spreadsheet is sent to a second page.

You could try to export to PDF in landscape orientation (may require a change in the original).

PS: when asking here, always mention OS name, LO version and save format. Regarding the last one, you said your documents are .xls(x) and .doc(x). Expect potential compatibility issues as LO is not a drop-in replacement for M$O.

Why? When you use LibreOffice it will use the last settings from the user-profile. This may not fit your needs for a file-converter.
.
Fix: Try to find the settings to print to one page in Calc. It may give better results. If this works, consider to use different profiles for separate jobs, if necessary…