Document

Document class

Class representing PDF document

The Document type exposes the following members:

Constructors

NameDescription
Document(input)Initializes a new instance of the Document class
Document(input, password, is_managed_stream)Initializes a new instance of the Document class
Document(input, is_managed_stream)Initializes a new instance of the Document class
Document(filename)Initializes a new instance of the Document class
Document(input, password)Initializes a new instance of the Document class
Document()Initializes empty document.
Document(filename, options)Initializes a new instance of the Document class
Document(input, options)Initializes a new instance of the Document class
Document(filename, password)Initializes a new instance of the Document class
Document(filename, password, is_managed_stream)Initializes a new instance of the Document class

Properties

NameDescription
java_scriptCollection of JavaScript of document level.
is_licensedGets licensed state of the system. Returns true is system works in licensed mode and false otherwise.
page_infoGets or sets the page info.(for generator only, not filled in when reading document)
enable_signature_sanitizationGets or sets flag to manage signature fields sanitization. Enabled by default.
is_pdfa_compliantGets the is document pdfa compliant.
is_pdf_ua_compliantGets the is document pdfua compliant.
is_xref_gaps_allowedGets or sets the is document pdfa compliant.
named_destinationsCollection of Named Destination in the document.
destinationsGets the collection of destinations.
Obsolete. Please use NamedDestinations.
pdf_formatGets PDF format
embed_standard_fontsProperty which declares that document must embed all standard Type1 fonts
which has flag IsEmbedded set into true. All PDF fonts can be embedded
into document simply via setting of flag IsEmbedded into true, but PDF standard Type1 fonts is an exception from this rule.
Standard Type1 font embedding requires much time, so to embed these fonts it’s necessary
not only set flag IsEmbedded into true for specified font but also set
an additiona flag on document’s level - EmbedStandardFonts = true;
This property can be set only one time for all fonts.
By default false.
disable_font_license_verificationsMany operations with font can’t be executed if these operations are prohibited by license of this font.
For example some font can’t be embedded into PDF document if license rules disable embedding for this font.
This flag is used to disable any license restrictions for all fonts in current PDF document.
Be careful when using this flag. When it is set it means that person who sets this flag,
takes all responsibility of possible license/law violations on himself.
So He takes it on it’s own risk.
It’s strongly recommended to use this flag only when you are fully confident that you are not breaking
the copyright law.
By default false.
font_utilitiesIDocumentFontUtilities instance
collectionGets collection of document.
versionGets a version of Pdf from Pdf file header.
open_actionGets or sets action performed at document opening.
hide_tool_barGets or sets flag specifying whether toolbar should be hidden when document is active.
hide_menubarGets or sets flag specifying whether menu bar should be hidden when document is active.
hide_window_uiGets or sets flag specifying whether user interface elements should be hidden when document is active.
fit_windowGets or sets flag specifying whether document window must be resized to fit the first displayed page.
center_windowGets or sets flag specifying whether position of the document’s window will be centerd on the screen.
display_doc_titleGets or sets flag specifying whether document’s window title bar should display document title.
pagesGets or sets collection of document pages.
Note that pages are numbered from 1 in collection.
outlinesGets document outlines.
actionsGets document actions. This property is instance of DocumentActions class which allows to get/set BeforClosing, BeforSaving, etc. actions.
formGets Acro Form of the document.
embedded_filesGets collection of files embedded to document.
directionGets or sets reading order of text: L2R (left to right) or R2L (right to left).
page_modeGets or sets page mode, specifying how document should be displayed when opened.
non_full_screen_page_modeGets or sets page mode, specifying how to display the document on exiting full-screen mode.
page_layoutGets or sets page layout which shall be used when the document is opened.
duplexGets or sets print duplex mode handling option to use when printing the file from the print dialog.
file_nameName of the PDF file that caused this document
infoGets document info.
metadataDocument metadata.
(A PDF document may include general information,
such as the document’s title, author, and creation and modification dates.
Such global information about the document (as opposed to its content or structure) is called metadata
and is intended to assist in cataloguing and searching for documents in external databases.)
logical_structureGets logical structure of the document.
handle_signature_changeThrow Exception if the document will save with changes and have signature
crypto_algorithmGets security settings if document is encrypted.
If document is not encrypted then corresponding exception will be raised in .net 1.1
or CryptoAlgorithm will be null for other .net versions.
is_linearizedGets or sets a value indicating whether document is linearized.
permissionsGets permissions of the document.
is_encryptedGets encrypted status of the document. True if document is encrypted.
idGets the ID.
backgroundGets or sets the background color of the document.
optimize_sizeGets or sets optimization flag. When pages are added to document, equal resource streams in resultant file are
merged into one PDF object if this flag set.
This allows to decrease resultant file size but may cause slower execution and larger memory requirements.
Default value: false.
allow_reuse_page_contentAllows to merge page contents to optimize docuement size. If used then differnet but duplicated pages may reference to the
same content object. Please note that this mode may cause side effects like changing page content when other page is changed.
ignore_corrupted_objectsGets or sets flag of ignoring errors in source files.
When pages from source document copied into destination document, copying process is stopped with exception
if some objects in source files are corrupted when this flag is false.
example: dest.Pages.Add(src.Pages);
If this flag is set to true then corrupted objects will be replaced with empty values.
By default: true.
page_labelsGets page labels in the document.
enable_object_unloadGet or sets flag which enables document partially be unloaded from memory.
This allow to decrease memory usage but may have negative effect on perfomance.
tagged_contentGets access to TaggedPdf content.

