JagPDF
Prev Up Home Next

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

5

2, 3, 4, 5, 6

Specifies PDF version 1.x. Generally, JagPDF rejects operations that are not supported by a particular version. However, in case of external resources, JagPDF performs an automatic adjustment when needed. For instance it might downsample image data or convert a font.

doc.encryption

standard

Specifies the security handler. Other options related to PDF encryption are described in section Encryption.

doc.compressed

1

0, 1

Whether to compress the document.

doc.topdown

0

0, 1

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

0

0, 1

Enables/disables pair kerning.

Name

Default

Description

doc.page_layout

SinglePage

Specifies the initial page layout:

  • SinglePage - One page is displayed at a time.
  • OneColumn - The pages are displayed in one column (continuous).
  • TwoColumnLeft - The pages are displayed in two columns, odd-numbered pages on the left (continuous facing).
  • TwoColumnRight - The pages are displayed in two columns, odd-numbered pages on the right (continuous facing).

doc.page_mode

UseNone

Specifies the appearance of the document when opened:

  • UseNone - Neither document outline nor thumbnail images visible.
  • UseOutlines - Document outline visible.
  • UseThumbs - Thumbnail images visible.
  • FullScreen - Full-screen mode.

doc.initial_destination

Specifies the initial document destination.

doc.viewer_preferences

Controls the viewer application. A semicolon separated list of the following options:

  • HideToolbar - Hide tool bars when the document is active.
  • HideMenubar - Hide menu bar when the document is active.
  • HideWindowUI - Hide user interface elements.
  • FitWindow - Resize document's window to fit the size of the first displayed page.
  • CenterWindow - Position the document's window in the center of the screen.
  • DisplayDocTitle - Display the document title in the document window's title bar (see Info, option info.title). If not specified, then the name of the PDF file is displayed.

Name

Default

Values

Description

fonts.default

standard; name=Helvetica; size=12

see font_load()

A font used when the user does not specify any.

fonts.embedded

1

0, 1

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

1

0, 1

Whether to subset fonts.

fonts.force_cid

1

0, 1

(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

1

0, 1

(Windows only). Whether the font matching mechanism is allowed to return a synthesized font.

Name

Default

Values

Description

images.default_dpi

72

valid DPI value

DPI used when not specified in an image, see dpi().

images.interpolated

0

0, 1

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.

Prev Up Home Next