PDFFileEx¶
Namespace: O2S.Components.PDF4NET.Core
The PDFFileEx class extends the PDFFile class with file update capabilities.
Inheritance Object → PDFFile → PDFFileEx
Remarks
The PDFFileEx class allows to load the entire PDF file and perform changes but without the overhead addded by PDFFixedDocument class. The updated file can be saved back to file or stream.
Constructors¶
PDFFileEx(String, String)¶
Initializes a new PDFFileEx object from a PDF file.
Parameters
fileName String
Path to the PDF file.
password String
Password for decrypting the PDF file.
PDFFileEx(Stream, String)¶
Initializes a new PDFFileEx object from a stream.
Parameters
stream Stream
Stream with the PDF file.
password String
Password for decrypting the PDF file.
Remarks
The 'stream' after the constructor executed can be disposed as the whole file has been loaded.
Properties¶
PageCount¶
Gets the number of pages.
Property Value
Int32
The number of pages in the PDF file.
SecurityHandler¶
Gets the file security handler.
Property Value
PDFSecurityHandler
The security handler that was used to encrypt the PDF file.
Methods¶
FlattenFormFields()¶
Flattens the form fields in the file.
GetPageCanvas(Int32, PDFPageCanvasPosition)¶
Gets the page canvas for the specified page.
Parameters
pageNumber Int32
The page number for which the canvas surface should be retrieved.
pageCanvasPosition PDFPageCanvasPosition
The position of page canvas, under or on top of existing page content.
Returns
PDFPageCanvas
A PDFPageCanvas object that allows to draw on page surface.
GetPageCosDictionary(Int32)¶
Gets the COS dictionary representing the specified page.
Parameters
pageNumber Int32
The page number for which to retrieve the COS dictionary.
Returns
PDFCosDictionary
The COS dictionary of the specified page.
Exceptions
ArgumentOutOfRangeException
Thrown when pageNumber is less than 0 or greater then or equal to PDFFile.PageCount.
GetPageNumberForFieldWidget(String, Int32)¶
Gets the number of the page that includes the specified field widget.
Parameters
fieldName String
The field that owns the widget.
widgetIndex Int32
Index of the widget.
Returns
Int32
The number of the page that includes the specified field widget or -1 if the field name is invalid.
GetPositionForFieldWidget(String, Int32)¶
Gets the position on the page for the specified field widget.
Parameters
fieldName String
The field that owns the widget.
widgetIndex Int32
Index of the widget.
Returns
PDFDisplayRectangle
A PDFDisplayRectangle specifying the position of the widget on the page.
Save(String, PDFSecurityHandler, Boolean)¶
Saves the PDF file to disk.
Parameters
fileName String
Path where the PDF file will be saved.
securityHandler PDFSecurityHandler
Security handler for encrypting the merged file.
enableObjectCompression Boolean
True if the merged file should compress the PDF file structure.
Save(Stream, PDFSecurityHandler, Boolean)¶
Saves the PDF file to given stream.
Parameters
output Stream
Stream where the PDF file will be saved.
securityHandler PDFSecurityHandler
Security handler for encrypting the merged file.
enableObjectCompression Boolean
True if the merged file should compress the PDF file structure.
SetFieldValue(String, Object)¶
Sets the given field with the specified value.
Parameters
fieldName String
Field to set
value Object
Value to set on the field.
Remarks
If the 'fieldName' does not exist nothing happens.
SetFormFillOptions(PDFFormFillOptions)¶
Sets the options for filling form fields.
Parameters
options PDFFormFillOptions
Options for filling form fields.