There was a task to convert xls to pdf on the old server with Linux, and this requirement created serious problems, because it is completely incomprehensible how to do this.

For python, there are various pyPDF2 pyXLSX utilities, but it is not clear how to cross them. Because all examples of the same pyPDF2 work only with other pdf or with drawing on Canvas.

For C ++, I have not found a suitable solution yet.

The situation is further complicated by the fact that the original xls is not trivial, with different colors and tables. Therefore, the translation option in csv, as an intermediate format, for example, disappears. In this case, I would not like to translate to jpg, because later in the text in pdf you will need a search + printing problems.

In this case, the original xls consists of a set of worksheets, each of which contains a table. And many tables are wider than the width of the sheet in pdf. Accordingly, when translating (I tested under windows) pdf these tables are ugly cropped and inserted into stubs, making the document unreadable. Therefore, everything else, the worksheets in xls should also be reduced before converting so that it is one page wide.

I’m looking in the direction of unoconv and LibreOffice now, but considering that before converting you need to do more manipulations with xls, I don’t imagine how I will decide as a result.

Still there is an option to just pick up a virtual machine with Windows with a simple service that will listen to the network and perform these actions. But this solution looks like a big crutch.

Have you already solved such a problem? If so, how? Maybe there are some ideas? Binding to python and C ++ is optional.

    2 answers 2

    You can use unoconv (in ubunt is in the repositories).

    The command line is:

     unoconv -f pdf File.xls 
    • Yes, I'm digging this option right now. Considering that, besides this, I need to do a table spread in landscape form and shrink the columns wide, if at the same time they crawl over the page, unoconv may not be enough for me) - Arkady
    • Heavy, however. - skegg

    You are sorry, but not entirely clear. Why spreadsheets to overtake in the format of the book. If cross-readability is required in the format of an e-table, there are enough offices for Windows and a penguin. And the easiest way is to remake all the tables in HTML.

    • In this case, such a TK. Why exactly this is needed - I do not know. Just a task arrived from another project, because I have unoccupied hours, with which, allegedly, for some reason, the javista could not cope with the whole department, so she turned out to be with me. A challenge for a wizard or crutch master. - Arkady
    • @smallFish, but from such tasks (with the right approach) you get all the wonderful things (like unix). - avp