I'm looking for a solution (consisting of one or more tools) which allows me to implement a personal document workflow to deliver documents of a professional nature with a minimal of repetitive work (e.g. styling).

The idea behind it is that I often have to write documents where the content differs, but the styling is always limited to a handful of layouts. Currently, these documents are written in Microsoft Word, but I find that I spend too much time fiddling with the layout and that it is distracting me from what matters, i.e. the content.

As a test, I wrote one document in plain text first (well, Markdown actually) and found that I was able to focus much better on the writing itself. The penalty came afterwards when having to piece everything back into Word.

These are the requirements:

  • Be able to define templates. These templates should contain style definitions (headers, colours, logo, …).
  • Write content using plain text with minimal markup for styling. Ideally, this would be something like Markdown or reStructuredText.
  • Generate table of contents, support for headers and footers, …
  • Export to PDF is crucial.
  • Run on OS X.
  • A command-line interface.

Nice to have:

  • Templates which support the use metadata (defined separately) to automatically create a distribution list, version overview … .
  • Export to different file types (e.g. doc(x), HTML, …).

Remarks:

  • A solution that would allow HTML + CSS would probably work too, as I can convert Markdown, RST, ... to HTML (using an intermediate conversion engine).

  • I would prefer a tool instead of a pure API library, though the latter is welcome as an addition and to implement further customisation. In that case, the API has to support Python 3.

What I've evaluated so far:

  • Pandoc: Uses Latex to export to PDF. While in theory I could define Latex templates, the learning curve of Latex for what I needed it was prohibitively steep. The conversion of MD tables to PDF was also rather lacking. From what I've gathered, using reStructuredText could be a solution for the table issue.
  • Prince: A commercial solution. This was a fairly close match to my requirements, however the lack of clear documentation (both official documentation and information found in the forum) was a big let down.
  • xhtml2pdf: HTML/CSS to PDF converter based on Python. This falls somewhere between a pure API and a tool you can use out of the box. It's based on the well known ReportLab PDF generation engine. The problem with xhtml2pdf is that Python 3 support is still largely broken in the current version (0.0.6).

Update:

In the end, I've settled for the following combination:

  • Python-Markdown: converts the Markdown source document to HTML
  • Jinja2: provides the necessary template features
  • PyYAML: metadata is entered in a separate YAML file and read with PyYAML
  • Weasyprint: performs the final conversion of HTML to PDF

While they're different tools/libraries, I was able to combine them rather easily using Python, allowing me to create a PDF document formatted using CSS documents.

However, I'm still selecting No-nonsense's suggestion Docxpresso as the "correct" answer, as it has one important advantage: Docxpresso generates ODF files, which still allows you to make minor modifications before the conversion to the final PDF file.

  • Would HTML for the content and CSS for the styles be an acceptable approach? If so, please take a look at the chapter about iText and XML Worker in The Best iText Questions on StackOverflow written by a fellow Belgian. – Bruno Lowagie Jun 16 '15 at 11:18
  • It might be worthwhile to have a closer look at the styling capabilities of OpenOffice. For really serious stuff, using a virtual Windows machine and Framemaker would be my preferred choice. – Max Wyss Jun 16 '15 at 11:54
  • Please make the whole "Update" paragraph into an answer. Thanks! – Nicolas Raoul Mar 1 '17 at 8:54

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.