Loading a Password Protected PDF
To load a password protected PDF refer to Use PDF Security.
Saving as a PDF
ImageGear PDF component provides the ImGearPDFSaveOptions
class that defines options for saving raster pages and documents to specific PDF formats like PDF/A. This class is derived from the regular ImGearSaveOptions
class and could be used with the regular ImGearFileFormats.SavePage
and ImGearFileFormats.SaveDocument
methods that take ImGearSaveOptions
parameter.
When using SaveDocument
with ImGearPDFDocument
or ImGearDocument
with vector data as input, ImageGear ignores specific compression settings. The following sample code demonstrates how to use the ImGearPDFSaveOptions
class for saving a raster document to PDF:
C#
ImGearDocument doc = null;
// Load raster document.
using (FileStream fileStream = new FileStream(infile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
doc = ImGearFileFormats.LoadDocument(fileStream, 0, -1);
}
// Specify PDF options.
ImGearPDFSaveOptions pdfOptions = new ImGearPDFSaveOptions();
// Save to PDF file.
using (FileStream fileStream = new FileStream(outfile, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
ImGearFileFormats.SaveDocument(doc, fileStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.PDF_DEFLATE, pdfOptions);
}
Reducing File Size when Saving a PDF
In order to reduce the size of a PDF document, use the ImageGear PDF Filter Control Parameters "SaveFlags". For this purpose, combine the following ImGearPDFSaveFlags
:
- ImGearPDFSaveFlags.ADD_FLATE
- ImGearPDFSaveFlags.REPLACE_LZW
- ImGearPDFSaveFlags.REMOVE_ASCII_FILTERS
- ImGearPDFSaveFlags.COMPRESSED
- ImGearPDFSaveFlags.OPTIMIZE_XOBJECTS
- ImGearPDFSaveFlags.OPTIMIZE_CONTENT_STREAMS
- ImGearPDFSaveFlags.OPTIMIZE_FONTS
C#
ImGearPDFSaveFlags saveFlags = ImGearPDFSaveFlags.ADD_FLATE | ImGearPDFSaveFlags.REPLACE_LZW | ImGearPDFSaveFlags.REMOVE_ASCII_FILTERS | ImGearPDFSaveFlags.COMPRESSED | ImGearPDFSaveFlags.OPTIMIZE_XOBJECTS | ImGearPDFSaveFlags.OPTIMIZE_CONTENT_STREAMS | ImGearPDFSaveFlags.OPTIMIZE_FONTS;
ImGearControlParameter parameter = ImGearFileFormats.Filters.Get(ImGearFormats.PDF).Parameters.GetByName("SaveFlags");
parameter.Value = saveFlags;
When the Save Compressed PDF functionality provided in ImageGear is used, you do not need to explicitly set these Save Flags. In this case, the saving operation is executed with these flags activated in order to obtain higher compression rates.
Saving a Password Protected PDF
To save a password protected PDF refer to Use PDF Security.
Saving a PDF as Other Supported Formats
See Convert... for more information.