Select to view content in your preferred language

How to convert Word.doc's to PDF's using Python???

5984
3
11-16-2010 10:32 AM
AaronPaul
Deactivated User
All-
I have Word.docs that I use to populate current date, then convert to pdf.

I'm automating map packs using arcpy and want to include these pdf's in my pack without first having to convert Word.docs manually.

How can I accomplish this with Python?

All I need is the coversion piece that will populate current date.
End product is a pdf with set text but has current date.

Thank you in advance, Aaron
0 Kudos
3 Replies
JasonScheirer
Esri Alum
There are several strategies you could take here:


  1. Set up a PDF printer as the default printer on the machine, turn off the print dialog, and use the command line to call MS word with the /P flag to print your word document out to a temporary location

  2. Have a pre-prepared PDF (potentially authored with Word) with blank areas where the dynamic parts go and use ReportLab to place the additional text

  3. Put it into Dynamic Text on an MXD layout (without data frames) and export that MXD to a PDF page each time for integrating into your final PDF


3 is the easiest.
0 Kudos
AaronPaul
Deactivated User
Excellent to have choices, thank you very much.

I've been using suggestion 3 and agree it may be the easiest.
I just didn't know if there was something simpler.

You've confirmed that my practices are solid 🙂

Thank you once again and enjoy, Aaron
0 Kudos
HILLARYHALL
Emerging Contributor
Try to convert Word to pdf in prorgammaticaly by call the related methods, and the Word can be in the suffic of doc and docx

Public Sub WordConvertToPdf()
     If True Then
     WordInputFile = ("C:/1.docx")
     ImageOutputFile = ImageFormat.pdf
     End If
     End Sub
     doc.Save(@"C:/1.docx", 1, @"C:/1.pdf")
0 Kudos