Poppler.Document¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
The author of the document |
||
d/r/w |
The date and time the document was created |
||
r/w |
The date and time the document was created |
||
r/w |
The software that created the document |
||
r |
The PDF version of the document |
||
r |
The PDF major version number of the document |
||
r |
The PDF minor version number of the document |
||
r/w |
Keywords |
||
r |
Is the document optimized for web viewing? |
||
r |
Embedded XML metadata |
||
d/r/w |
The date and time the document was modified |
||
r/w |
The date and time the document was modified |
||
r |
Initial Page Layout |
||
r |
Page Mode |
||
r |
Permissions |
||
r |
Duplex Viewer Preference |
||
r |
Number of Copies Viewer Preference |
||
r |
Print Scaling Viewer Preference |
||
r/w |
The software that converted the document |
||
r/w |
Subjects the document touches |
||
r |
The PDF subtype of the document |
||
r |
The conformance level of PDF subtype |
||
r |
The part of PDF conformance |
||
r |
The PDF subtype of the document |
||
r/w |
The title of the document |
||
r |
Viewer Preferences |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Poppler.Document(**kwargs)¶
- Bases:
- Abstract:
No
- classmethod new_from_bytes(bytes, password)¶
- Parameters:
bytes (
GLib.Bytes
) – aGLib.Bytes
password (
str
orNone
) – password to unlock the file with, orNone
- Raises:
- Returns:
a newly created
Poppler.Document
, orNone
- Return type:
Creates a new
Poppler.Document
from bytes. The returned document will hold a reference to bytes.On error,
None
is returned, with error set. Possible errors include those in the #POPPLER_ERROR and #G_FILE_ERROR domains.New in version 0.82.
- classmethod new_from_data(data, password)¶
- Parameters:
- Raises:
- Returns:
A newly created
Poppler.Document
, orNone
- Return type:
Creates a new
Poppler.Document
. IfNone
is returned, then error will be set. Possible errors include those in the #POPPLER_ERROR and #G_FILE_ERROR domains.Note that data is not copied nor is a new reference to it created. It must remain valid and cannot be destroyed as long as the returned document exists.
Deprecated since version 0.82: This requires directly managing length and data. Use
Poppler.Document.new_from_bytes
() instead.
- classmethod new_from_fd(fd, password)¶
- Parameters:
- Raises:
- Returns:
a new
Poppler.Document
, orNone
- Return type:
Creates a new
Poppler.Document
reading the PDF contents from the file descriptor fd. fd must refer to a regular file, or STDIN, and be open for reading. Possible errors include those in the #POPPLER_ERROR and #G_FILE_ERROR domains. Note that this function takes ownership of fd; you must not operate on it again, nor close it.New in version 21.12.0.
- classmethod new_from_file(uri, password)¶
- Parameters:
- Raises:
- Returns:
A newly created
Poppler.Document
, orNone
- Return type:
Creates a new
Poppler.Document
. IfNone
is returned, then error will be set. Possible errors include those in the #POPPLER_ERROR and #G_FILE_ERROR domains.
- classmethod new_from_gfile(file, password, cancellable)¶
- Parameters:
password (
str
orNone
) – password to unlock the file with, orNone
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
a new
Poppler.Document
, orNone
- Return type:
Creates a new
Poppler.Document
reading the PDF contents from file. Possible errors include those in the #POPPLER_ERROR and #G_FILE_ERROR domains.New in version 0.22.
- classmethod new_from_stream(stream, length, password, cancellable)¶
- Parameters:
stream (
Gio.InputStream
) – aGio.InputStream
to read fromlength (
int
) – the stream length, or -1 if not knownpassword (
str
orNone
) – password to unlock the file with, orNone
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
a new
Poppler.Document
, orNone
- Return type:
Creates a new
Poppler.Document
reading the PDF contents from stream. Note that the givenGio.InputStream
must be seekable orGio.IOErrorEnum.NOT_SUPPORTED
will be returned. Possible errors include those in the #POPPLER_ERROR, #G_FILE_ERROR and #G_IO_ERROR domains.New in version 0.22.
- create_dests_tree()¶
-
Creates a balanced binary tree of all named destinations in self
The tree key is strings in the form returned by
Poppler.named_dest_to_bytestring
() which constains a destination name. The tree value is thePoppler.Dest
which contains a named destination. The return value must be freed withGLib.Tree.destroy
().New in version 0.78.
- find_dest(link_name)¶
- Parameters:
link_name (
str
) – a named destination- Returns:
a new
Poppler.Dest
destination, orNone
if link_name is not a destination.- Return type:
Creates a
Poppler.Dest
for the named destination link_name in self.Note that named destinations are bytestrings, not string. That means that unless link_name was returned by a poppler function (e.g. is Poppler.Dest.named_dest), it needs to be converted to string using
Poppler.named_dest_from_bytestring
() before being passed to this function.The returned value must be freed with
Poppler.Dest.free
().
- get_attachments()¶
- Returns:
a list of available attachments.
- Return type:
Returns a
GLib.List
containingPoppler.Attachment
s. These attachments are unowned, and must be unreffed, and the list must be freed with g_list_free().
- get_author()¶
-
Returns the author of the document
New in version 0.16.
- get_creation_date()¶
- Returns:
the date the document was created, or -1
- Return type:
Returns the date the document was created as seconds since the Epoch
New in version 0.16.
- get_creation_date_time()¶
- Returns:
the date the document was created, or
None
- Return type:
Returns the date the document was created as a
GLib.DateTime
New in version 20.09.0.
- get_creator()¶
-
Returns the creator of the document. If the document was converted from another format, the creator is the name of the product that created the original document from which it was converted.
New in version 0.16.
- get_form_field(id)¶
- Parameters:
id (
int
) – an id of aPoppler.FormField
- Returns:
a new
Poppler.FormField
orNone
if not found- Return type:
Returns the
Poppler.FormField
for the given id. It must be freed withGObject.Object.unref
()
- get_id()¶
- Returns:
- Return type:
Returns the PDF file identifier represented as two byte string arrays of size 32. permanent_id is the permanent identifier that is built based on the file contents at the time it was originally created, so that this identifer never changes. update_id is the update identifier that is built based on the file contents at the time it was last updated.
Note that returned strings are not null-terminated, they have a fixed size of 32 bytes.
New in version 0.16.
- get_keywords()¶
-
Returns the keywords associated to the document
New in version 0.16.
- get_metadata()¶
-
Returns the XML metadata string of the document
New in version 0.16.
- get_modification_date()¶
- Returns:
the date the document was most recently modified, or -1
- Return type:
Returns the date the document was most recently modified as seconds since the Epoch
New in version 0.16.
- get_modification_date_time()¶
- Returns:
the date the document was modified, or
None
- Return type:
Returns the date the document was most recently modified as a
GLib.DateTime
New in version 20.09.0.
- get_n_attachments()¶
- Returns:
Number of attachments
- Return type:
Returns the number of attachments in a loaded document. See also
Poppler.Document.get_attachments
()New in version 0.18.
- get_n_pages()¶
- Returns:
Number of pages
- Return type:
Returns the number of pages in a loaded document.
- get_n_signatures()¶
- Returns:
The number of signatures found in the document
- Return type:
Returns how many digital signatures self contains. PDF digital signatures ensure that the content hash not been altered since last edit and that it was produced by someone the user can trust
New in version 21.12.0.
- get_page(index)¶
- Parameters:
index (
int
) – a page index- Returns:
The
Poppler.Page
at index- Return type:
Returns the
Poppler.Page
indexed at index. This object is owned by the caller.
- get_page_by_label(label)¶
- Parameters:
label (
str
) – a page label- Returns:
The
Poppler.Page
referenced by label- Return type:
Returns the
Poppler.Page
reference by label. This object is owned by the caller. label is a human-readable string representation of the page number, and can be document specific. Typically, it is a value such as “iii” or “3”.By default, “1” refers to the first page.
- get_page_layout()¶
- Returns:
a
Poppler.PageLayout
that should be used when the document is opened- Return type:
Returns the page layout that should be used when the document is opened
New in version 0.16.
- get_page_mode()¶
- Returns:
a
Poppler.PageMode
that should be used when document is opened- Return type:
Returns a
Poppler.PageMode
representing how the document should be initially displayed when opened.New in version 0.16.
- get_pdf_conformance()¶
- Returns:
the document’s subtype conformance level
- Return type:
Returns the conformance level of the self as
Poppler.PDFConformance
.New in version 0.70.
- get_pdf_part()¶
- Returns:
the document’s subtype part
- Return type:
Returns the part of the conforming standard that the self adheres to as a
Poppler.PDFSubtype
.New in version 0.70.
- get_pdf_subtype()¶
- Returns:
the document’s subtype
- Return type:
Returns the subtype of self as a
Poppler.PDFSubtype
.New in version 0.70.
- get_pdf_subtype_string()¶
- Returns:
a newly allocated string containing the PDF subtype version of self, or
None
- Return type:
Returns the PDF subtype version of self as a string.
New in version 0.70.
- get_pdf_version()¶
- Returns:
- major_version:
return location for the PDF major version number
- minor_version:
return location for the PDF minor version number
- Return type:
Updates values referenced by major_version & minor_version with the major and minor PDF versions of self.
New in version 0.16.
- get_pdf_version_string()¶
-
Returns the PDF version of self as a string (e.g. PDF-1.6)
New in version 0.16.
- get_permissions()¶
- Returns:
a set of flags from
Poppler.Permissions
enumeration- Return type:
Returns the flags specifying which operations are permitted when the document is opened.
New in version 0.16.
- get_print_duplex()¶
- Returns:
a
Poppler.PrintDuplex
that should be used when document is printed- Return type:
Returns the duplex mode value suggested for printing by author of the document. Value
Poppler.PrintDuplex.NONE
means that the document does not specify this preference.New in version 0.80.
- get_print_n_copies()¶
- Returns:
Number of copies
- Return type:
Returns the suggested number of copies to be printed. This preference should be applied only if returned value is greater than 1 since value 1 usually means that the document does not specify it.
New in version 0.80.
- get_print_page_ranges()¶
- Returns:
an array of
Poppler.PageRange
s orNone
. Free the array when it is no longer needed.- Return type:
Returns the suggested page ranges to print in the form of array of
Poppler.PageRange
s and number of ranges.None
pointer means that the document does not specify page ranges for printing.New in version 0.80.
- get_print_scaling()¶
- Returns:
a
Poppler.PrintScaling
that should be used when document is printed- Return type:
Returns the print scaling value suggested by author of the document.
New in version 0.73.
- get_producer()¶
-
Returns the producer of the document. If the document was converted from another format, the producer is the name of the product that converted it to PDF
New in version 0.16.
- get_signature_fields()¶
- Returns:
a list of all signature form fields.
- Return type:
Returns a
GLib.List
containing all signaturePoppler.FormField
s in the document.New in version 22.02.0.
- get_subject()¶
-
Returns the subject of the document
New in version 0.16.
- get_title()¶
-
Returns the document’s title
New in version 0.16.
- has_javascript()¶
- Return type:
Returns whether self has any javascript in it.
New in version 0.90.
- is_linearized()¶
-
Returns whether self is linearized or not. Linearization of PDF enables efficient incremental access of the PDF file in a network environment.
New in version 0.16.
- reset_form(fields, exclude_fields)¶
- Parameters:
Resets the form fields specified by fields if exclude_fields is
False
. Resets all others if exclude_fields isTrue
. All form fields are reset regardless of the exclude_fields flag if fields is empty.New in version 0.90.
- save(uri)¶
- Parameters:
uri (
str
) – uri of file to save- Raises:
- Returns:
True
, if the document was successfully saved- Return type:
Saves self. Any change made in the document such as form fields filled, annotations added or modified will be saved. If error is set,
False
will be returned. Possible errors include those in the #G_FILE_ERROR domain.
- save_a_copy(uri)¶
- Parameters:
uri (
str
) – uri of file to save- Raises:
- Returns:
True
, if the document was successfully saved- Return type:
Saves a copy of the original self. Any change made in the document such as form fields filled by the user will not be saved. If error is set,
False
will be returned. Possible errors include those in the #G_FILE_ERROR domain.
- save_to_fd(fd, include_changes)¶
- Parameters:
- Raises:
- Returns:
True
, if the document was successfully saved- Return type:
Saves self. Any change made in the document such as form fields filled, annotations added or modified will be saved if include_changes is
True
, or discarded i include_changes isFalse
.Note that this function takes ownership of fd; you must not operate on it again, nor close it.
If error is set,
False
will be returned. Possible errors include those in the #G_FILE_ERROR domain.New in version 21.12.0.
- set_author(author)¶
- Parameters:
author (
str
) – A new author
Sets the document’s author. If author is
None
, Author entry is removed from the document’s Info dictionary.New in version 0.46.
- set_creation_date(creation_date)¶
- Parameters:
creation_date (
int
) – A new creation date
Sets the document’s creation date. If creation_date is -1, CreationDate entry is removed from the document’s Info dictionary.
New in version 0.46.
- set_creation_date_time(creation_datetime)¶
- Parameters:
creation_datetime (
GLib.DateTime
orNone
) – A new creationGLib.DateTime
Sets the document’s creation date. If creation_datetime is
None
, CreationDate entry is removed from the document’s Info dictionary.New in version 20.09.0.
- set_creator(creator)¶
- Parameters:
creator (
str
) – A new creator
Sets the document’s creator. If creator is
None
, Creator entry is removed from the document’s Info dictionary.New in version 0.46.
- set_keywords(keywords)¶
- Parameters:
keywords (
str
) – New keywords
Sets the document’s keywords. If keywords is
None
, Keywords entry is removed from the document’s Info dictionary.New in version 0.46.
- set_modification_date(modification_date)¶
- Parameters:
modification_date (
int
) – A new modification date
Sets the document’s modification date. If modification_date is -1, ModDate entry is removed from the document’s Info dictionary.
New in version 0.46.
- set_modification_date_time(modification_datetime)¶
- Parameters:
modification_datetime (
GLib.DateTime
orNone
) – A new modificationGLib.DateTime
Sets the document’s modification date. If modification_datetime is
None
, ModDate entry is removed from the document’s Info dictionary.New in version 20.09.0.
- set_producer(producer)¶
- Parameters:
producer (
str
) – A new producer
Sets the document’s producer. If producer is
None
, Producer entry is removed from the document’s Info dictionary.New in version 0.46.
- set_subject(subject)¶
- Parameters:
subject (
str
) – A new subject
Sets the document’s subject. If subject is
None
, Subject entry is removed from the document’s Info dictionary.New in version 0.46.
- set_title(title)¶
- Parameters:
title (
str
) – A new title
Sets the document’s title. If title is
None
, Title entry is removed from the document’s Info dictionary.New in version 0.46.
- sign(signing_data, cancellable, callback, *user_data)¶
- Parameters:
signing_data (
Poppler.SigningData
) – aPoppler.SigningData
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
callback (
Gio.AsyncReadyCallback
orNone
) – aGio.AsyncReadyCallback
user_data (
object
orNone
) – user data used by callback function
Sign #document using #signing_data.
New in version 23.07.0.
- sign_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
- Raises:
- Returns:
True
on successful signing a document, otherwiseFalse
and error is set.- Return type:
Finish poppler_sign_document and get return status or error.
New in version 23.07.0.
Property Details¶
- Poppler.Document.props.author¶
-
The author of the document
- Poppler.Document.props.creation_date¶
- Name:
creation-date
- Type:
- Default Value:
-1
- Flags:
The date the document was created as seconds since the Epoch, or -1
Deprecated since version 20.09.0: This will overflow in 2038. Use creation-datetime instead.
- Poppler.Document.props.creation_datetime¶
- Name:
creation-datetime
- Type:
- Default Value:
- Flags:
The
GLib.DateTime
the document was created.New in version 20.09.0.
- Poppler.Document.props.creator¶
-
The creator of the document. See also
Poppler.Document.get_creator
()
- Poppler.Document.props.format¶
-
The PDF version as string. See also
Poppler.Document.get_pdf_version_string
()
- Poppler.Document.props.format_major¶
-
The PDF major version number. See also
Poppler.Document.get_pdf_version
()
- Poppler.Document.props.format_minor¶
-
The PDF minor version number. See also
Poppler.Document.get_pdf_version
()
- Poppler.Document.props.keywords¶
-
The keywords associated to the document
- Poppler.Document.props.linearized¶
-
Whether document is linearized. See also
Poppler.Document.is_linearized
()
- Poppler.Document.props.mod_date¶
- Name:
mod-date
- Type:
- Default Value:
-1
- Flags:
The date the document was most recently modified as seconds since the Epoch, or -1
Deprecated since version 20.09.0: This will overflow in 2038. Use mod-datetime instead.
- Poppler.Document.props.mod_datetime¶
- Name:
mod-datetime
- Type:
- Default Value:
- Flags:
The
GLib.DateTime
the document was most recently modified.New in version 20.09.0.
- Poppler.Document.props.page_layout¶
- Name:
page-layout
- Type:
- Default Value:
- Flags:
The page layout that should be used when the document is opened
- Poppler.Document.props.page_mode¶
- Name:
page-mode
- Type:
- Default Value:
- Flags:
The mode that should be used when the document is opened
- Poppler.Document.props.permissions¶
- Name:
permissions
- Type:
- Default Value:
Poppler.Permissions.OK_TO_PRINT
|Poppler.Permissions.OK_TO_MODIFY
|Poppler.Permissions.OK_TO_COPY
|Poppler.Permissions.OK_TO_ADD_NOTES
|Poppler.Permissions.OK_TO_FILL_FORM
|Poppler.Permissions.OK_TO_EXTRACT_CONTENTS
|Poppler.Permissions.OK_TO_ASSEMBLE
|Poppler.Permissions.OK_TO_PRINT_HIGH_RESOLUTION
|Poppler.Permissions.FULL
- Flags:
Flags specifying which operations are permitted when the document is opened
- Poppler.Document.props.print_duplex¶
- Name:
print-duplex
- Type:
- Default Value:
- Flags:
Duplex Viewer Preference
New in version 0.80.
- Poppler.Document.props.print_n_copies¶
-
Suggested number of copies to be printed for this document
New in version 0.80.
- Poppler.Document.props.print_scaling¶
- Name:
print-scaling
- Type:
- Default Value:
- Flags:
Print Scaling Viewer Preference
New in version 0.73.
- Poppler.Document.props.producer¶
-
The producer of the document. See also
Poppler.Document.get_producer
()
- Poppler.Document.props.subject¶
-
The subject of the document
- Poppler.Document.props.subtype¶
- Name:
subtype
- Type:
- Default Value:
- Flags:
Document PDF subtype type
- Poppler.Document.props.subtype_conformance¶
- Name:
subtype-conformance
- Type:
- Default Value:
- Flags:
Document PDF subtype conformance
- Poppler.Document.props.subtype_part¶
- Name:
subtype-part
- Type:
- Default Value:
- Flags:
Document PDF subtype part
- Poppler.Document.props.subtype_string¶
-
Document PDF subtype. See also
Poppler.Document.get_pdf_subtype_string
()
- Poppler.Document.props.viewer_preferences¶
- Name:
viewer-preferences
- Type:
- Default Value:
- Flags:
Viewer Preferences