Posts Tagged ‘pdf’

PowerShell script to save all .pdf’s as .docx in and underneath a folder failing on Word 2016, working on Word 2010.

  1. Problem: Word 2016 shows erratic behavior when trying to save (admittedly: complex) .PDF as .DOCX – whether
    1. using automation
      1. “The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108  (RPC_E_DISCONNECTED))”
      2. “The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)”
    2. or trying manually.
      1. “There is a problem saving the file.”
      2. “A file error has occurred.”
      3. Or Word crashes.
  2. Workaround: My age-old Word 2010 installation on Windows Vista with PowerShell 2 (gasp! Smiley) manages this automation script (inspired by The Scripting Guy) just fine:
# Acquire a list of DOCX files in a folder
$Files = GET-CHILDITEM -include *.pdf -exclude *_converted.pdf -recurse -path 'G:\bookz\office\excel' # 'G:\bookz\lang\vba' # 'G:\bookz\office\access' # 
Foreach ($File in $Files) {
        write-host "Trying  " $File.fullname 
        # open a Word document, filename from the directory
        write-host "Opening " $File.fullname ". RESULT=" + $?
        # Swap out PDF with DOCX in the Filename
        $Name=($File.Fullname).replace("pdf",“docx”) # $Name=($Doc1.Fullname).replace("pdf",“docx”)
        # Save this File as a PDF in Word 2010/2013 - hm, and 2016 fails? 
        $Doc1.saveas([ref] $Name, [ref] 16) # see WdSaveFormat enumeration : 16 is word default, 
        $ErrorMessage = $_.Exception.Message
        $FailedItem = $_.Exception.ItemName
        write-host "Caught error saving " $FailedItem ". Msg: " $ErrorMessage 
    finally {
        [GC]::Collect() # watch me trying a number of things to get this to work with Word 2016... 🙂
        move-item -path $file.FullName -destination ($file.Directory.ToString() + "\" + $file.BaseName + "_converted" + $file.Extension)


How to fix MS-Word not creating PDF Bookmarks for your Headings

  1. Problem: No navigation bar in Acrobat Reader when viewing your PDF created from MS-Word.
  2. Solution: Check this setting first in the Save as PDF Options: image
  3. But: Word 2013’s  “Save as PDF” with “Create Bookmarks”  may remains greyed out since it won’t even see your own heading styles, even if you based these styles on the built-in heading styles (which are known to contain  “hidden magic” not easily replicated) , including their outline level, if
    1. Heading appears in Content control.
    2. Heading appears in Table.
  4. Workaround:
    1. Move headings out of Content Controls (you can still “lock”the text with Grouping, which will be enabled on the Developer Tab once you select at least a conten control and text (meant for form field labels).
    2. Move headings outside of tables.

How to bind files to PDF with eXpert PDF Creator

  1. I tried PDF Editor (mind you, old version! 6 which I still have around from a promotion – nice software, though) first, including its help.
  2. Use Batch Creator instead,
  3. uncheck “Create multiple Documents”
  4. then you will be prompted for a (new) filename for the bound files.
  5. expert-pdf-editor
  6. Then click the “save” icon  in the upper right menu.