PdfCompressionOptions Class
Represents the compression options of the loaded document.
Inheritance
System.Object
PdfCompressionOptions
Namespace: Syncfusion.Pdf
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfCompressionOptions : Object
Remarks
To know more about refer this link .
Examples
//Load an existing document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Initialize new instance of PdfCompressionOptions class.
PdfCompressionOptions options = new PdfCompressionOptions();
//set the compress images based on the image quality.
options.CompressImages = true;
//set the image quality.
options.ImageQuality = 50;
//set the optimize font.
options.OptimizeFont = true;
//set the optimize page contents.
options.OptimizePageContents = true;
//set the remove metadata informations.
options.RemoveMetadata = true;
ldoc.CompressionOptions = options;
//Save and close the document.
ldoc.Save("Output.pdf");
ldoc.Close(true);
'Load an existing document.
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Initialize new instance of PdfCompressionOptions class.
Dim options As PdfCompressionOptions = New PdfCompressionOptions()
'set the compress images based on the image quality.
options.CompressImages = True
'set the image quality.
options.ImageQuality = 50
'set the optimize font.
options.OptimizeFont = True
'set the optimize page contents.
options.OptimizePageContents = True
'set the remove metadata informations.
options.RemoveMetadata = True
ldoc.CompressionOptions = options
'Save and Close the document.
ldoc.Save("Output.pdf")
ldoc.Close(True)
Constructors
PdfCompressionOptions()
Declaration
public PdfCompressionOptions()
Properties
CompressImages
Gets or sets whether to compress images based on the image quality.
Declaration
public bool CompressImages { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
Examples
//Load an existing document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Initialize new instance of PdfCompressionOptions class.
PdfCompressionOptions options = new PdfCompressionOptions();
//set the compress images based on the image quality.
options.CompressImages = true;
ldoc.CompressionOptions = options;
//Save and close the document.
ldoc.Save("Output.pdf");
ldoc.Close(true);
'Load an existing document.
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Initialize new instance of PdfCompressionOptions class.
Dim options As PdfCompressionOptions = New PdfCompressionOptions()
'set the compress images based on the image quality.
options.CompressImages = True
ldoc.CompressionOptions = options
'Save and Close the document.
ldoc.Save("Output.pdf")
ldoc.Close(True)
DownsampleAlgorithm
Declaration
public DownsamplingAlgorithm DownsampleAlgorithm { get; set; }
Property Value
| Type |
|---|
| DownsamplingAlgorithm |
DownsampleImages
Declaration
public bool DownsampleImages { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
EnableJpxDecode
Gets or sets whether images are encoded using JPEG 2000 (/JPXDecode). Default is false.
Declaration
public bool EnableJpxDecode { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
Examples
//Load an existing document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Initialize new instance of PdfCompressionOptions class.
PdfCompressionOptions options = new PdfCompressionOptions();
options.EnableJpxDecode = true;
//set the optimize font.
options.OptimizeFont = true;
ldoc.CompressionOptions = options;
//Save and close the document.
ldoc.Save("Output.pdf");
ldoc.Close(true);
'Load an existing document.
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Initialize new instance of PdfCompressionOptions class.
Dim options As PdfCompressionOptions = New PdfCompressionOptions()
options.EnableJpxDecode = True
'set the optimize font.
options.OptimizeFont = True
ldoc.CompressionOptions = options
'Save and Close the document.
ldoc.Save("Output.pdf")
ldoc.Close(True)
ImageQuality
Declaration
public int ImageQuality { get; set; }
Property Value
| Type |
|---|
| System.Int32 |
Examples
//Load an existing document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Initialize new instance of PdfCompressionOptions class.
PdfCompressionOptions options = new PdfCompressionOptions();
//set the compress images based on the image quality.
options.CompressImages = true;
//set the image quality.
options.ImageQuality = 50;
ldoc.CompressionOptions = options;
//Save and close the document.
ldoc.Save("Output.pdf");
ldoc.Close(true);
'Load an existing document.
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Initialize new instance of PdfCompressionOptions class.
Dim options As PdfCompressionOptions = New PdfCompressionOptions()
'set the compress images based on the image quality.
options.CompressImages = True
'set the image quality.
options.ImageQuality = 50
ldoc.CompressionOptions = options
'Save and Close the document.
ldoc.Save("Output.pdf")
ldoc.Close(True)
OptimizeFont
Gets or sets whether to optimize font data.
Declaration
public bool OptimizeFont { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
Examples
//Load an existing document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Initialize new instance of PdfCompressionOptions class.
PdfCompressionOptions options = new PdfCompressionOptions();
//set the optimize font.
options.OptimizeFont = true;
ldoc.CompressionOptions = options;
//Save and close the document.
ldoc.Save("Output.pdf");
ldoc.Close(true);
'Load an existing document.
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Initialize new instance of PdfCompressionOptions class.
Dim options As PdfCompressionOptions = New PdfCompressionOptions()
'set the optimize font.
options.OptimizeFont = True
ldoc.CompressionOptions = options
'Save and Close the document.
ldoc.Save("Output.pdf")
ldoc.Close(True)
OptimizePageContents
Gets or sets whether to optimize page contents.
Declaration
public bool OptimizePageContents { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
Examples
//Load an existing document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Initialize new instance of PdfCompressionOptions class.
PdfCompressionOptions options = new PdfCompressionOptions();
//set the optimize page contents.
options.OptimizePageContents = true;
ldoc.CompressionOptions = options;
//Save and close the document.
ldoc.Save("Output.pdf");
ldoc.Close(true);
'Load an existing document.
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Initialize new instance of PdfCompressionOptions class.
Dim options As PdfCompressionOptions = New PdfCompressionOptions()
'set the optimize page contents.
options.OptimizePageContents = True
ldoc.CompressionOptions = options
'Save and Close the document.
ldoc.Save("Output.pdf")
ldoc.Close(True)
RemoveMetadata
Gets or sets whether to remove metadata information from the PDF document.
Declaration
public bool RemoveMetadata { get; set; }
Property Value
| Type |
|---|
| System.Boolean |
Examples
//Load an existing document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Initialize new instance of PdfCompressionOptions class.
PdfCompressionOptions options = new PdfCompressionOptions();
//Remove metadata information from the document.
options.RemoveMetadata = true;
ldoc.CompressionOptions = options;
//Save and close the document.
ldoc.Save("Output.pdf");
ldoc.Close(true);
'Load an existing document.
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Initialize new instance of PdfCompressionOptions class.
Dim options As PdfCompressionOptions = New PdfCompressionOptions()
'Remove metadata information from the document.
options.RemoveMetadata = True
ldoc.CompressionOptions = options
'Save and Close the document.
ldoc.Save("Output.pdf")
ldoc.Close(True)
TargetDpi
Gets or sets the target DPI for downsampled images.
Declaration
public int TargetDpi { get; set; }
Property Value
| Type |
|---|
| System.Int32 |
Remarks
Default value is 150. Valid range is 36 to 2400.
Examples
//Load an existing document.
PdfLoadedDocument ldoc = new PdfLoadedDocument("input.pdf");
//Initialize new instance of PdfCompressionOptions class.
PdfCompressionOptions options = new PdfCompressionOptions();
options.TargetDpi = 150;
//set the optimize font.
options.OptimizeFont = true;
ldoc.CompressionOptions = options;
//Save and close the document.
ldoc.Save("Output.pdf");
ldoc.Close(true);
'Load an existing document.
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument("input.pdf")
'Initialize new instance of PdfCompressionOptions class.
Dim options As PdfCompressionOptions = New PdfCompressionOptions()
options.TargetDpi = 150
'set the optimize font.
options.OptimizeFont = True
ldoc.CompressionOptions = options
'Save and Close the document.
ldoc.Save("Output.pdf")
ldoc.Close(True)