Saving PDF Document Files

To save to a PDF document file; in the IEpnSaveOptions object, set the Format property to FILE_PDF and set the SaveOptions DocumentType to DLG_FT_SAVE_TYPE_DOCUMENT.

Set the DocumentOptions.WithoutShapes property to VARIANT_TRUE in order to not save the shapes, or set it to VARIANT_FALSE to save the shapes.

Set the DocumentOptions.MultiPageFile property to VARIANT_TRUE to save all pages in one PDF file, or set it to VARIANT_FALSE to save every page in a separate file.

Set the DocumentOptions.PDFOptions property with valid data.

The PDFOptions property contains information about how PDF document files will be saved. This information can be broken down into the following groups of information:

image\sqrblit.gif PDF Version group. Access the PDF versioning by using the Version, LevelMajor, and LevelMinor properties.

image\sqrblit.gif Document Information group. Access the document information by using the Title, Subject, Author, and Keywords properties.

image\sqrblit.gif Font Embedding group. Access the font embedding by using the ForceEmbed, AutoEmbed, EmbedAll, EmbeddedFontsCount, Checked, Embedable, and Fonts properties.

image\sqrblit.gif Security group. Access the security by using the Protect, Method, UserPassword, OwnerPassword, Copy, Edit, Comments, Assembly, Print, and FaithfulPrint properties.

image\sqrblit.gif Open Options group. Access the opening PDF document options by using the PageMode, PageLayout, Magnification, CustomMag, StartPage, CountPages, Linearized, ShowToolbar, ShowMenu, and ShowWindowControl properties.

image\sqrblit.gif Compression group. Access the PDF compression by using the CompressedDocuments, CompressedImages, and Factor properties.

image\sqrblit.gif URL Detection group. Access the URLs by using the EnableURLDetect, DashedHyperlink, ForceHyperlinkColor, and Hyperlink properties.

image\sqrblit.gif Bookmarks group. Access the bookmarks by using the BookmarkFontsCount, Bold, Italic, Size, Fonts, Levels, and LevelsCount properties.

PDF Version group

This group contains the version used to create the document.

LEADTOOLS® ePrint supports PDF versions 1.2, 1.3, 1.4, and 1.5. PDF Version 1.3, which features Unicode support, is used for Adobe Acrobat 4. PDF Version 1.4, which features enhanced PDF security, is used for Adobe Acrobat 5 or later.

To allow the maximum number of readers to open documents, unless Unicode or enhanced PDF security support is needed, when creating documents ePrint uses PDF version 1.2. Otherwise, ePrint uses the lowest version necessary to support the required features (Unicode and/or enhanced PDF security). You can specify which PDF version to use, but if the version number you specify is lower than necessary to support the features you have requested, ePrint will override your version specification.

Generally, it is better to produce documents at the lowest version possible, because this enables a larger group of readers to open the resulting document. For instance, if the PDF version is specified as 1.4, Adobe Acrobat 3 and Adobe Acrobat 4 will not be able to open the document. On the other hand, older versions of the PDF format do not support all available features. For example, PDF version 1.2 format does not support either Unicode or enhanced PDF security, so if those features are desired, a newer version of the PDF format is required.

Document Information Group

This group contains general information about the PDF document, including the title, subject, author and keywords of the document. This information can be used to identify and organize the created documents.

Font Embedding Group

This group contains font embedding information about the PDF document, which enables PDF documents to be used anywhere, without consideration of which fonts have been installed on the computer used to read the document.

Document portability means that a document may be read on many machines and operating systems without losing either content or style. For instance, if a PDF document is created using a custom font on one computer, but then read on a computer that does not have that font installed, Adobe Acrobat Reader will substitute a different font. This will change the appearance of the document. To prevent this from happening, the PDF format supports font embedding. By storing font data inside the file, the document becomes "portable," and will appear the same on any computer. However, embedding fonts always makes documents larger, since the font data must be stored as well as the file data.

LEADTOOLS ePrint supports font embedding and has a number of options to customize this capability in order to balance the portability of a document with storage requirements. The options for embedding fonts are: embedding all fonts, automatic font embedding, or custom font embedding.

image\sqrblit.gif Embedding all fonts allows you to embed all fonts, including Licensed Fonts. For important information about Licensed Fonts, please refer to Licensed Fonts.

image\sqrblit.gif Automatic font embedding allows ePrint to choose which fonts to embed. In automatic font embedding, fonts that are not commonly available are embedded (with the exception of Licensed Fonts) and common fonts are not embedded. For example, Times New Roman is likely to be installed on any available machine, so it is not necessary to embed it. However, Book Antiqua is not likely to be installed on any available machine, so it is better to embed it. For users who have obtained the necessary font licenses for Licensed Fonts, ePrint provides an override to permit the embedding of these fonts as well.

image\sqrblit.gif Custom font embedding allows you to specify the fonts to be embedded. Please note that a Licensed Font and may NOT be embedded unless the user has a license from the owner of the Licensed Font. For important information on the Licensed Fonts, please refer to Licensed Fonts.

Security Group

This group contains information for creating protected PDF documents and using RC4 40-bit encryption or RC4 128-bit encryption to prevent un-authorized access to the resulting documents.

To protect a document, perform the following steps:

1.

To protect the document, set the Protect property to VARIANT_TRUE.

2.

Set an encryption method in the Method property.

