Optimizing the page contents will remove unwanted commented
lines, white spaces, convert end-of-line characters to spaces and compress all uncompressed
PdfCompressionOptions options = new PdfCompressionOptions();
options.OptimizePageContents = true;
Reducing PDF file size by disabling incremental updates
The content of a PDF file can be updated incrementally
without rewriting the entire file. Changes are appended to the end of the file,
leaving its original contents intact. Disabling the incremental update will
rewrite the entire file, which results in a smaller PDF.
//Load the existing PDF document.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(@"input.pdf");
//Restructure the complete document.
loadedDocument.FileStructure.IncrementalUpdate = false;
Reducing PDF file size by removing form fields
Removing or flattening form fields can help reduce your file
size. When form fields and their values are not necessary, they can be removed.
When they are necessary but require no further editing, they can be flattened. Both
of these actions will result in a reduced file size.
public void RemoveFormFields(PdfLoadedDocument ldoc, bool flatten)
ldoc.Form.Flatten = true;
int count = ldoc.Form.Fields.Count;
for (int i = count - 1; i >= 0; i--)
Reducing PDF file size by removing annotations
Removing or flattening annotations can help reduce your file
size. Annotations and their contents can be removed when they are not needed. When
they are necessary but do not require additional editing, they can be flattened.
Both of these options will result in a reduced file size.
public void RemoveAnnotations(PdfLoadedDocument ldoc, bool flatten)
foreach(PdfPageBase page in ldoc.Pages)
page.Annotations.Flatten = true;
int count = page.Annotations.Count;
for (int i = count - 1;i >= 0; i--)
PDF compression options
A sample demonstrating the available compression options in
Essential PDF can be downloaded here: OptimizePDFSample.zip.
As you can see, Essential PDF
provides a variety of optimizing mechanisms for compressing a PDF document. Use
them effectively to generate compressed documents for increased efficiency and
productivity in a document management system. Take a moment to peruse the documentation,
where you’ll find other options and features, all with accompanying code
If you are new to our PDF library, it is highly recommended
that you follow our Getting
If you’re already a Syncfusion user, you can download the
product setup here.
If you’re not yet a Syncfusion user, you can download a free, 30-day trial here.
If you have any questions or require clarifications about these
features, please let us know in the comments below. You can also contact us
through our support forum or Direct-Trac. We are
happy to assist you!