AlJohri / docx2pdf

MIT License
497 stars 94 forks source link

Controlling the quality of PDF #101

Open vpodpecan opened 3 months ago

vpodpecan commented 3 months ago

It would be better to use the Document.ExportAsFixedFormat function instead of Document.SaveAs. ExportAsFixedFormat support the OptimizeFor parameter which can be set to screen or print optimization. OptimizeFor for can be either wdExportOptimizeForOnScreen (1) or wdExportOptimizeForPrint (0).

All that is needed is to replace

doc.SaveAs(str(pdf_filepath), FileFormat=wdFormatPDF)

with

doc.ExportAsFixedFormat(str(pdf_filepath), wdFormatPDF, False, 0)

to ensure print quality by default.