What good document standard to use programmatically?

I am writing a program that requires input as a document, it needs to replace several values, insert a table and convert it to PDF. It is written in Python + Qt (PyQt). Is there a well-known document standard that can be easily used programmatically? It should be a cross platform and preferably open.

  • I looked at Microsoft Doc and Docx, which are binary formats, and I cannot edit them. Python has bindings for it, but they are only on Windows.

  • Open Office ODT / ODF is encrypted in an XML file, so I can edit it, but there are no command line utilities or in any way programmatically convert the file to a PDF file. Open Office provides bindings, but you need to start Open Office from the command line, start the server, etc. And my clients may not have Open Office installed.

  • RTF is readable with Python, but I could not find a way / libraries for converting RTF documents to PDF.

I am currently exporting from Microsoft Word to HTML, replacing values ​​and using PyQt to convert it to PDF. However, it loses formatting features and looks awful. I am surprised that there is no well-known library that allows you to edit various document formats and convert them to other formats, am I missing something?

Update: thanks for the tip, I'll take a look at using Latex.

Thanks Jackson

+3
source share
5 answers

Have you studied LaTeX documents?

They are ideal for use programmatically (document compilation? You must love this ...) and you have several Python frameworks that you can use, such as plasTeX and PyTex .

Export LaTeX documents to PDF almost immediately.

+9
source

PyQt, , Qt RTF, . , . , QPrinter - PDF.

, , , , PyQt , - , .

, GUI Qt, .

edit: .

+2

, ReportLab. PDF , , .

+1

, , , .
Excel, xlrd.
, . Excel :

0

XML-, XSL/fo Fop RenderX. docbook , PDF, RTF, HTML .. .

, , AFAICT.

docbook , , .., "" , . XSL , .

.

"" XSL, XSL-fo .

0

Source: https://habr.com/ru/post/1750962/


All Articles