PTPDFDoc
@interface PTPDFDoc : NSObject
PDFDoc is a high-level class describing a single PDF (Portable Document Format) document. Most applications using PDFNet will use this class to open existing PDF documents, or to create new PDF documents from scratch.
The class offers a number of entry points into the document. For example,
- To access pages use pdfdoc.GetPageIterator() or pdfdoc.GetPage(page_num).
- To access form fields use pdfdoc.GetFieldIterator(), pdfdoc.GetFieldIterator(name) or pdfdoc.GetField(name).
- To access document’s meta-data use pdfdoc.GetDocInfo().
- To access the outline tree use pdfdoc.GetFirstBookmark().
- To access low-level Document Catalog use pdfdoc.GetRoot(). …
The class also offers utility methods to slit and merge PDF pages, to create new pages, to flatten forms, to change security settings, etc.
-
Default constructor. Creates an empty new document.
Declaration
Objective-C
- (instancetype)init;
Swift
init!()
-
Undocumented
Declaration
Objective-C
- (instancetype)initWithFilepath: (NSString *)filepath;
Swift
init!(filepath: String!)
-
Undocumented
Declaration
Objective-C
- (instancetype)initWithBuf: (NSData*)buf buf_size: (unsigned long)buf_size;
Swift
init!(buf: Data!, buf_size: UInt)
-
Close PDFDoc
Declaration
Objective-C
- (void)Close;
Swift
func close()
-
Declaration
Objective-C
- (BOOL)IsEncrypted;
Swift
func isEncrypted() -> Bool
Return Value
true if the document is/was originally encrypted false otherwise.
-
Initializes document’s SecurityHandler. This version of InitSecurityHandler() works with Standard and Custom PDF security and can be used in situations where the password is obtained dynamically via user feedback. See EncTest sample for example code.
This function should be called immediately after an encrypted document is opened. The function does not have any side effects on documents that are not encrypted.
If the security handler was successfully initialized it can be later obtained using GetSecurityHandler() method.
@exception An exception is thrown if the matching handler for document’s security was not found in the global SecurityManager. In this case, you need to register additional custom security handlers with the global SecurityManager (using SecurityManagerSingleton).
Declaration
Objective-C
- (BOOL)InitSecurityHandler;
Swift
func initSecurityHandler() -> Bool
Parameters
custom_data
An optional parameter used to specify custom data that should be passed in SecurityHandler::Initialize() callback.
Return Value
true if the SecurityHandler was successfully initialized (this may include authentication data collection, verification etc.), false otherwise.
-
Initializes document’s SecurityHandler using the supplied password. This version of InitSecurityHandler() assumes that document uses Standard security and that a password is specified directly.
This function should be called immediately after an encrypted document is opened. The function does not have any side effects on documents that are not encrypted.
If the security handler was successfully initialized, it can be later obtained using GetSecurityHandler() method.
@exception An exception is thrown if the document’s security Filter is not ‘Standard’. In this case, you need to register additional custom security handlers with the global SecurityManager (SecurityManagerSingleton).
@remark Deprecated. Use versions that accepts UString or buffer instead.
Declaration
Objective-C
- (BOOL)InitStdSecurityHandlerWithPassword:(NSString *)password password_sz:(int)password_sz;
Swift
func initStdSecurityHandler(withPassword password: String!, password_sz: Int32) -> Bool
Parameters
password
Specifies the password used to open the document without any user feedback. If you would like to dynamically obtain the password, you need to derive a custom class from StdSecurityHandler() and use InitSecurityHandler() without any parameters. See EncTest sample for example code.
password_sz
An optional parameter used to specify the size of the password buffer, in bytes. If the ‘password_sz’ is 0, or if the parameter is not specified, the function assumes that the string is null terminated.
Return Value
true if the given password successfully unlocked the document, false otherwise.
-
Initializes document’s SecurityHandler using the supplied password. This version of InitSecurityHandler() assumes that document uses Standard security and that a password is specified directly.
This function should be called immediately after an encrypted document is opened. The function does not have any side effects on documents that are not encrypted.
If the security handler was successfully initialized, it can be later obtained using GetSecurityHandler() method.
@exception An exception is thrown if the document’s security Filter is not ‘Standard’. In this case, you need to register additional custom security handlers with the global SecurityManager (SecurityManagerSingleton).
Declaration
Objective-C
- (BOOL)InitStdSecurityHandler:(NSString *)password;
Swift
func initStdSecurityHandler(_ password: String!) -> Bool
Parameters
password
Specifies the password used to open the document without any user feedback. If you would like to dynamically obtain the password, you need to derive a custom class from StdSecurityHandler() and use InitSecurityHandler() without any parameters. See EncTest sample for example code.
Return Value
true if the given password successfully unlocked the document, false otherwise.
-
Note
InitSecurityHandler() should be called before GetSecurityHandler() in order to initialize the handler.
Note
Returned security handler can be modified in order to change the security settings of the existing document. Changes to the current handler will not invalidate the access to the original file and will take effect during document Save().
Note
If the security handler is modified, document will perform a full save even if e_incremental was given as a flag in Save() method.
Declaration
Objective-C
- (PTSecurityHandler *)GetSecurityHandler;
Swift
func getSecurityHandler() -> PTSecurityHandler!
Return Value
Currently selected SecurityHandler.
-
The function sets a new SecurityHandler as the current security handler.
Note
Setting a new security handler will not invalidate the access to the original file and will take effect during document Save().
Note
If the security handler is modified, document will perform a full save even if e_incremental was given as a flag in Save() method.
Declaration
Objective-C
- (void)SetSecurityHandler:(PTSecurityHandler *)handler;
Swift
func setSecurityHandler(_ handler: PTSecurityHandler!)
Parameters
handler
new SecurityHandler
-
This function removes document security.
Declaration
Objective-C
- (void)RemoveSecurity;
Swift
func removeSecurity()
-
Indicates whether this documents contains any digital signatures.
Declaration
Objective-C
- (BOOL)HasSignatures;
Swift
func hasSignatures() -> Bool
Return Value
True if a digital signature is found in this PDFDoc.
-
Adds a signature handler to the signature manager.
Declaration
Objective-C
- (PTSignatureHandlerId)AddSignatureHandler: (PTSignatureHandler *)signature_handler;
Swift
func add(_ signature_handler: PTSignatureHandler!) -> PTSignatureHandlerId
Parameters
signature_handler
The signature handler instance to add to the signature manager.
Return Value
A unique ID representing the SignatureHandler within the SignatureManager.
-
Adds a standard (built-in) signature handler to the signature manager. This method will use cryptographic algorithm based on Adobe.PPKLite/adbe.pkcs7.detached filter to sign a PDF.
Declaration
Objective-C
- (unsigned long)AddStdSignatureHandlerFromFile:(NSString *)pkcs12_keyfile pkcs12_keypass:(NSString *)pkcs12_keypass;
Swift
func addStdSignatureHandler(fromFile pkcs12_keyfile: String!, pkcs12_keypass: String!) -> UInt
Parameters
pkcs12_file
The private key certificate store to use.
pkcs12_pass
The passphrase for the provided private key.
Return Value
A unique ID representing the SignatureHandler within the SignatureManager.
-
Adds a standard (built-in) signature handler to the signature manager. This method will use cryptographic algorithm based on Adobe.PPKLite/adbe.pkcs7.detached filter to sign a PDF.
Declaration
Objective-C
- (unsigned long)AddStdSignatureHandlerFromBuffer:(NSData *)pkcs12_keybuffer pkcs12_keypass:(NSString *)pkcs12_keypass;
Swift
func addStdSignatureHandler(fromBuffer pkcs12_keybuffer: Data!, pkcs12_keypass: String!) -> UInt
Parameters
pkcs12_keybuffer
The private key certificate store to use (as a data buffer in an array of bytes).
pkcs12_pass
The passphrase for the provided private key.
Return Value
A unique ID representing the SignatureHandler within the SignatureManager.
-
Removes a signature handler from the signature manager.
Declaration
Objective-C
- (void)RemoveSignatureHandler:(PTSignatureHandlerId)signature_handler_id;
Swift
func removeSignatureHandler(_ signature_handler_id: PTSignatureHandlerId)
Parameters
signature_handler_id
The unique id of the signature handler to remove.
-
Gets the associated signature handler instance from the signature manager by looking it up with the handler name.
Declaration
Objective-C
- (PTSignatureHandler *)GetSignatureHandler: (PTSignatureHandlerId)signature_handler_id;
Swift
func getSignatureHandler(_ signature_handler_id: PTSignatureHandlerId) -> PTSignatureHandler!
Parameters
signature_handler_id
The unique id of the signature handler to get.
Return Value
The signature handler instance if found, otherwise NULL.
-
Declaration
Objective-C
- (PTSDFUndoManager *)GetUndoManager;
Swift
func getUndoManager() -> PTSDFUndoManager!
Return Value
The UndoManager object (one-to-one mapped to document)
-
Creates an unsigned digital signature form field inside the document.
Declaration
Objective-C
- (PTDigitalSignatureField *)CreateDigitalSignatureField: (NSString *)in_sig_field_name;
Swift
func createDigitalSignatureField(_ in_sig_field_name: String!) -> PTDigitalSignatureField!
Parameters
in_sig_field_name
The fully-qualified name to give the digital signature field. If one is not provided, a unique name is created automatically.
Return Value
A DigitalSignatureField object representing the created digital signature field.
-
Retrieves an iterator that iterates over digital signature fields.
Declaration
Objective-C
- (PTDigitalSignatureFieldIterator *)GetDigitalSignatureFieldIterator;
Swift
func getDigitalSignatureFieldIterator() -> PTDigitalSignatureFieldIterator!
Return Value
An iterator that iterates over digital signature fields.
-
Retrieves the most restrictive document permissions locking level from all of the signed digital signatures in the document.
Declaration
Objective-C
- (PTDigitalSignatureFieldDocumentPermissions)GetDigitalSignaturePermissions;
Swift
func getDigitalSignaturePermissions() -> PTDigitalSignatureFieldDocumentPermissions
Return Value
An enumerated value representing the most restrictive document permission level found in the document.
-
Return Value
The class representing document information metadata. (i.e. entries in the document information dictionary).
-
PDFDocViewPrefs is a high-level utility class that can be used to control the way the document is to be presented on the screen or in print.
Declaration
Objective-C
- (PTPDFDocViewPrefs *)GetViewPrefs;
Swift
func getViewPrefs() -> PTPDFDocViewPrefs!
Return Value
Viewer preferences for this document.
-
Get the Action associated with the selected Doc Trigger event.
Declaration
Objective-C
- (PTObj *)GetTriggerAction:(PTPDFDocActionTriggerEvent)trigger;
Swift
func getTriggerAction(_ trigger: PTPDFDocActionTriggerEvent) -> PTObj!
Parameters
trigger
the type of trigger event to get
Return Value
the Action Obj if present, otherwise NULL
-
Call this function to determine whether the document has been modified since it was last saved.
Declaration
Objective-C
- (BOOL)IsModified;
Swift
func isModified() -> Bool
Return Value
- true if document was modified, false otherwise
-
Checks whether or not the underlying file has an XRef table that had to be repaired when the file was opened. If the document had an invalid XRef table when opened, PDFNet will have repaired the XRef table for its working representation of the document.
Note
- If this function returns true, it is not possible to incrementally save the document (see http://www.pdftron.com/kb_corrupt_xref)
Declaration
Objective-C
- (BOOL)HasRepairedXRef;
Swift
func hasRepairedXRef() -> Bool
Return Value
- true if document was found to be corrupted, and was repaired, during opening and has not been saved since.
-
Call this function to determine whether the document is represented in linearized (fast web view) format.
Note
any changes to the document can invalidate linearization. The function will return ‘true’ only if the original document is linearized and if it is not modified.
In order to provide good performance over relatively slow communication links, PDFNet can generate PDF documents with linearized objects and hint tables that can allow a PDF viewer application to download and view one page of a PDF file at a time, rather than requiring the entire file (including fonts and images) to be downloaded before any of it can be viewed.
To save a document in linearized (fast web view) format you only need to pass ‘Doc.SaveOptions.e_linearized’ flag in the Save method.
Declaration
Objective-C
- (BOOL)IsLinearized;
Swift
func isLinearized() -> Bool
Return Value
- true if document is stored in fast web view format, false otherwise.
-
Indicates whether this document was created via the
PDFViewCtrl
methodOpenURLAsync
.Declaration
Objective-C
- (BOOL)HasDownloader;
Swift
func hasDownloader() -> Bool
Return Value
True if the document was created via the
PDFViewCtrl
methodOpenURLAsync
; False otherwise. -
Returns the number of bytes that have been downloaded, when
HasDownloader()
is True.@exception if ‘HasDownloader()` returns False, calling this method will result in an exception.
Declaration
Objective-C
- (unsigned long long)GetDownloadedByteCount;
Swift
func getDownloadedByteCount() -> UInt64
Return Value
The number bytes downloaded.
-
Returns the document’s total size in bytes, when
HasDownloader()
is True.@exception if ‘HasDownloader()` returns False, calling this method will result in an exception.
Declaration
Objective-C
- (unsigned long long)GetTotalRemoteByteCount;
Swift
func getTotalRemoteByteCount() -> UInt64
Return Value
The total number of bytes in the remote document.
-
Saves the document to a file.
If a full save is requested to the original path, the file is saved to a file system-determined temporary file, the old file is deleted, and the temporary file is renamed to path.
A full save with remove unused or linearization option may re-arrange object in the cross reference table. Therefore all pointers and references to document objects and resources should be re acquired in order to continue document editing.
In order to use incremental save the specified path must match original path and e_incremental flag bit should be set.
@exception - if the file can’t be opened for saving or if there is a problem during Save an Exception object will be thrown.
Note
- Save will modify the PDFDoc object’s internal representation. As such, the user should acquire a write lock before calling save.
Note
- If the original pdf has a corrupt xref table (see HasRepairedXref), then it can not be saved using the e_incremental flag.
Declaration
Objective-C
- (void)SaveToFile:(NSString *)path flags:(unsigned int)flags;
Swift
func save(toFile path: String!, flags: UInt32)
Parameters
path
- The full path name to which the file is saved.
flags
- A bit field composed of an OR of SDFDoc::SaveOptions values.
-
Saves the document to a stream.
@exception - if there is a problem during Save an Exception object will be thrown.
Note
- Save will modify the PDFDoc object’s internal representation. As such, the user should acquire a write lock before calling save.
Note
- If the original pdf has a corrupt xref table (see HasRepairedXref), then it can not be saved using the e_incremental flag.
Declaration
Objective-C
- (NSData *)SaveToBuf:(unsigned int)flags;
Swift
func save(toBuf flags: UInt32) -> Data!
Parameters
stream
The output stream where to write data.
flags
- A bit field composed of an OR of the SDFDoc::SaveOptions values.
-
Saves a custom signature Contents to a document which has been prepared to receive it. No changes should be made to document in meantime.
@exception - if there is a problem during Save an Exception object will be thrown.
Declaration
Objective-C
- (void)SaveCustomSignatureToFile:(NSData *)in_signature in_field:(PTDigitalSignatureField *)in_field in_path:(NSString *)in_path;
Swift
func saveCustomSignature(toFile in_signature: Data!, in_field: PTDigitalSignatureField!, in_path: String!)
Parameters
in_signature
The signature Contents to write
in_field
The signature field to which to write
in_path
The full path name to which the file is saved.
-
Saves a custom signature Contents to a document which has been prepared to receive it. No changes should be made to document in meantime.
@exception - if there is a problem during Save an Exception object will be thrown.
Declaration
Objective-C
- (void)SaveCustomSignature:(NSData *)in_signature in_field:(PTDigitalSignatureField *)in_field out_stream:(PTFilter *)out_stream;
Swift
func saveCustomSignature(_ in_signature: Data!, in_field: PTDigitalSignatureField!, out_stream: PTFilter!)
Parameters
in_signature
The signature Contents to write
in_field
The signature field to which to write
out_stream
The output stream where to write data.
-
Use the Next() method on the returned iterator to traverse all pages in the document. For example:
PageIterator itr = pdfdoc.GetPageIterator(); while (itr.HasNext()) { // Read every page Page page = itr.Current(); // ... itr.Next() }
For full sample code, please take a look at ElementReader, PDFPageTest and PDFDraw sample projects.
Declaration
Objective-C
- (PTPageIterator *)GetPageIterator:(unsigned int)page_number;
Swift
func getPageIterator(_ page_number: UInt32) -> PTPageIterator!
Parameters
page_number
page to set the iterator on. 1 corresponds to the first page.
Return Value
an iterator to the first page in the document.
-
For example:
Page page = pdfdoc.GetPage(page_num); if (page == null) return; // Page not found
Declaration
Objective-C
- (PTPage *)GetPage:(unsigned int)page_number;
Swift
func getPage(_ page_number: UInt32) -> PTPage!
Parameters
page_number
- the page number in document’s page sequence. Page numbers in document’s page sequence are indexed from 1.
Return Value
a Page corresponding to a given page number, or null (invalid page) if the document does not contain the given page number.
-
Declaration
Objective-C
- (void)PageRemove:(PTPageIterator *)page_itr;
Swift
func pageRemove(_ page_itr: PTPageIterator!)
Parameters
page_itr
- the PageIterator to the page that should be removed A PageIterator for the given page can be obtained using PDFDoc::GetPageIterator(page_num) or using direct iteration through document’s page sequence.
-
Insert/Import a single page at a specific location in the page sequence.
Note
Invalidates all PageIterators pointing to the document.
Declaration
Objective-C
- (void)PageInsert:(PTPageIterator *)where page:(PTPage *)page;
Swift
func pageInsert(_ where: PTPageIterator!, page: PTPage!)
Parameters
where
- The location in the page sequence indicating where to insert the page. The page is inserted before the specified location.
page
- A page to insert.
-
Inserts a range of pages from specified PDFDoc
Declaration
Objective-C
- (void)InsertPages:(int)insert_before_page_number src_doc:(PTPDFDoc *)src_doc start_page:(int)start_page end_page:(int)end_page flag:(PTInsertFlag)flag;
Swift
func insertPages(_ insert_before_page_number: Int32, src_doc: PTPDFDoc!, start_page: Int32, end_page: Int32, flag: PTInsertFlag)
Parameters
insert_before_page_number
- the destination of the insertion. If less than or equal to 1, the pages are added to the beginning of the document. If larger than the number of pages in the destination document, the pages are appended to the document.
src_doc
- source PDFDoc to insert from
start_page
- start of the page number to insert
end_page
- end of the page number to insert
flag
- specifies insert options
progress
- A pointer to the progress interface. NULL if progress tracking is not required.
-
Inserts a range of pages from specified PDFDoc using PageSet
Declaration
Objective-C
- (void)InsertPagesWithPageSet:(int)insert_before_page_number src_doc:(PTPDFDoc *)src_doc source_page_set:(PTPageSet *)source_page_set flag:(PTInsertFlag)flag;
Swift
func insertPages(withPageSet insert_before_page_number: Int32, src_doc: PTPDFDoc!, source_page_set: PTPageSet!, flag: PTInsertFlag)
Parameters
insert_before_page_number
- the destination of the insertion. If less than or equal to 1, the pages are added to the beginning of the document. If larger than the number of pages in the destination document, the pages are appended to the document.
src_doc
- source PDFDoc to insert from
source_page_set
- a collection of the page number to insert
flag
- specifies insert options
progress
- A pointer to the progress interface. NULL if progress tracking is not required.
-
Moves a range of pages from specified PDFDoc. Pages are deleted from source document after move.
Note
MovePages function does not save src_doc. It merely delete pages in memeory. For permanent changes, PDFDoc::Save should be used to save src_doc after function exists.Declaration
Objective-C
- (void)MovePages:(int)move_before_page_number src_doc:(PTPDFDoc *)src_doc start_page:(int)start_page end_page:(int)end_page flag:(PTInsertFlag)flag;
Swift
func movePages(_ move_before_page_number: Int32, src_doc: PTPDFDoc!, start_page: Int32, end_page: Int32, flag: PTInsertFlag)
Parameters
move_before_page_number
- the destination of the move. If less than or equal to 1, the pages are moved to the beginning of the document. If larger than the number of pages in the destination document, the pages are moved to the end of the document.
src_doc
- source PDFDoc to move from
start_page
- start of the page number to move
end_page
- end of the page number to move
flag
- specifies insert options
progress
- A pointer to the progress interface. NULL if progress tracking is not required.
-
Moves a range of pages from specified PDFDoc. Pages are deleted from source document after move.
Note
MovePages function does not save src_doc. It merely delete pages in memeory. For permanent changes, PDFDoc::Save should be used to save src_doc after function exists.Declaration
Objective-C
- (void)MovePagesWithPageSet:(int)move_before_page_number src_doc:(PTPDFDoc *)src_doc source_page_set:(PTPageSet *)source_page_set flag:(PTInsertFlag)flag;
Swift
func movePages(withPageSet move_before_page_number: Int32, src_doc: PTPDFDoc!, source_page_set: PTPageSet!, flag: PTInsertFlag)
Parameters
move_before_page_number
- the destination of the move. If less than or equal to 1, the pages are moved to the beginning of the document. If larger than the number of pages in the destination document, the pages are moved to the end of the document.
src_doc
- source PDFDoc to move from
source_page_set
- a collection of the page number to move
flag
- specifies insert options
progress
- A pointer to the progress interface. NULL if progress tracking is not required.
-
The function imports a list of pages to this document. Although a list of pages can be imported using repeated calls to PageInsert(), PageImport will not import duplicate copies of resources that are shared across pages (such as fonts, images, colorspaces etc). Therefore this method is recommended when a page import list consists of several pages that share the same resources.
Declaration
Objective-C
- (PTVectorPage *)ImportPages:(PTVectorPage *)pages import_bookmarks:(BOOL)import_bookmarks;
Swift
func importPages(_ pages: PTVectorPage!, import_bookmarks: Bool) -> PTVectorPage!
Parameters
pages
A list of pages to import. All pages should belong to the same source document.
import_bookmarks
An optional flag specifying whether any bookmark items pointing to pages in the import list should be merged with the target (i.e. this) document.
Return Value
a list of imported pages. Note that imported pages are not placed in the document page sequence. This can be done using methods such as PageInsert(), PagePushBack(), etc.
-
Create a new, empty page in the document. You can use PageWriter to fill the page with new content. Finally the page should be inserted at specific place within document page sequence using PageInsert/PagePushFront/PagePushBack methods.
Note
the new page still does not belong to document page sequence and should be subsequently placed at a specific location within the sequence.
The following is a listing of some standard U.S. page sizes:
- Letter = Rect(0, 0, 612, 792)
- Legal = Rect(0, 0, 612, 1008)
- Ledger = Rect(0, 0, 1224, 792)
- Tabloid = Rect(0, 0, 792, 1224)
- Executive = Rect(0, 0, 522, 756)
The following is a listing of ISO standard page sizes:
- 4A0 = Rect(0, 0, 4768, 6741)
- 2A0 = Rect(0, 0, 3370, 4768)
- A0 = Rect(0, 0, 2384, 3370)
- A1 = Rect(0, 0, 1684, 2384)
- A2 = Rect(0, 0, 1191, 1684)
- A3 = Rect(0, 0, 842, 1191)
- A4 = Rect(0, 0, 595, 842)
- A5 = Rect(0, 0, 420, 595)
- A6 = Rect(0, 0, 298, 420)
- A7 = Rect(0, 0, 210, 298)
- A8 = Rect(0, 0, 147, 210)
- A9 = Rect(0, 0, 105, 147)
- A10 = Rect(0, 0, 74, 105)
- B0 = Rect(0, 0, 2835, 4008)
- B1 = Rect(0, 0, 2004, 2835)
- B2 = Rect(0, 0, 1417, 2004)
- B3 = Rect(0, 0, 1001, 1417)
- B4 = Rect(0, 0, 709, 1001)
- B5 = Rect(0, 0, 499, 709)
- B6 = Rect(0, 0, 354, 499)
- B7 = Rect(0, 0, 249, 354)
- B8 = Rect(0, 0, 176, 249)
- B9 = Rect(0, 0, 125, 176)
- B10 = Rect(0, 0, 88, 125)
- C0 = Rect(0, 0, 2599, 3677)
- C1 = Rect(0, 0, 1837, 2599)
- C2 = Rect(0, 0, 1298, 1837)
- C3 = Rect(0, 0, 918, 1298)
- C4 = Rect(0, 0, 649, 918)
- C5 = Rect(0, 0, 459, 649)
- C6 = Rect(0, 0, 323, 459)
- C7 = Rect(0, 0, 230, 323)
- C8 = Rect(0, 0, 162, 230)
- C9 = Rect(0, 0, 113, 162)
- C10 = Rect(0, 0, 79, 113)
Declaration
Parameters
media_box
A rectangle, expressed in default user space units, defining the boundaries of the physical medium on which the page is intended to be displayed or printed. A user space units is 1/72 of an inch. If media_box is not specified the default dimensions of the page are 8.5 x 11 inches (or 8.5*72, 11*72 units).
Return Value
A new, empty page.
-
Imports two external pages and highlights the differences between them. This function adds two new pages to the current document. The two input pages are typically coming from two different PDF files. Note: Each contiguous block of change is considered a single difference. A deletion immediately followed by an insertion is considered a single edit.
Declaration
Parameters
page1
is the before page, the basis of the comparison (read-only)
page2
is the after page, to which the basis is compared (read-only)
Return Value
the total number of differences found
-
Imports two external PDFs and highlights the differences between them. This function appends alternating pages from the two input documents into the current document. Note: Each contiguous block of change is considered a single difference. A deletion immediately followed by an insertion is considered a single edit.
Declaration
Objective-C
- (int)AppendTextDiffWithDoc:(PTPDFDoc *)doc1 doc2:(PTPDFDoc *)doc2;
Swift
func appendTextDiff(with doc1: PTPDFDoc!, doc2: PTPDFDoc!) -> Int32
Parameters
doc1
is the before document, the basis of the comparison (read-only)
doc2
is the after document, to which the basis is compared (read-only)
Return Value
the total number of differences found
-
Imports two external PDFs and highlights the differences between them. This function directly adds the highlights to the two input documents. Note: Each contiguous block of change is considered a single difference. A deletion immediately followed by an insertion is considered a single edit.
Declaration
Objective-C
+ (int)HighlightTextDiff:(PTPDFDoc *)doc1 doc2:(PTPDFDoc *)doc2 options:(PTTextDiffOptions *)options;
Swift
class func highlightTextDiff(_ doc1: PTPDFDoc!, doc2: PTPDFDoc!, options: PTTextDiffOptions!) -> Int32
Parameters
doc1
is the before document, the basis of the comparison
doc2
is the after document, to which the basis is compared
options
processing options (optional)
Return Value
the total number of differences found
-
Declaration
Objective-C
- (PTBookmark *)GetFirstBookmark;
Swift
func getFirstBookmark() -> PTBookmark!
Return Value
- the first Bookmark from the document’s outline tree. If the Bookmark tree is empty the underlying SDF/Cos Object is null and returned Bookmark is not valid (i.e. Bookmark::IsValid() returns false).
-
Adds/links the specified Bookmark to the root level of document’s outline tree.
Note
parameter ‘root_bookmark’ must not be linked (must not be belong) to a bookmark tree.Declaration
Objective-C
- (void)AddRootBookmark:(PTBookmark *)root_bookmark;
Swift
func addRootBookmark(_ root_bookmark: PTBookmark!)
Parameters
root_bookmark
Bookmark to Add/link
-
Declaration
Objective-C
- (int)GetPageCount;
Swift
func getPageCount() -> Int32
Return Value
the number of pages in the document.
-
An interactive form (sometimes referred to as an AcroForm) is a collection of fields for gathering information interactively from the user. A PDF document may contain any number of fields appearing on any combination of pages, all of which make up a single, global interactive form spanning the entire document.
The following methods are used to access and manipulate Interactive form fields (sometimes referred to as AcroForms).
The list of all Fields present in the document can be traversed as follows:
FieldIterator itr = pdfdoc.GetFieldIterator(); for(; itr.HasNext(); itr.Next()) { Field field = itr.Current(); Console.WriteLine("Field name: {0}", field.GetName()); }
For a sample, please refer to ‘InteractiveForms’ sample project.
Declaration
Objective-C
- (PTFieldIterator *)GetFieldIterator;
Swift
func getFieldIterator() -> PTFieldIterator!
Return Value
an iterator to the first Field in the document.
-
An interactive form (sometimes referred to as an AcroForm) is a collection of fields for gathering information interactively from the user. A PDF document may contain any number of fields appearing on any combination of pages, all of which make up a single, global interactive form spanning the entire document.
The following methods are used to access and manipulate Interactive form fields (sometimes referred to as AcroForms).
For a sample, please refer to ‘InteractiveForms’ sample project.
Declaration
Objective-C
- (PTFieldIterator *)GetFieldIteratorWithName:(NSString *)field_name;
Swift
func getFieldIterator(withName field_name: String!) -> PTFieldIterator!
Parameters
field_name
String representing the name of the field to get.
Return Value
an iterator to the Field in the document.
-
FieldIterator itr = pdfdoc.GetFieldIterator("name"); if (itr.HasNext()) { Console.WriteLine("Field name: {0}", itr.Current().GetName()); } else { ...field was not found... }
Declaration
Objective-C
- (PTField *)GetField:(NSString *)field_name;
Swift
func getField(_ field_name: String!) -> PTField!
Parameters
field_name
- a string representing the fully qualified name of the field (e.g. “employee.name.first”).
Return Value
a FieldIterator referring to an interactive Field or to invalid field if the field name was not found. If a given field name was not found itr.HasNext() will return false. For example:
-
Create a new interactive form Field.
@exception if ‘field_name’ is equal to an existing non-terminal field name an exception is thrown.
Declaration
Objective-C
- (PTField *)FieldCreateWithObj:(NSString *)field_name type:(PTFieldType)type field_value:(PTObj *)field_value def_field_value:(PTObj *)def_field_value;
Swift
func fieldCreate(withObj field_name: String!, type: PTFieldType, field_value: PTObj!, def_field_value: PTObj!) -> PTField!
Parameters
field_name
a string representing the fully qualified name of the field (e.g. “employee.name.first”). field_name must be either a unique name or equal to an existing terminal field name.
type
field type (e.g. Field::e_text, Field::e_button, etc.)
field_value
def_field_value
Return Value
the new form Field.
-
Create a new interactive form Field.
@exception if ‘field_name’ is equal to an existing non-terminal field name an exception is thrown.
Declaration
Objective-C
- (PTField *)FieldCreate:(NSString *)field_name type:(PTFieldType)type field_value:(PTObj *)field_value;
Swift
func fieldCreate(_ field_name: String!, type: PTFieldType, field_value: PTObj!) -> PTField!
Parameters
field_name
a string representing the fully qualified name of the field (e.g. “employee.name.first”). field_name must be either a unique name or equal to an existing terminal field name.
type
field type (e.g. Field::e_text, Field::e_button, etc.)
field_value
def_field_value
Return Value
the new form Field.
-
Undocumented
Declaration
Objective-C
- (PTField*)FieldCreateWithString: (NSString *)field_name type: (PTFieldType)type field_value: (NSString *)field_value def_field_value: (NSString *)def_field_value;
Swift
func fieldCreate(with field_name: String!, type: PTFieldType, field_value: String!, def_field_value: String!) -> PTField!
-
Regenerates the appearance stream for every widget annotation in the document Call this method if you modified field’s value and would like to update field’s appearances.
Declaration
Objective-C
- (void)RefreshFieldAppearances;
Swift
func refreshFieldAppearances()
-
Generates the appearance stream for annotations in the document using the specified options. A common use case is to generate appearances only for missing annotations, which can be accomplished using the default options.
Declaration
Objective-C
- (void)RefreshAnnotAppearances:(PTRefreshOptions *)options;
Swift
func refreshAnnotAppearances(_ options: PTRefreshOptions!)
Parameters
options
Options that can be used to adjust this generation process.
-
Flatten all annotations in the document.
Declaration
Objective-C
- (void)FlattenAnnotations:(BOOL)forms_only;
Swift
func flattenAnnotations(_ forms_only: Bool)
Parameters
forms_only
if false flatten all annotations, otherwise flatten only form fields.
-
Extract form data and/or annotations to FDF
Declaration
Objective-C
- (PTFDFDoc *)FDFExtract:(PTExtractFlag)flag;
Swift
func fdfExtract(_ flag: PTExtractFlag) -> PTFDFDoc!
Parameters
flag
- specifies extract options
Return Value
a pointer to the newly created FDF file with an interactive data.
-
Extract form data and/or annotations to FDF
Declaration
Objective-C
- (PTFDFDoc *)FDFExtractPages:(PTPageSet *)pages_to_extract flag:(PTExtractFlag)flag;
Swift
func fdfExtractPages(_ pages_to_extract: PTPageSet!, flag: PTExtractFlag) -> PTFDFDoc!
Parameters
pages_to_extract
The set of pages for which to extract interactive data.
flag
specifies extract options
Return Value
a pointer to the newly created FDF file with an interactive data.
-
Extract selected annotations to FDF
Declaration
Objective-C
- (PTFDFDoc *)FDFExtractAnnots:(PTVectorAnnot *)annotations;
Swift
func fdfExtractAnnots(_ annotations: PTVectorAnnot!) -> PTFDFDoc!
Parameters
annotations
the annotation(s) to extract
Return Value
a pointer to the newly created FDF file with the interactive data.
-
Extract annotations to FDF
Declaration
Objective-C
- (PTFDFDoc *)FDFExtractCommand:(PTVectorAnnot *)annot_added annot_modified:(PTVectorAnnot *)annot_modified annot_deleted:(PTVectorAnnot *)annot_deleted;
Swift
func fdfExtractCommand(_ annot_added: PTVectorAnnot!, annot_modified: PTVectorAnnot!, annot_deleted: PTVectorAnnot!) -> PTFDFDoc!
Parameters
annot_added
specifies the array of added annotations
annot_modified
specifies the array of modified annotations
annot_deleted
specifies the array of deleted annotations
Return Value
a pointer to the newly created FDF file with an interactive data.
-
Replace existing form and annotation data with those imported from the FDF file. It will make annotations in the FDF match those in the PDF. Since this method avoids updating annotations unnecessarily it works well with incremental save and can sometimes preserve annotation appearances, but it requires that the annotations intended to be in the final document be in the provided FDF file.
Note
Some PDF viewers (like Chrome) cannot display annotations that don’t already have an appearance, so it is often desirable to call PDFDoc.RefreshAnnotAppearances after this method to ensure these annotations can still be displayed in those applications.Note
This method is not suitable for realtime collaboration.Declaration
Objective-C
- (void)FDFUpdate:(PTFDFDoc *)fdf_doc;
Swift
func fdfUpdate(_ fdf_doc: PTFDFDoc!)
Parameters
fdf_doc
a pointer to the FDF file
-
Note
if the document does not nave associated action the returned Action will be null (i.e. Action.IsValid() returns false)
Return Value
Action that is triggered when the document is opened. The returned action can be either a destination or some other kind of Action (see Section 8.5, ‘Actions’ in PDF Reference Manual).
-
Sets the Action that will be triggered when the document is opened.
Declaration
Objective-C
- (void)SetOpenAction:(PTAction *)action;
Swift
func setOpen(_ action: PTAction!)
Parameters
action
A new Action that will be triggered when the document is opened. An example of such action is a GoTo Action that takes the user to a given location in the document.
-
Associates a file attachment with the document.
The file attachment will be displayed in the user interface of a viewer application (in Acrobat this is File Attachment tab). The function differs from Annot.CreateFileAttachment() because it associates the attachment with the whole document instead of an annotation on a specific page.
Note
Another way to associate a file attachment with the document is using SDF::NameTree:
SDF::NameTree names = SDF::NameTree::Create(doc, "EmbeddedFiles"); names.Put(file_key, file_keysz, embedded_file.GetSDFObj());
Declaration
Objective-C
- (void)AddFileAttachment:(NSString *)file_key embedded_file:(PTFileSpec *)embedded_file;
Swift
func addFileAttachment(_ file_key: String!, embedded_file: PTFileSpec!)
Parameters
file_key
A key/name under which the attachment will be stored.
embedded_file
Embedded file stream
-
Declaration
Objective-C
- (PTPageLabel *)GetPageLabel:(int)page_num;
Swift
func getPageLabel(_ page_num: Int32) -> PTPageLabel!
Parameters
page_num
The page number. Because PDFNet indexes pages starting from 1, page_num must be larger than 0.
Return Value
the PageLabel that is in effect for the given page. If there is no label object in effect, this method returns an invalid page label object.
-
Attaches a label to a page. This establishes the numbering scheme for that page and all following it, until another page label is encountered. This label allows PDF producers to define a page numbering system other than the default.
Declaration
Objective-C
- (void)SetPageLabel:(int)page_num label:(PTPageLabel *)label;
Swift
func setPageLabel(_ page_num: Int32, label: PTPageLabel!)
Parameters
page_num
The number of the page to label. If page_num is less than 1 or greater than the number of pages in the document, the method does nothing.
-
Removes the page label that is attached to the specified page, effectively merging the specified range with the previous page label sequence.
Declaration
Objective-C
- (void)RemovePageLabel:(int)page_num;
Swift
func removePageLabel(_ page_num: Int32)
Parameters
page_num
The page from which the page label is removed. Because PDFNet indexes pages starting from 1, page_num must be larger than 0.
-
Declaration
Objective-C
- (BOOL)IsTagged;
Swift
func isTagged() -> Bool
Return Value
true if this document is marked as Tagged PDF, false otherwise.
-
Declaration
Objective-C
- (BOOL)HasOC;
Swift
func hasOC() -> Bool
Return Value
true if the optional content (OC) feature is associated with the document. The document is considered to have optional content if there is an OCProperties dictionary in the document’s catalog, and that dictionary has one or more entries in the OCGs array.
-
Return Value
the Obj array that contains optional-content groups (OCGs) for the document, or NULL if the document does not contain any OCGs. The order of the groups is not guaranteed to be the creation order, and is not the same as the display order.
-
AddHighlights is used to highlight text in a document using ‘Adobe’s Highlight File Format’ (Technical Note #5172 ). The method will parse the character offset data and modify the current document by adding new highlight annotations.
@exception An exception will be thrown if the XML file is malformed or os out of sync with the document.
Declaration
Objective-C
- (void)AddHighlights:(NSString *)hilite;
Swift
func addHighlights(_ hilite: String!)
Parameters
hilite
a string representing the filename for the highlight file or or a data buffer containing XML data.
-
This method creates an SDF/Cos indirect name object
Unlike direct objects, indirect objects can be referenced by more than one object (i.e. indirect objects can be shared).
-
This method creates an SDF/Cos indirect array object
Unlike direct objects, indirect objects can be referenced by more than one object (i.e. indirect objects can be shared).
Return Value
Returns a new indirect array object.
-
This method creates an SDF/Cos indirect boolean object
Unlike direct objects, indirect objects can be referenced by more than one object (i.e. indirect objects can be shared).
Declaration
Objective-C
- (PTObj *)CreateIndirectBool:(BOOL)value;
Swift
func createIndirectBool(_ value: Bool) -> PTObj!
Parameters
value
the value with which to create the boolean object.
Return Value
Returns a new indirect boolean object.
-
This method creates an SDF/Cos indirect dict object
Unlike direct objects, indirect objects can be referenced by more than one object (i.e. indirect objects can be shared).
Return Value
Returns a new indirect dict object.
-
This method creates an SDF/Cos indirect null object
Unlike direct objects, indirect objects can be referenced by more than one object (i.e. indirect objects can be shared).
Return Value
Returns a new indirect null object.
-
This method creates an SDF/Cos indirect number object
Unlike direct objects, indirect objects can be referenced by more than one object (i.e. indirect objects can be shared).
Declaration
Objective-C
- (PTObj *)CreateIndirectNumber:(double)value;
Swift
func createIndirectNumber(_ value: Double) -> PTObj!
Parameters
value
the value with which to create the number object.
Return Value
Returns a new indirect number object.
-
This method creates an SDF/Cos indirect string object
Unlike direct objects, indirect objects can be referenced by more than one object (i.e. indirect objects can be shared).
Declaration
Objective-C
- (PTObj *)CreateIndirectString:(NSData *)value size:(unsigned int)size;
Swift
func createIndirectString(_ value: Data!, size: UInt32) -> PTObj!
Parameters
value
Unsigned char pointer with which to create the string object.
size
length of string.
Return Value
Returns a new indirect string object.
-
This method creates an SDF/Cos indirect stream object
Unlike direct objects, indirect objects can be referenced by more than one object (i.e. indirect objects can be shared).
Declaration
Objective-C
- (PTObj *)CreateIndirectStream:(PTFilterReader *)data filter_chain:(PTFilter *)filter_chain;
Swift
func createIndirectStream(_ data: PTFilterReader!, filter_chain: PTFilter!) -> PTObj!
Parameters
data
reference to a FilterReader object with which to create the stream object.
filter_chain
filter object with which to create the stream object. Defaults to Filters::Filter(0,false)
Return Value
Returns a new indirect stream object.
-
Locks the document to prevent competing threads from accessing the document at the same time. Threads attempting to access the document will wait in suspended state until the thread that owns the lock calls doc.Unlock().
Declaration
Objective-C
- (void)Lock;
Swift
func lock()
-
Removes the lock from the document.
Declaration
Objective-C
- (void)Unlock;
Swift
func unlock()
-
Try locking the document, waiting no longer than specified number of milliseconds.
Declaration
Objective-C
- (BOOL)TryLock:(int)milliseconds;
Swift
func tryLock(_ milliseconds: Int32) -> Bool
Parameters
milliseconds
- max number of milliseconds to wait for the document to lock
Return Value
true if the document is locked for multi-threaded access, false otherwise.
-
Locks the document to prevent competing write threads (using Lock()) from accessing the document at the same time. Other reader threads however, will be allowed to access the document. Threads attempting to obtain write access to the document will wait in suspended state until the thread that owns the lock calls doc.UnlockRead(). Note: To avoid deadlocks obtaining a write lock while holding a read lock is not permitted and will throw an exception. If this situation is encountered please either unlock the read lock before the write lock is obtained or acquire a write lock (rather than read lock) in the first place.
Declaration
Objective-C
- (void)LockRead;
Swift
func lockRead()
-
Removes the read lock from the document.
Declaration
Objective-C
- (void)UnlockRead;
Swift
func unlockRead()
-
Tries to obtain a read lock the document for
duration, and returns true if the lock was successfully acquired Declaration
Objective-C
- (BOOL)TryLockRead:(int)milliseconds;
Swift
func tryLockRead(_ milliseconds: Int32) -> Bool
Parameters
milliseconds
duration to obtain a read lock for.
Return Value
true if the document is locked for multi-threaded access, false otherwise.
-
Declaration
Objective-C
- (NSString *)GetFileName;
Swift
func getFileName() -> String!
Return Value
The filename of the document if the document is loaded from disk, or empty string if the document is not yet saved or is loaded from a memory buffer.
-
Generates thumbnail images for all the pages in this PDF document.
Declaration
Objective-C
- (void)GenerateThumbnails:(unsigned int)size;
Swift
func generateThumbnails(_ size: UInt32)
Parameters
size
The maximum dimension (width or height) that thumbnails will have.
-
Generates a PDF diff of the given pages by overlaying and blending them on top of each other.
Declaration
Objective-C
- (void)AppendVisualDiff:(PTPage *)p1 p2:(PTPage *)p2 opts:(PTDiffOptions *)opts;
Swift
func appendVisualDiff(_ p1: PTPage!, p2: PTPage!, opts: PTDiffOptions!)
Parameters
p1
one of the two pages for comparing.
p2
the other page for comparing.
opts
options for comparison results.
-
Applies optimizations to improve viewing speed and saves the document to the specified file. The main optimizations used are linearization and embedding thumbnails for the first page and any complex pages.
@exception if the file can’t be opened for saving or if there is a problem during Save an Exception object will be thrown.
Declaration
Objective-C
- (void)SaveViewerOptimized:(NSString *)path opts:(PTViewerOptimizedOptions *)opts;
Swift
func saveViewerOptimized(_ path: String!, opts: PTViewerOptimizedOptions!)
Parameters
path
The full path name to which the file is saved.
opts
The optimization options
-
Attempts to verify all signed cryptographic digital signatures in the document, ignoring unsigned signatures.
Declaration
Objective-C
- (PTSignaturesVerificationStatus)VerifySignedDigitalSignatures: (PTVerificationOptions *)in_opts;
Swift
func verifySignedDigitalSignatures(_ in_opts: PTVerificationOptions!) -> PTSignaturesVerificationStatus
Return Value
an enumeration value representing the state of the document’s signatures
-
Merge existing form and annotation data with those imported from the XFDF file. It will replace annotations from pdfdocument with matching annotations from XFDF. In order for the annotations to be considered matching, “name” of the xfdf annotation needs to match “NM” of that in pdf. XFDF annotations that don’t have a match in the pdf document will be added. For regular xfdf files, no deletions will be made This method also supports command form of xfdf, for those files, deletions will be performed for annotations in “delete” section Since this method avoids updating annotations unnecessarily it works well with incremental save. Note: This method is suitable for realtime collaboration.
Declaration
Objective-C
- (void)MergeXFDF:(PTFilter *)stream opts:(PTMergeXFDFOptions *)opts;
Swift
func mergeXFDF(_ stream: PTFilter!, opts: PTMergeXFDFOptions!)
Parameters
stream
- Input Filter which provides the xfdf contents
opts
- MergeXFDFOptions object for finer control @throws PDFNetException
-
Merge existing form and annotation data with those imported from the XFDF file. It will replace annotations from pdfdocument with matching annotations from XFDF. In order for the annotations to be considered matching, “name” of the xfdf annotation needs to match “NM” of that in pdf. XFDF annotations that don’t have a match in the pdf document will be added. For regular xfdf files, no deletions will be made This method also supports command form of xfdf, for those files, deletions will be performed for annotations in “delete” section Since this method avoids updating annotations unnecessarily it works well with incremental save. Note: This method is suitable for realtime collaboration.
Declaration
Objective-C
- (void)MergeXFDFWithString:(NSString *)xfdf opts:(PTMergeXFDFOptions *)opts;
Swift
func mergeXFDF(with xfdf: String!, opts: PTMergeXFDFOptions!)
Parameters
xfdf
- xfdf contents in string form or the path to the xfdf file
opts
- MergeXFDFOptions object for finer control @throws PDFNetException
-
Undocumented
Declaration
Objective-C
+ (PTPDFDoc*)CreateInternal: (unsigned long long)impl;
Swift
class func createInternal(_ impl: UInt64) -> PTPDFDoc!
-
Undocumented
Declaration
Objective-C
- (unsigned long long)GetHandleInternal;
Swift
func getHandleInternal() -> UInt64
-
Synchronously acquires a read lock for this
PTPDFDoc
instance and executes the given block on the current queue.Declaration
Objective-C
- (void)LockReadWithBlock:(nonnull void (^)(void))block;
Parameters
block
The block to perform.
-
Synchronously acquires a write lock for this
PTPDFDoc
instance and executes the given block.Simultaneous write access to a PTPDFDoc instance is not allowed. A write lock cannot be acquired if the thread already holds a read lock. Attempting to do so is an error.
Declaration
Objective-C
- (void)LockWithBlock:(nonnull void (^)(void))block;
Parameters
block
The block to perform.
-
Synchronously acquires a read lock for this
PTPDFDoc
instance and executes the given block on the current queue.Any
NSException
thrown while locking or unlocking the document, or executing the block, is converted into anNSError
object and returned in theerror
parameter.Note
In Swift, this method returns
Void
and is marked with thethrows
keyword to indicate that it throws an error in cases of failure.Declaration
Objective-C
- (BOOL)LockReadWithBlock:(nonnull void (^)(void))block error:(out NSError *_Nullable *_Nullable)outError;
Swift
func lockRead(_ block: () -> Void) throws
Parameters
block
The block to perform.
outError
On input, a pointer to an error object. If an error occurs (an
NSException
is thrown), this pointer is set to an actual error object containing the error information. You may specifynil
for this parameter if you do not want the error information.Return Value
YES
if the document could be locked and the block could be run successfully. If an error occurs (anNSException
is thrown), this method returnsNO
and assigns an appropriate error object to theerror
parameter. -
Synchronously acquires a write lock for this
PTPDFDoc
instance and executes the given block.Simultaneous write access to a PTPDFDoc instance is not allowed. A write lock cannot be acquired if the thread already holds a read lock. Attempting to do so is an error.
Any
NSException
thrown while locking or unlocking the document, or executing the block, is converted into anNSError
object and returned in theerror
parameter.Note
In Swift, this method returns
Void
and is marked with thethrows
keyword to indicate that it throws an error in cases of failure.Declaration
Objective-C
- (BOOL)LockWithBlock:(nonnull void (^)(void))block error:(out NSError *_Nullable *_Nullable)outError;
Swift
func lock(_ block: () -> Void) throws
Parameters
block
The block to perform.
outError
On input, a pointer to an error object. If an error occurs (an
NSException
is thrown), this pointer is set to an actual error object containing the error information. You may specifynil
for this parameter if you do not want the error information.Return Value
YES
if the document could be locked and the block could be run successfully. If an error occurs (anNSException
is thrown), this method returnsNO
and assigns an appropriate error object to theerror
parameter.
-
Enumerates through the pages in this document and calls the provided block for each page.
Note
This method requires a read-lock on the
PTPDFDoc
.Declaration
Objective-C
- (void)enumeratePagesWithBlock: (nonnull void (^)(unsigned int, PTPage *_Nonnull, BOOL *_Nonnull))block;
Swift
func enumeratePages() async -> (UInt32, PTPage, UnsafeMutablePointer<ObjCBool>)
Parameters
block
The block to be executed for each page in the document.
-
Enumerates through the pages in this document between the start and end page numbers and calls the provided block for each page.
Note
This method requires a read-lock on the
PTPDFDoc
.Declaration
Objective-C
- (void)enumeratePagesFromPageNumber:(unsigned int)startPageNumber toPageNumber:(unsigned int)endPageNumber withBlock:(nonnull void (^)(unsigned int, PTPage *_Nonnull, BOOL *_Nonnull))block;
Swift
func enumeratePages(fromPageNumber startPageNumber: UInt32, toPageNumber endPageNumber: UInt32, with block: (UInt32, PTPage, UnsafeMutablePointer<ObjCBool>) -> Void)
Parameters
block
The block to be executed for each page in the document.
-
Generates a new unique ID for the given annotation.
Note
This method requires a write-lock on the PTPDFDoc.
Declaration
Objective-C
- (void)GenerateUniqueIDForAnnotation:(nonnull PTAnnot *)annotation;
Swift
func generateUniqueID(forAnnotation annotation: PTAnnot)
Parameters
annotation
The annotation for which to generate and set a new unique identifier