Reputation: 331
I'm looking for a way to output a VERY simple pdf file from Python. Basically it will consist of two columns of words, one in Russian (so utf-8 characters) and the other in English.
I've been googling for about an hour, and the packages I've found are either massive overkill (and still don't provide useful examples) such as ReportLab, or seem to assume that the only thing anyone would ever do with pdfs is concatenate several of them together (PyPdf, pdfrw).
Maybe I'm just missing something obvious, but all the ones I've seen seem to launch into some massive discussion about taking 17 pdf files and converting them into a 60 foot wide poster with 23 panes (slight exaggeration maybe), and leave me wondering how to get the "Hello World" program working. Any help would be appreciated.
Upvotes: 23
Views: 15072
Reputation: 308
A simpler approach would be to use the csv package to write the two columns to a .csv file, then read it into a spreadsheet & print to pdf. Not 100% python but maybe 90% less work ...
Upvotes: 0
Reputation: 1589
You may use wkhtmltopdf. It is a command line utility that uses Webkit to convert html to pdf.
You can generate your data as html and style it with css if you want, then, use wkhtmltopdf to generate the pdf file.
Upvotes: 10
Reputation: 2124
you could also use weasyprint it supports specific css paged media features
Upvotes: 0
Reputation: 43097
rst2pdf
does exactly what you want; with restructured text input
Styles can be applied inline with native RST styling, and document-level properties (including fonts) are controlled with a style sheet.
Upvotes: 5
Reputation: 72855
A recipe to convert a text file to a PDF. A little long but pure Python and with no external dependencies.
Upvotes: 1
Reputation: 5665
Try pod (python open document) is a library that allows to easily generate documents whose content is dynamic.
pod generates another ODF text document (ODT) that contains the desired result.pod can call OpenOffice in server mode to generate the result in PDF, DOC, RTF or TXT format.
Upvotes: 1