3.7. Profile
A profile is a set of global options that affect the resulting PDF document. These options are defined prior document creation and remain immutable during the document lifetime. If they are not specified explicitly then default values are used. The options are represented by the Profile class.
A single profile object can be used for multiple PDF documents. Each document holds its copy of the profile so changes to a profile object do not affect documents that have been already created with that profile.
There are several ways how to create a profile object. Here is an example of how to retrieve a default profile:
profile = jagpdf.create_profile()
This example will load a profile from a file:
profile = jagpdf.create_profile_from_file(filename)
And here we will load it from a string:
profile = jagpdf.create_profile_from_string('doc.compressed=0\n' 'info.author=Your Name')
Once we have created a profile we can modify it or save it to a file:
profile.set('doc.compressed', '0') profile.save_to_file(filename)
And finally, create a PDF document based on it:
doc = jagpdf.create_stream(my_stream, profile)
The format of a string or a file passed to create_profile_from_file() or create_profile_from_string() is one keyword=value option pair per line. Lines starting with #
are ignored.
Note that the value passed to set() is a string.
The following tables describe available options.
Name |
Default |
Values |
Description |
---|---|---|---|
doc.version |
|
|
Specifies PDF version 1. |
doc.encryption |
|
Specifies the security handler. Other options related to PDF encryption are described in section Encryption. |
|
doc.compressed |
|
|
Whether to compress the document. |
doc.topdown |
|
|
Moves the origin of the default user space coordinate system to the upper-left page corner and reverses the orientation of the y axis. |
Name |
Default |
Values |
Description |
---|---|---|---|
text.kerning |
|
|
Enables/disables pair kerning. |
Name |
Default |
Description |
---|---|---|
doc.page_layout |
|
Specifies the initial page layout:
|
doc.page_mode |
|
Specifies the appearance of the document when opened:
|
doc.initial_destination |
Specifies the initial document destination. |
|
doc.viewer_preferences |
Controls the viewer application. A semicolon separated list of the following options:
|
Name |
Default |
Values |
Description |
---|---|---|---|
fonts.default |
|
see font_load() |
A font used when the user does not specify any. |
fonts.embedded |
|
|
Whether to embed fonts. In some cases this flag is ignored by JagPDF (e.g. because of the font copyright or a PDF Reference recommendation). |
fonts.subset |
|
|
Whether to subset fonts. |
fonts.force_cid |
|
|
(Advanced). Whether to specify a font in PDF as a composite font even in case it would be possible to specify it as a simple font (see the PDF Reference, chapter Text | Simple Fonts/Composite Fonts. |
fonts.synthesized |
|
|
(Windows only). Whether the font matching mechanism is allowed to return a synthesized font. |
Name |
Default |
Values |
Description |
---|---|---|---|
images.default_dpi |
|
valid DPI value |
DPI used when not specified in an image, see dpi(). |
images.interpolated |
|
|
A default setting for image interpolation. It is used if no value is set by interpolate(). |
The following options allows specifying metadata for the document. A value has to be a UTF-8 encoded string. The default value is an empty string. For details see the PDF Reference, chapter Document Interchange | Metadata | Document Information Dictionary.
Name |
Description |
---|---|
info.title |
The document's title. |
info.author |
The name of the author of this document. |
info.subject |
The subject of the document |
info.keywords |
Keywords associated with the document. |
info.creator |
The name of the application that created the original document from which the PDF document was converted. |