Methods

NameDescription
save(output)Stores document into stream.
save(output_file_name)Saves document into the specified file.
save()Stores document into stream.
save(options)Saves the document with save options.
save(output_file_name, format)Saves the document with a new name along with a file format.
save(output_stream, format)Saves the document with a new name along with a file format.
save(output_file_name, options)Saves the document with a new name setting its save options.
save(output_stream, options)Saves the document to a stream with a save options.
export_annotations_to_xfdf(file_name)Exports all document annotations to XFDF file
export_annotations_to_xfdf(stream)Export all document annotations into stream.
send_to(device, output)Sends the whole document to the document device for processing.
send_to(device, from_page, to_page, output)Sends the certain pages of the document to the document device for processing.
send_to(device, output_file_name)Sends the whole document to the document device for processing.
send_to(device, from_page, to_page, output_file_name)Sends the whole document to the document device for processing.
import_annotations_from_xfdf(file_name)Imports annotations from XFDF file to document.
import_annotations_from_xfdf(stream)Imports annotations from stream to document.
validate(output_log_file_name, format)Validate document into the specified file.
validate(output_log_stream, format)Validate document into the specified file.
validate(options)Validate document into the specified file.
convert(output_log_file_name, format, action, transparency_action)Convert document and save errors into the specified file.
convert(output_log_stream, format, action, transparency_action)Convert document and save errors into the specified file.
convert(output_log_file_name, format, action)Convert document and save errors into the specified file.
convert(options)Convert document using specified conversion options
convert(output_log_stream, format, action)Convert document and save errors into the specified file.
convert(fixup, output_log, only_validation, parameters)Convert document by applying the Fixup.
convert(fixup, output_log, only_validation, parameters)Convert document by applying the Fixup.
convert(src_file_name, load_options, dst_file_name, save_options)Converts source file in source format into destination file in destination format.
convert(src_stream, load_options, dst_file_name, save_options)Converts stream in source format into destination file in destination format.
convert(src_file_name, load_options, dst_stream, save_options)Converts stream in source format into destination file in destination format.
convert(src_stream, load_options, dst_stream, save_options)Converts stream in source format into destination file in destination format.
flatten()Removes all fields from the document and place their values instead.
flatten(flatten_settings)Removes all fields from the document and place their values instead.
encrypt(user_password, owner_password, privileges, crypto_algorithm, use_pdf20)Encrypts the document. Call then Save to get encrypted version of the document.
encrypt(user_password, owner_password, permissions, crypto_algorithm)Encrypts the document. Call then Save to get encrypted version of the document.
encrypt(user_password, owner_password, permissions, crypto_algorithm, use_pdf20)Encrypts the document. Call then Save to get encrypted version of the document.
optimize_resources()Optimize resources in the document:
1. Resources which are not used on the document pages are removed;
2. Equal resources are joined into one object;
3. Unused objects are deleted.
optimize_resources(strategy)Optimize resources in the document according to defined optimization strategy.
bind_xml(file)Bind xml to document
bind_xml(xml_file, xsl_file)Bind xml to document
bind_xml(xml_stream, xsl_stream)Bind xml/xsl to document
bind_xml(stream)Bind xml/xsl to document
remove_pdfa_compliance()Remove pdfa compliance from the document
remove_pdf_ua_compliance()Remove pdfUa compliance from the document
set_title(title)Set Title for Pdf Document
process_paragraphs()Process paragraphs for generator.
remove_metadata()Removes metadata from the document.
change_passwords(owner_password, new_user_password, new_owner_password)Changes document passwords. This action can be done only using owner password.
decrypt()Decrypts the document. Call then Save to obtain decrypted version of the document.
optimize()Linearize document in order to
- open the first page as quickly as possible;
- display next page or follow by link to the next page as quickly as possible;
- display the page incrementally as it arrives when data for a page is delivered over a slow channel (display the most useful data first);
- permit user interaction, such as following a link, to be performed even before the entire page has been received and displayed.
Invoking this method doesn’t actually saves the document. On the contrary the document only is prepared to have optimized structure,
call then Save to get optimized document.
get_catalog_value(key)Returns item value from catalog dictionary.
free_memory()Clears memory
save_xml(file)Save document to XML.
get_object_by_id(id)Gets a object with specified ID in the document.
repair()Repairs broken document.
get_xmp_metadata(stream)Get XMP metadata from document.
set_xmp_metadata(stream)Set XMP metadata of document.
check(do_repair)Validates document.
page_nodes_to_balanced_tree(nodes_num_in_subtrees)Organizes page tree nodes in a document into a balanced tree.
Only if the document has more than nodesNumInSubtrees page objects, otherwise it does nothing.

See Also