TUTORIALS
Basics: Using preferences
As easy as 1, 2, 3...
What are preferences?
Preferences are properties used by the API while creating new PDF documents or, at runtime, while modifying them. For
instance, it is possible via preferences to request that a document use
compression or encryption. It is also possible to set quality settings
for image compression.
Some preferences attributes can be specified at document
creation; others can be changed at runtime. The screenshot below shows
the preferences object with its setters and getters.

Initialization attributes
All setters with a name in the form of setDefaultXXX() are used to set initialization properties.
These properties are being used when a new document is created as per the example below:
// Create the preferences container:
Preferences preferences=new Preferences();
// Use the new PDF Format used by Acrobat 6 and above:
preferences.setDefaultPDFFormat( Preferences.PDFFORMAT_PURE );
// Set the default page size to Legal:
preferences.setDefaultPageFormat( JPdfPageFormat.LEGAL );
// Create a new document:
PdfDocument doc=new PdfDocument(preferences);
// Fill your document as required...:
// Save and close:
doc.saveAs("myFile.pdf");
doc.close();
Dynamic attributes
Any setter that is not an initialization attribute is a runtime attribute
and can be changed dynamically at runtime. For instance, you can
change image quality ratio or tell the engine to generate strings as
glyph for just a short period of time.
|