Class: Poppler::Document
- Inherits:
-
Object
- Object
- Poppler::Document
- Includes:
- Enumerable
- Defined in:
- lib/poppler/document.rb
Instance Method Summary collapse
-
#attachments ⇒ GLib::List<Poppler::Attachment>
Returns a #GList containing Poppler::Attachments.
-
#author ⇒ String
The author of the document.
-
#author=(author) ⇒ String
The author of the document.
-
#create_dests_tree ⇒ GLib::Tree
Creates a balanced binary tree of all named destinations in document.
-
#creation_date ⇒ Integer
The date the document was created as seconds since the Epoch, or -1.
-
#creation_date=(creation_date) ⇒ Integer
The date the document was created as seconds since the Epoch, or -1.
-
#creation_date_time ⇒ GLib::DateTime
Returns the date the document was created as a GDate::Time.
-
#creation_date_time=(creation_datetime) ⇒ nil
Sets the document's creation date.
-
#creation_datetime ⇒ GLib::DateTime
The GDate::Time the document was created.
-
#creation_datetime=(creation_datetime) ⇒ GLib::DateTime
The GDate::Time the document was created.
-
#creator ⇒ String
The creator of the document.
-
#creator=(creator) ⇒ String
The creator of the document.
- #each ⇒ Object
-
#find_dest(link_name) ⇒ Poppler::Dest
Creates a Poppler::Dest for the named destination link_name in document.
-
#format ⇒ String
The PDF version as string.
-
#format=(format) ⇒ String
The PDF version as string.
-
#format_major ⇒ Integer
The PDF major version number.
-
#format_major=(format_major) ⇒ Integer
The PDF major version number.
-
#format_minor ⇒ Integer
The PDF minor version number.
-
#format_minor=(format_minor) ⇒ Integer
The PDF minor version number.
-
#get_form_field(id) ⇒ Poppler::FormField
Returns the Poppler::FormField for the given id.
-
#get_id(permanent_id, update_id) ⇒ Boolean
Returns the PDF file identifier represented as two byte string arrays of size 32.
-
#get_page(index) ⇒ Poppler::Page
(also: #[])
Returns the Poppler::Page indexed at index.
-
#get_page_by_label(label) ⇒ Poppler::Page
Returns the Poppler::Page reference by label.
-
#get_pdf_version(major_version, minor_version) ⇒ nil
Updates values referenced by major_version & minor_version with the major and minor PDF versions of document.
-
#get_print_page_ranges(n_ranges) ⇒ Array<Poppler::PageRange>
Returns the suggested page ranges to print in the form of array of Poppler::PageRanges and number of ranges.
-
#has_attachments ⇒ Boolean
Returns true of document has any attachments.
-
#has_javascript ⇒ Boolean
Returns whether document has any javascript in it.
- #index_iter ⇒ Object
-
#initialize(*args) ⇒ Poppler::Document
constructor
Creates a new Poppler::Document reading the PDF contents from stream.
-
#initialize_raw ⇒ Poppler::Document
Creates a new Poppler::Document reading the PDF contents from stream.
-
#is_linearized ⇒ Boolean
Returns whether document is linearized or not.
-
#keywords ⇒ String
The keywords associated to the document.
-
#keywords=(keywords) ⇒ String
The keywords associated to the document.
-
#linearized=(linearized) ⇒ Boolean
Whether document is linearized.
-
#linearized? ⇒ Boolean
Whether document is linearized.
-
#metadata ⇒ String
Document metadata in XML format, or nil.
-
#metadata=(metadata) ⇒ String
Document metadata in XML format, or nil.
-
#mod_date ⇒ Integer
The date the document was most recently modified as seconds since the Epoch, or -1.
-
#mod_date=(mod_date) ⇒ Integer
The date the document was most recently modified as seconds since the Epoch, or -1.
-
#mod_datetime ⇒ GLib::DateTime
The GDate::Time the document was most recently modified.
-
#mod_datetime=(mod_datetime) ⇒ GLib::DateTime
The GDate::Time the document was most recently modified.
-
#modification_date ⇒ Poppler::time_t
Returns the date the document was most recently modified as seconds since the Epoch.
-
#modification_date=(modification_date) ⇒ nil
Sets the document's modification date.
-
#modification_date_time ⇒ GLib::DateTime
Returns the date the document was most recently modified as a GDate::Time.
-
#modification_date_time=(modification_datetime) ⇒ nil
Sets the document's modification date.
-
#n_attachments ⇒ Integer
Returns the number of attachments in a loaded document.
-
#n_pages ⇒ Integer
(also: #size)
Returns the number of pages in a loaded document.
-
#n_signatures ⇒ Integer
Returns how many digital signatures document contains.
-
#page_layout ⇒ Poppler::PageLayout
The page layout that should be used when the document is opened.
-
#page_layout=(page_layout) ⇒ Poppler::PageLayout
The page layout that should be used when the document is opened.
-
#page_mode ⇒ Poppler::PageMode
The mode that should be used when the document is opened.
-
#page_mode=(page_mode) ⇒ Poppler::PageMode
The mode that should be used when the document is opened.
-
#pdf_conformance ⇒ Poppler::PDFConformance
Returns the conformance level of the document as Poppler::PDFConformance.
-
#pdf_part ⇒ Poppler::PDFPart
Returns the part of the conforming standard that the document adheres to as a Poppler::PDFSubtype.
-
#pdf_subtype ⇒ Poppler::PDFSubtype
Returns the subtype of document as a Poppler::PDFSubtype.
-
#pdf_subtype_string ⇒ String
Returns the PDF subtype version of document as a string.
-
#pdf_version_string ⇒ String
Returns the PDF version of document as a string (e.g. PDF-1.6).
-
#permissions ⇒ Poppler::Permissions
Flags specifying which operations are permitted when the document is opened.
-
#permissions=(permissions) ⇒ Poppler::Permissions
Flags specifying which operations are permitted when the document is opened.
-
#print_duplex ⇒ Poppler::PrintDuplex
Print-duplex.
- #print_duplex=(print_duplex) ⇒ Poppler::PrintDuplex
-
#print_n_copies ⇒ Integer
Suggested number of copies to be printed for this document.
-
#print_n_copies=(print_n_copies) ⇒ Integer
Suggested number of copies to be printed for this document.
-
#print_scaling ⇒ Poppler::PrintScaling
Print-scaling.
- #print_scaling=(print_scaling) ⇒ Poppler::PrintScaling
-
#producer ⇒ String
The producer of the document.
-
#producer=(producer) ⇒ String
The producer of the document.
-
#reset_form(fields, exclude_fields) ⇒ nil
Resets the form fields specified by fields if exclude_fields is FALSE.
-
#save(uri) ⇒ Boolean
Saves document.
-
#save_a_copy(uri) ⇒ Boolean
Saves a copy of the original document.
-
#save_a_copy_raw ⇒ Boolean
Saves a copy of the original document.
-
#save_raw ⇒ Boolean
Saves document.
-
#save_to_fd(fd, include_changes) ⇒ Boolean
Saves document.
-
#sign(signing_data, cancellable, callback, user_data) ⇒ nil
Sign #document using #signing_data.
-
#sign_finish(result) ⇒ Boolean
Finish poppler_sign_document and get return status or error.
-
#signature_fields ⇒ GLib::List<Poppler::FormField>
Returns a #GList containing all signature Poppler::FormFields in the document.
-
#subject ⇒ String
The subject of the document.
-
#subject=(subject) ⇒ String
The subject of the document.
-
#subtype ⇒ Poppler::PDFSubtype
Document PDF subtype type.
-
#subtype=(subtype) ⇒ Poppler::PDFSubtype
Document PDF subtype type.
-
#subtype_conformance ⇒ Poppler::PDFConformance
Document PDF subtype conformance.
-
#subtype_conformance=(subtype_conformance) ⇒ Poppler::PDFConformance
Document PDF subtype conformance.
-
#subtype_part ⇒ Poppler::PDFPart
Document PDF subtype part.
-
#subtype_part=(subtype_part) ⇒ Poppler::PDFPart
Document PDF subtype part.
-
#subtype_string ⇒ String
Document PDF subtype.
-
#subtype_string=(subtype_string) ⇒ String
Document PDF subtype.
-
#title ⇒ String
The document's title or nil.
-
#title=(title) ⇒ String
The document's title or nil.
-
#viewer_preferences ⇒ Poppler::ViewerPreferences
Viewer-preferences.
- #viewer_preferences=(viewer_preferences) ⇒ Poppler::ViewerPreferences
Constructor Details
#initialize(*args) ⇒ Poppler::Document
Creates a new Poppler::Document reading the PDF contents from stream. Note that the given GInput::Stream must be seekable or %G_IO_ERROR_NOT_SUPPORTED will be returned. Possible errors include those in the #POPPLER_ERROR, #G_FILE_ERROR and #G_IO_ERROR domains.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/poppler/document.rb', line 24 def initialize(*args) if args.size == 1 and args[0].is_a?(Hash) = args[0] else uri_or_data, password = args if pdf_data?(uri_or_data) = { :data => uri_or_data, :password => password } else = { :uri => ensure_uri(uri_or_data), :password => password } end end data = [:data] uri = [:uri] path = [:path] stream = [:stream] length = [:length] file = [:file] password = [:password] if data if respond_to?(:initialize_new_from_bytes) initialize_new_from_bytes(data, password) else @file = Tempfile.new(["poppler", ".pdf"]) @file.binmode @file.write(data) @file.close initialize_new_from_file(ensure_uri(@file.path), password) end elsif uri initialize_new_from_file(uri, password) elsif path uri = ensure_uri(path) initialize_new_from_file(uri, password) elsif stream if length.nil? raise(ArgumentError, "must specify :length for :stream: #{.inspect}") end initialize_new_from_stream(stream, length, password) elsif file case file when String, Pathname initialize(path: file, password: password) else initialize_new_from_gfile(file, password) end else = "must specify one of :data, :uri, :path, :stream or :file: " + .inspect raise(ArgumentError, ) end end |
Instance Method Details
#attachments ⇒ GLib::List<Poppler::Attachment>
Returns a #GList containing Poppler::Attachments. These attachments are unowned, and must be unreffed, and the list must be freed with g_list_free().
#author ⇒ String
The author of the document
#author=(author) ⇒ String
The author of the document
#create_dests_tree ⇒ GLib::Tree
Creates a balanced binary tree of all named destinations in document
The tree key is strings in the form returned by poppler_named_dest_to_bytestring() which constains a destination name. The tree value is the Poppler::Dest which contains a named destination. The return value must be freed with g_tree_destroy().
#creation_date ⇒ Integer
The date the document was created as seconds since the Epoch, or -1
#creation_date=(creation_date) ⇒ Integer
The date the document was created as seconds since the Epoch, or -1
#creation_date_time ⇒ GLib::DateTime
Returns the date the document was created as a GDate::Time
#creation_date_time=(creation_datetime) ⇒ nil
Sets the document's creation date. If creation_datetime is nil, CreationDate entry is removed from the document's Info dictionary.
#creation_datetime ⇒ GLib::DateTime
The GDate::Time the document was created.
#creation_datetime=(creation_datetime) ⇒ GLib::DateTime
The GDate::Time the document was created.
#creator ⇒ String
The creator of the document. See also poppler_document_get_creator()
#creator=(creator) ⇒ String
The creator of the document. See also poppler_document_get_creator()
#each ⇒ Object
88 89 90 91 92 93 94 |
# File 'lib/poppler/document.rb', line 88 def each return to_enum(__method__) unless block_given? n_pages.times do |i| yield get_page(i) end end |
#find_dest(link_name) ⇒ Poppler::Dest
Creates a Poppler::Dest for the named destination link_name in document.
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().
#format ⇒ String
The PDF version as string. See also poppler_document_get_pdf_version_string()
#format=(format) ⇒ String
The PDF version as string. See also poppler_document_get_pdf_version_string()
#format_major ⇒ Integer
The PDF major version number. See also poppler_document_get_pdf_version()
#format_major=(format_major) ⇒ Integer
The PDF major version number. See also poppler_document_get_pdf_version()
#format_minor ⇒ Integer
The PDF minor version number. See also poppler_document_get_pdf_version()
#format_minor=(format_minor) ⇒ Integer
The PDF minor version number. See also poppler_document_get_pdf_version()
#get_form_field(id) ⇒ Poppler::FormField
Returns the Poppler::FormField for the given id. It must be freed with g_object_unref() not found
#get_id(permanent_id, update_id) ⇒ Boolean
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.
#get_page(index) ⇒ Poppler::Page Also known as: []
Returns the Poppler::Page indexed at index. This object is owned by the caller.
#get_page_by_label(label) ⇒ Poppler::Page
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_pdf_version(major_version, minor_version) ⇒ nil
Updates values referenced by major_version & minor_version with the major and minor PDF versions of document.
#get_print_page_ranges(n_ranges) ⇒ Array<Poppler::PageRange>
Returns the suggested page ranges to print in the form of array of Poppler::PageRanges and number of ranges. nil pointer means that the document does not specify page ranges for printing.
#has_attachments ⇒ Boolean
Returns true of document has any attachments.
#has_javascript ⇒ Boolean
Returns whether document has any javascript in it.
#index_iter ⇒ Object
106 107 108 |
# File 'lib/poppler/document.rb', line 106 def index_iter IndexIter.new(self) end |
#initialize_raw ⇒ Poppler::Document
Creates a new Poppler::Document reading the PDF contents from stream. Note that the given GInput::Stream must be seekable or %G_IO_ERROR_NOT_SUPPORTED will be returned. Possible errors include those in the #POPPLER_ERROR, #G_FILE_ERROR and #G_IO_ERROR domains.
|
|
# File 'lib/poppler/document.rb', line 23
|
#is_linearized ⇒ Boolean
Returns whether document is linearized or not. Linearization of PDF enables efficient incremental access of the PDF file in a network environment.
#keywords ⇒ String
The keywords associated to the document
#keywords=(keywords) ⇒ String
The keywords associated to the document
#linearized=(linearized) ⇒ Boolean
Whether document is linearized. See also poppler_document_is_linearized()
#linearized? ⇒ Boolean
Whether document is linearized. See also poppler_document_is_linearized()
#metadata ⇒ String
Document metadata in XML format, or nil
#metadata=(metadata) ⇒ String
Document metadata in XML format, or nil
#mod_date ⇒ Integer
The date the document was most recently modified as seconds since the Epoch, or -1
#mod_date=(mod_date) ⇒ Integer
The date the document was most recently modified as seconds since the Epoch, or -1
#mod_datetime ⇒ GLib::DateTime
The GDate::Time the document was most recently modified.
#mod_datetime=(mod_datetime) ⇒ GLib::DateTime
The GDate::Time the document was most recently modified.
#modification_date ⇒ Poppler::time_t
Returns the date the document was most recently modified as seconds since the Epoch
#modification_date=(modification_date) ⇒ nil
Sets the document's modification date. If modification_date is -1, ModDate entry is removed from the document's Info dictionary.
#modification_date_time ⇒ GLib::DateTime
Returns the date the document was most recently modified as a GDate::Time
#modification_date_time=(modification_datetime) ⇒ nil
Sets the document's modification date. If modification_datetime is nil, ModDate entry is removed from the document's Info dictionary.
#n_attachments ⇒ Integer
Returns the number of attachments in a loaded document. See also poppler_document_get_attachments()
#n_pages ⇒ Integer Also known as: size
Returns the number of pages in a loaded document.
#n_signatures ⇒ Integer
Returns how many digital signatures document 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
#page_layout ⇒ Poppler::PageLayout
The page layout that should be used when the document is opened
#page_layout=(page_layout) ⇒ Poppler::PageLayout
The page layout that should be used when the document is opened
#page_mode ⇒ Poppler::PageMode
The mode that should be used when the document is opened
#page_mode=(page_mode) ⇒ Poppler::PageMode
The mode that should be used when the document is opened
#pdf_conformance ⇒ Poppler::PDFConformance
Returns the conformance level of the document as Poppler::PDFConformance.
#pdf_part ⇒ Poppler::PDFPart
Returns the part of the conforming standard that the document adheres to as a Poppler::PDFSubtype.
#pdf_subtype ⇒ Poppler::PDFSubtype
Returns the subtype of document as a Poppler::PDFSubtype.
#pdf_subtype_string ⇒ String
Returns the PDF subtype version of document as a string. the PDF subtype version of document, or nil
#pdf_version_string ⇒ String
Returns the PDF version of document as a string (e.g. PDF-1.6)
#permissions ⇒ Poppler::Permissions
Flags specifying which operations are permitted when the document is opened
#permissions=(permissions) ⇒ Poppler::Permissions
Flags specifying which operations are permitted when the document is opened
#print_duplex ⇒ Poppler::PrintDuplex
Returns print-duplex.
#print_duplex=(print_duplex) ⇒ Poppler::PrintDuplex
#print_n_copies ⇒ Integer
Suggested number of copies to be printed for this document
#print_n_copies=(print_n_copies) ⇒ Integer
Suggested number of copies to be printed for this document
#print_scaling ⇒ Poppler::PrintScaling
Returns print-scaling.
#print_scaling=(print_scaling) ⇒ Poppler::PrintScaling
#producer ⇒ String
The producer of the document. See also poppler_document_get_producer()
#producer=(producer) ⇒ String
The producer of the document. See also poppler_document_get_producer()
#reset_form(fields, exclude_fields) ⇒ nil
Resets the form fields specified by fields if exclude_fields is FALSE. Resets all others if exclude_fields is TRUE. All form fields are reset regardless of the exclude_fields flag if fields is empty.
#save(uri) ⇒ Boolean
Saves document. 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.
97 98 99 |
# File 'lib/poppler/document.rb', line 97 def save(uri) save_raw(ensure_uri(uri)) end |
#save_a_copy(uri) ⇒ Boolean
Saves a copy of the original document. 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.
102 103 104 |
# File 'lib/poppler/document.rb', line 102 def save_a_copy(uri) save_a_copy_raw(ensure_uri(uri)) end |
#save_a_copy_raw ⇒ Boolean
Saves a copy of the original document. 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.
|
|
# File 'lib/poppler/document.rb', line 101
|
#save_raw ⇒ Boolean
Saves document. 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.
|
|
# File 'lib/poppler/document.rb', line 96
|
#save_to_fd(fd, include_changes) ⇒ Boolean
Saves document. 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 is false.
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.
#sign(signing_data, cancellable, callback, user_data) ⇒ nil
Sign #document using #signing_data.
#sign_finish(result) ⇒ Boolean
Finish poppler_sign_document and get return status or error.
#signature_fields ⇒ GLib::List<Poppler::FormField>
Returns a #GList containing all signature Poppler::FormFields in the document.
#subject ⇒ String
The subject of the document
#subject=(subject) ⇒ String
The subject of the document
#subtype ⇒ Poppler::PDFSubtype
Document PDF subtype type
#subtype=(subtype) ⇒ Poppler::PDFSubtype
Document PDF subtype type
#subtype_conformance ⇒ Poppler::PDFConformance
Document PDF subtype conformance
#subtype_conformance=(subtype_conformance) ⇒ Poppler::PDFConformance
Document PDF subtype conformance
#subtype_part ⇒ Poppler::PDFPart
Document PDF subtype part
#subtype_part=(subtype_part) ⇒ Poppler::PDFPart
Document PDF subtype part
#subtype_string ⇒ String
Document PDF subtype. See also poppler_document_get_pdf_subtype_string()
#subtype_string=(subtype_string) ⇒ String
Document PDF subtype. See also poppler_document_get_pdf_subtype_string()
#title ⇒ String
The document's title or nil
#title=(title) ⇒ String
The document's title or nil
#viewer_preferences ⇒ Poppler::ViewerPreferences
Returns viewer-preferences.