Question

I'm building a web application which will include functionality that takes MS Word (and possibly input from a web-based rich text editor) documents, substitutes values into the formfield placeholders in those documents, and generates a PCL document as output.

I'm developing in python and django on windows, but this whole solution will need to be deployed to a web host (yet to be chosen), which in practice means that the solution will need to run on linux.

I'm open to linux-only solutions if that's the only way. I'm open to solutions that involve talking to a server written in another language. I am able to write C++ or java if necessary to get this done. The final output does have to be in PCL format.

My question is: what is a good tool chain for generating PCL from word documents using python?

I am considering using some kind of interface to openoffice to open the word documents, do the substitutions, and send the output to some kind of printer driver. Does anyone have experience with this? What libraries would you recommend?

Options for interfacing that I have identified include the following; any other suggestions would be greatly welcomed:

A second approach would be to use something like paradocx ( https://bitbucket.org/yougov/paradocx/wiki/Home ) to open the word files, do the substitutions using that in python, then somehow interface with something that can output PCL. Again, any experience or comments on this approach would be appreciated.

I will very much appreciate any comments on tools and toolchains, and ideas or recipes that you may have.

This question covers similar ground to, but is not the same as: How to Create PCL file from MS word

Was it helpful?

Solution 2

OK, so my final solution involved creating a java webservice to perform my transcoding.

  • Docx4j provides a class org.docx4j.convert.out.pdf.viaXSLFO.Conversion which hooks into apache FOP to convert Docx to PDF; that can be easily hacked to convert to PCL (because FOP outputs PCL)
  • Spark is a lightweight java web framework which allowed me to wrap my transcoder in a web service
  • Because I also manipulate the document, I need to have some metadata, so the perfect thing is a multipart form. I decode that using Apache Fileupload

In almost all cases, I had to upgrade to the development versions of libraries to get this to work.

On the python side I use:

  • requests to communicate with the web service
  • poster to prepare the multi-part request

OTHER TIPS

Ghostscript can read PS (Postscript) or PDF and create PCL. You can use python libraries or just subprocess....

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top