Category / Section
Tips to reduce the PDF file size while converting Word document to PDF
1 min read
Syncfusion® .NET Word Library (DocIO) allows you to convert Word documents to PDF. Using this library, you can reduce the output PDF file size during the Word to PDF conversion.
Optimization Tips
Follow these tips to efficiently reduce the PDF file size.
Adjust Image Quality and Resolution
By adjusting the image quality and image resolution using ImageQuality and ImageResolution respectively, the size of the output PDF file is reduced.
// Sets the image quality to reduce the PDF file size
converter.Settings.ImageQuality = 50;
// Sets the image resolution
converter.Settings.ImageResolution = 640;
Set PDF Compression Level
The PDF document can also be compressed using which helps to reduce the file size.
// Sets PDF compression level
pdfDocument.Compression = PdfCompressionLevel.Best;
Code Example
The following code example illustrates about how to implement the above mentioned tips.
C#
WordDocument wordDocument = new WordDocument(@"Template.docx", FormatType.Docx);
DocToPDFConverter converter = new DocToPDFConverter();
// Adjust image quality and resolution
converter.Settings.ImageQuality = 50;
converter.Settings.ImageResolution = 640;
// Convert Word document to PDF
PdfDocument pdfDocument = converter.ConvertToPDF(wordDocument);
// Set PDF compression level
pdfDocument.Compression = PdfCompressionLevel.Best;
// Save the PDF document
pdfDocument.Save("Output.pdf");
// Close document instances
wordDocument.Close();
pdfDocument.Close();
You can download a complete working sample from GitHub.