Priesto
Priesto

Reputation: 61

What python modules should I use to edit a word document then turn it to a pdf?

I want users to be able to create the report template in Microsoft Word, I'll then probably add document fields. Then the script evaluates a number of things adds the appropriate text to the fields then creates a pdf of the filled in form.

So which modules would be best for this? I've looked at reportlab but I need to work from a pre-generated template and that doesn't seem feasible.

Upvotes: 2

Views: 2503

Answers (2)

Paul Jowett
Paul Jowett

Reputation: 6581

If it suits your application to use a cloud service to populate Doc/DocX files there is a commercial system called Docmosis that can popluate plain-text (or merge) fields and stream back populated PDF documents to your Python system, or deliver via email etc.

You would upload your "template" Doc files to Docmosis via the Website (or api calls) then invoke Docmosis using a https post from your Python code.

Please note I work for the company that created Docmosis.
Hope that helps.

Upvotes: 0

rano
rano

Reputation: 5676

If you will use it only under Windows, having Word installed you could use PyWin32 that lets you access the api of the suite. You could also try IronPython as suggested here.

If you need to read a docx template regardless of the platform you could try this outdated extension.

Upvotes: 1

Related Questions