If one Word document has several images, the size of PDF document will be very large which converting from this Word document. Sometimes, uses will be troubled because of the large size PDF document. In this post, I will introduce a method to make document size smaller through changing image quality when converting Word to PDF by using C#/VB.NET.
At the beginning, we need to learn something about image quality. Image quality is a characteristic of an image that measures perceived image degradation. That means image will be compared to an ideal or perfect status.
In my example, I use a component, Spire.Doc in this method. So, I add its dll file as reference in my project.
Detailed Steps Shown as Following:
Step 1, Load Document
Declare a document and load document which I want to set image quality and convert to PDF by using document.LoadFromFile() method.
Document document = new Document();
Dim document As New Document()
Step 2, Set Image Quality
Assign value for document.JPEGQuality. The default quality is percentage 80. If you want to have smaller size, you can set the percentage to be lower than 80.
document.JPEGQuality = 50
Step 3, Convert Word to PDF
Save document as PDF by using document.SaveToFile() method and then launch this converted file.
Note: if original document has several images, this sentence: document.JPEGQuality= 50; is used to set all image quality.
Result Shown as Following:
Comparing with the original Word document, PDF which is converted with MS Word and PDF document which converted with setting quality, we can find ImageQuality.PDF has smaller size.
Click Here to LEARN MORE about Spire.Doc
Click Here to DOWNLOAD Spire.Doc
Spire.Office also can be used to realize this function.