Reputation: 323
I am using the Word .NET API from powershell to bulk convert Word .docx files to PDF in powershell like so:
$wordApplication = New-Object -ComObject Word.Application
$doc = $wordApplication.documents.open($infilename, $false)
$doc.SaveAs($outfilename, 17)
The word files have Images with QR codes in them, and the image quality is significantly worse in the PDF than in the original .docx. This is true on screen and when printing (the latter being my actual use case).
Is there any way to do this conversion (preferably without 3rd-party tools) in a way that the image quality is retained?
Thanks in advance for any help!
Best, eDude
EDIT:
Tried the Document.ExportAsFixedFormat2
method, thanks for the pointer! Unfortunately, none of the option seem to make any difference on the end result. For reference, I tried:
$doc.ExportAsFixedFormat2($outfilename,
17, # file format (pdf)
$false, # open after export
0, # optimize for (print)
0, # range (entire document)
1, # from
1, # to
0, # export without markup
$false, # include document properties
$true, # keep IRM
0, # create bookmarks (no)
$true, # doc structure tags
$true, # include missing fonts as bitmaps
$false, # use ISO19005_1
$true # optimize for image quality
)
But it still washes out the qr code. This is the case for both ISO19005_1 on and off.
In the word file, it looks like this:
In the pdf, it comes out as:
It is really frustrating, none of the calls or options seem to make any difference to the outcome :@
EDIT 2: Could not get it to run. In the end, I hacked around with the QR code generator code until it gave me svg files, which work fine both in .docx and PDF (screen and printer).
Upvotes: 0
Views: 565
Reputation: 49405
Try to use the Document.ExportAsFixedFormat / ExportAsFixedFormat2 methods instead. They accept a bunch of parameters that allow setting up PDF documents properly.
Upvotes: 0