Class PdfCompressionExtension
Inheritance
System.Object
PdfCompressionExtension
Namespace: Syncfusion.Pdf
Assembly: Syncfusion.Pdf.Imaging.NET.dll
Syntax
public static class PdfCompressionExtension : Object
Methods
Compress(PdfLoadedDocument, PdfCompressionOptions)
Compress PDF documents with compression options applied.
Declaration
public static void Compress(this PdfLoadedDocument ldoc, PdfCompressionOptions options)
Parameters
Type | Name | Description |
---|---|---|
PdfLoadedDocument | ldoc | |
PdfCompressionOptions | options |
Examples
//Load an existing PDF.
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(fileName);
//Create new compression options instance.
PdfCompressionOptions options = new PdfCompressionOptions();
//Set image compression.
options.CompressImages = true;
//Set image quality.
options.ImageQuality = 50;
//Optimize font.
options.OptimizeFont = true;
//Optimize page contents.
options.OptimizePageContents = true;
//Remove metadata information.
options.RemoveMetadata = true;
//Set compression options.
loadedDocument.Compress(options);
//Save the document
MemoryStream stream = new MemoryStream();
loadedDocument.Save(stream);
//close the document
loadedDocument.Close(true);
'Load an existing PDF
Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument(fileName)
'Create new compression options instance.
Dim options As PdfCompressionOptions = New PdfCompressionOptions()
'Set image compression.
options.CompressImages = True
'Set image quality.
options.ImageQuality = 50
'Optimize font.
options.OptimizeFont = True
'Optimize page contents.
options.OptimizePageContents = True
'Remove metadata information.
options.RemoveMetadata = True
'Set compression options.
loadedDocument.Compress(options)
Dim stream As New MemoryStream()
'Save the document
loadedDocument.Save(stream)
'close the document
loadedDocument.Close(True)