3.

Set the password you want the users to use in order to open the document in the UserPassword property.

4.

Set the password you want the owners to use in the OwnerPassword property. Owners have the ability to perform all of the permission options.

5.

Select the actions you wish to allow the Users to perform by setting the other property of this group. These actions include:

 

Copying text and images from the document.

 

Document editing.

 

Adding comments.

 

Adding or removing pages from the document (RC4 128-bit only).

 

Printing.

 

Printing in high quality (RC4 128-bit only)

6.

Once all the security options and any other PDF options you want have been set, set these options with the rest of the printer saving options using the SetPrinterSaveOptions method.

Please note the following about security options:

 

If you protect a document, you have to specify at least one password.

 

If you specify a user password, that password must be entered before you can open the document.

 

In addition to the ability to open a document, you can also grant authority to perform certain actions by setting the appropriate members of this group.

 

The permissions granted control the actions that are allowed to users of the document.

 

If both Owners and Users groups have been created, the difference between an owner and a user is that an owner can change the actions permitted by users and owners.

 

If you create a User password but no Owner password, and you set permissions, the user who uses the password has the authority to change the actions permitted by users.

 

The Permissions granted can be reviewed in the created document when it is open, by (in Adobe Acrobat) selecting File -> Document Info -> Security. The User password in ePrint corresponds to the Open Password in Adobe Acrobat. The Owner password in ePrint corresponds to the Security Password in Adobe Acrobat.

 

To change the Permissions in the created document, in Adobe Acrobat 5.0 or later use File -> Document security -> Change settings.

Open Options Group

This group contains information used to determine how the PDF document will look when the user first opens the document. The most commonly used software for opening PDF files is Adobe Acrobat Reader but of course any other software which follows Adobe’s PDF specifications, may use these options as well. The options available in this group pertain to page settings, the way the document is initially viewed, and the user interface.

Compression Group

This group contains information about compression options. The PDF format was designed to be compact in order to use it anywhere easily.

Compressing the data streams and text can significantly reduce the file size. To compress the data streams and text, set the CompressedDocuments property to VARIANT_FALSE.

In addition to compressing the data streams and text, it is also possible to compress images. You can either select not to compress images, or select to use JPG compression. To use images without compressing them, set the CompressedImages property to VARIANT_TRUE. Using this option maintains the best image quality. When using JPG compression it is possible to indicate whether you prefer images that are higher in quality, or images that are more compressed. The higher the image quality, the less the compression and thus the bigger the resulting file. The available range for image quality is from 2 through 255, where 2 is the best quality (largest file size) and 255 is the lowest quality (greatest compression/smallest file size).

To use image compression, set CompressedImages to VARIANT_TRUE, and then set the Factor property to a number between 2 and 255.

URL Detection group

This group contains information about detecting URLs.

URL detection parses the document and converts the URLs such as www.leadtools.com into working links, when the EnableURLDetect property is set to VARIANT_TRUE. The appearance of the detected URLs can be customized by setting: the DashedHyperlink property, the ForceHyperlinkColor property, and the Hyperlink property, if needed.

Bookmarks Group

This group contains information about adding bookmarks.

Bookmarks may be added to mark parts of a document for quick access. This can be done with documents that have been consistently formatted in outline or chapter form with sections and subsections, where each level uses unique font formatting. An example for a Microsoft Word document is shown in the following figure.

image\ePrintOptionsPDFwordDocOutline.gif

In this example the formatting for the document is as follows:

Chapter: Times New Roman 17pt Bold

Section: Times New Roman 13pt

Sub Section: Times New Roman 11pt Italic

This group contains information on the number of levels and the arrays containing information about each level, including whether the font is bold or italic, the size and the name of the font.

To set the bookmarks for a document, first set the number of levels of bookmarks that you want in the LevelsCount property. In our example there are three levels to be turned into bookmarks, so set Levels to 3. Then, fill the Fonts, Bold, Italic, and Size properties with all fonts in the document as the following:

Fonts(0) = "Times New Roman"
Fonts(1) = "Times New Roman"
Fonts(2) = "Times New Roman"

Bold(0) = VARIANT_TRUE
Bold(1) = VARIANT_FALSE
Bold(2) = VARIANT_FALSE

Bold(0) = VARIANT_FALSE
Bold(1) = VARIANT_FALSE
Bold(2) = VARIANT_TRUE

Size(0) = 17
Size(0) = 13
Size(0) = 11

Now, Fill the Levels property with the indices of the Fonts (which is the same as the indices of Bold, Italic, and Size) that we want to use as bookmarks. In our example, we will use all fonts.

Levels(0) = 0
Levels(1) = 1
Levels(2) = 2

Where 0 is the index of the Fonts array property that is related to the Times New Roman 17pt Bold, 1 is the index of the Fonts array property that is related to the Times New Roman 13pt, and 2 is the index of the Fonts array property that is related to the Times New Roman 11pt Italic.

Once all the bookmarks options have been set and any other PDF and save options, call SetPrinterSaveOptions to actually set the new values.

Note:

Levels should not conflict, that is, the user cannot select "Times New Roman" 17pt for both level1 and level2. Each level setting should be unique.

Note:

The maximum number of bookmarks cannot be greater than 10 levels. Also, the maximum number of bookmarks is limited by the number of unique fonts available in the document being printed. In the example used, it is limited to 3.