Saturday, May 5, 2018

microsoft word - DOCX to PDF... with Custom Document Properties

TLDR: How can I convert a DOC(X) to a PDF and keep CustomDocumentProperties and Fields - so that I can programmatically update the Custom Properties and print the PDF via a Windows Service?


!TLDR


We have a custom in-house application that pairs DOCX creation - followed with field updates and printing. The application as it is - a Windows Form based program - works but requires it to be run from user shell. I want to upgrade this program to be run from a Windows Service.


THE issue with DOCX in a Windows Service is printing. Must have Word Installed on the Server. Word doesn't play well outside of a user shell - Modal Dialogs, user prompts (do you want to restore one of these? Do you want to enable editing of this document? etc), required registry entries, etc.


I'm exploring adjusting our workflow to PDFs on the server.


Workflow


DOC(X) Prep/Creation (Manual, not in-program):



  • Import/Run VBScript:

    • Get table/view columns out of a database.

    • Each column goes into a Custom DocumentProperty.


  • Place Fields into document for desired Custom Properties.


So CustomerName, AddressLine1, City, etc get added as CustomDocumentProperties... then the fields get placed in the right spots on a form to print automatically in the automated program.


DOCX Usage (Automatic, in program):



  • Pull row from same table

  • Put correct data into each CustomDocumentPropertyField

  • Update fields (replaces CustomerName with Doe, John, City with Whoville, etc)

  • Print document to correct printer


Desired Changes


I'm looking to either


a. Convert the DOC(X) to a PDF in such a way that the custom properties transfer - as well as the ability to replace the fields - remains intact. Would be 1) Create DOCX (lots of these currently exist and is current workflow), 2) Convert to PDF, 3) Update/print PDF. PRO: Continued use of word products that customers are happy with/trained in. CONS: Possibly complex docx/pdf conversion in the middle in exchange for the easier PDF printing inside a windows service.


b. Replace DOC(X) completely and instead use PDF creation tools. PRO: Same two step process. CON: Users are used to DOC(X) creation. Additional software/training may be needed. Lots of documents would need to be converted.


c. Work around DOCX as a service and get it to print inside a service.


This question is exploring a - DOC(X) conversion to PDF. Given a Word Document with Custom Document Properties and Fields placed on the document... I seem to lose those properties AND the fields are replaced with the current values when I convert to PDF via Save As PDF in Word. What other viable options are there to convert to PDF - keeping that information for step 2) DOCX Usage/Printing.

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...