Provides extra options to use when saving a document using the Adobe Portable Document Format (PDF).
The options set in the PdfDocumentOptions class will be used when the user saves a document using the DocumentFormat.Pdf format.
Before using the LEADTOOLS Document Writer to create PDF documents, you must unlock the RasterSupportType.DocumentWritersPdf key unless the document writers are being used from the LEADTOOLS OCR engine. For more information, refer to Unlocking Special LEAD Features.
To change the options used with the PDF format, perform the following steps:
The PdfDocumentOptions class contains the following features:
Feature | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Set the PDF document type to PDF or PDF/A. | Use the PdfDocumentOptions.DocumentType property to set the document type to either PDF or PDF/A. | ||||||||||||||||||||
Control the font embedding mode | Use the PdfDocumentOptions.FontEmbedMode property to control how the fonts are embedded in the resulting PDF document. Note that PdfDocumentOptions.FontEmbedMode is not used when saving PDF/A files; all fonts are always embedded in the file. | ||||||||||||||||||||
Add an image as an overlay on top of the PDF content. | Use the PdfDocumentOptions.ImageOverText property to add the original raster image as an overlay on top of the PDF content. The resulting document will look exactly like the original document. If this option is used, the overlay image must be set in the Image property of the DocumentPage object passed to the DocumentWriter.AddPage method. Use the ImageOverTextSize and ImageOverTextMode properties to control the quality of this image. | ||||||||||||||||||||
Create linearized PDF documents optimized for fast web viewing. | A linearized PDF file is a file that has been organized in a special way to enable efficient incremental access in a network environment. This allows the first page of the PDF file to be displayed in a user Web browser before the entire file is downloaded from the Web server. To enable the creation of linearized PDF documents, use the PdfDocumentOptions.Linearized property. PDF linearization is supported in both PDF and PDF/A formats. | ||||||||||||||||||||
Set the PDF document metadata | The resulting PDF can contain optional metadata associated with the document. This metadata can be used by external search and indexing engines to search and classify PDF documents. Use the PdfDocumentOptions.Title, PdfDocumentOptions.Subject, PdfDocumentOptions.Author and PdfDocumentOptions.Keywords to set the document metadata. | ||||||||||||||||||||
Set the PDF initial view properties |
The user can control the intial view properties of the generated PDF file as follows:
|
||||||||||||||||||||
Security, access rights and Encryption |
PDF documents can be protected (secured) using two methods:
When a PDF document is protected against editing (through the use of an owner password), an encryption level and owner access rights can be granted or denied in the resulting document. The following table lists the PDF access rights supported by the LEADTOOLS Document Writers:
|
||||||||||||||||||||
Add bookmarks in the final PDF document. | Use PdfAutoBookmark or PdfCustomBookmark to create either auto or custom (user) bookmarks in the final PDF documents. | ||||||||||||||||||||
Create an annotated PDF document by adding an annotation objects. | Annotated PDF can be created by passing valid LEADTOOLS annotation container for each page that needs to be annotated inside the PDF document. Set the AnnotationContainer property to a valid LEADTOOLS annotation container before calling the DocumentWriter.AddPagemethod. |
Property | Description |
---|---|
PageModeType | Page mode such page only, page with bookmarks, page with thumbnails, etc. |
PageLayoutType | Page layout such single page, one column, two pages, etc. |
PageFitType | Page fit such as none, fit width, height, etc. |
InitialPageNumber | Initial page number to go to. |
XCoordinate and YCoordinate | Position of the page to use go to initially. |
ZoomPercent | Zoom percentage to use when the document is opened. |
HideToolbar, HideMenubar and HideWindowUI | Show or hide various user interface elements. |
FitWindow and CenterWindow | How the document is viewed in the window. |
DisplayDocTitle | Display the document title in the viewer. |
Encryption | Owner Access Right |
---|---|
Low (PdfDocumentOptions.EncryptionMode set to PdfDocumentEncryptionMode.RC40Bit) | Printing (PdfDocumentOptions.PrintEnabled), Copying text (PdfDocumentOptions.CopyEnabled), Editing (PdfDocumentOptions.EditEnabled) and Annotations and comments (PdfDocumentOptions.AnnotationsEnabled). |
High (PdfDocumentOptions.EncryptionMode set to PdfDocumentEncryptionMode.RC128Bit) | Adds the following to owner access rights supported by low level encryption: High quality printing (PdfDocumentOptions.HighQualityPrintEnabled) and adding/removing pages PdfDocumentOptions.AssemblyEnabled. |
The following table shows the suggested PDF document options to use to achieve the smallest output PDF file size while maintaining an acceptable quality.
Property |
Value |
Remarks |
---|---|---|
JBIG2 format offers the best 1-bit image compression. |
||
JPX offers the best colored image compression (8 or 24 bits per pixel). Revert to flate compression if the image has bits per pixel value other than 8 or 24. |
||
Only used when using the image over text option (ImageOverText is true). The overlay image is sized by half and stretched over the page. This will save up to 75% of the size while maintaining the image quality. |
||
Only used when using the image over text option (ImageOverText is true). Any grayscale overlay image is converted to black and white while ignoring noise and shadows. |
||
50 or 100 |
Use 50 when using the image over text option (ImageOverText is true). Use 100 when image over text is not used (ImageOverText is false). |
|
Do not embed the fonts in the PDF file. Warning: The result PDF is not guaranteed to have the same fonts used to create it. Use this option only if font substituting is acceptable in your particular scenario. Otherwise, leave this to the default value of DocumentFontEmbedMode.Auto. |
The following code snippet shows how to set the PDF options to produce minimum file size with acceptable quality:
void SetPDFOptions(DocumentWriter documentWriter, bool useImageOverText)
{
// Get the current PDF options
PdfDocumentOptions pdfOptions = documentWriter.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions;
// Use JBIG2 for B/W images
pdfOptions.OneBitImageCompression = OneBitImageCompressionType.Jbig2;
// Use JPEG2000 or Flate for colored images
pdfOptions.ColoredImageCompression = ColoredImageCompressionType.FlateJpx;
// Embed fonts automatically
pdfOptions.FontEmbedMode = DocumentFontEmbedMode.Auto;
if (useImageOverText)
{
// Use image over text
pdfOptions.ImageOverText = true;
// Re-size the overlay image by 2
pdfOptions.ImageOverTextSize = DocumentImageOverTextSize.Half;
// Convert grayscale to black and white if possible
pdfOptions.ImageOverTextMode = DocumentImageOverTextMode.Relaxed;
// Use quality factor of 50
pdfOptions.QualityFactor = 50;
}
else
{
// Will not use image over text
pdfOptions.ImageOverText = false;
// Use quality factor of 100
pdfOptions.QualityFactor = 100;
}
// Set our options
documentWriter.SetOptions(DocumentFormat.Pdf, pdfOptions);
}
This example will create a new Adobe Portable Document Format document (PDF) file using the various supported options.
Products |
Support |
Feedback: PdfDocumentOptions Class - Leadtools.Forms.DocumentWriters |
Introduction |
Help Version 19.0.2017.3.21
|