Represents a PDF document and can be used to parse an existing PDF document.
// Load an existing PDF document
let document: PdfDocument = new PdfDocument(data);
// Access first page
let page: PdfPage = document.getPage(0);
// Flatten annotations and form fields
document.flatten = true;
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();
PdfBookmarkBase
Gets the bookmarks (Read only).
PdfFileStructure
Gets the internal structure of the PDF document.
boolean
Gets the boolean flag to flatten the annotations and form fields.
PdfForm
Gets the PDF form fields included in the document (Read only).
boolean
Gets a value indicating whether the document is encrypted. (Read Only).
boolean
Gets a value indicating whether the document is decrypted using the user password. (Read only).
PdfLayerCollection
Gets the collection of PdfLayer
from the document.
number
Gets the page count (Read only).
PdfPermissionFlag
Gets the permission flag of the PDF document (Read only).
Creates a new page with default page settings and adds it to the collection.
Returns PdfPage
Creates a new page with default settings and inserts it into the collection at the specified page index.
Parameter | Type | Description |
---|---|---|
index | number |
Page index. |
Returns PdfPage
Creates a new page with specified page settings and adds it to the collection.
Parameter | Type | Description |
---|---|---|
pageSettings | PdfPageSettings |
Page settings. |
Returns PdfPage
Creates a new page with specified page settings and inserts it into the collection at the specified page index.
Parameter | Type | Description |
---|---|---|
index | number |
Page index. |
pageSettings | PdfPageSettings |
Page settings. |
Returns PdfPage
Creates a new section with default page settings.
Returns PdfSection
Creates a new section with custom page settings.
Parameter | Type | Description |
---|---|---|
settings | PdfPageSettings |
Settings of the section. |
Returns PdfSection
Disposes the current instance of PdfDocument
class.
Returns void
Exports the annotations from the PDF document.
Returns Uint8Array
Exports the annotations from the PDF document.
Parameter | Type | Description |
---|---|---|
settings | PdfAnnotationExportSettings |
Annotation export settings. |
Returns Uint8Array
Exports the annotations from the PDF document.
Parameter | Type | Description |
---|---|---|
filename | string |
Output file name. |
Returns void
Exports the annotations from the PDF document.
Parameter | Type | Description |
---|---|---|
filename | string |
Output file name. |
settings | PdfAnnotationExportSettings |
Annotation export settings. |
Returns void
Exports the form data from the PDF document.
Returns Uint8Array
Exports the form data from the PDF document.
Parameter | Type | Description |
---|---|---|
settings | PdfFormFieldExportSettings |
Form field export settings. |
Returns Uint8Array
Exports the form data from the PDF document.
Parameter | Type | Description |
---|---|---|
filename | string |
Output file name. |
Returns void
Exports the form data from the PDF document.
Parameter | Type | Description |
---|---|---|
filename | string |
Output file name. |
settings | PdfFormFieldExportSettings |
Form field export settings. |
Returns void
Gets the PdfPage
at the specified index.
Parameter | Type | Description |
---|---|---|
pageIndex | number |
Page index. |
Returns PdfPage
Imports the annotations from the PDF document.
Parameter | Type | Description |
---|---|---|
data | string |
annotations data as base64 string. |
dataFormat | DataFormat |
Data format of the input data. |
Returns void
Imports the annotations from the PDF document.
Parameter | Type | Description |
---|---|---|
data | Uint8Array |
annotations data as byte array. |
dataFormat | DataFormat |
Data format of the input data. |
Returns void
Imports the form data from the PDF document.
Parameter | Type | Description |
---|---|---|
data | string |
Form data as base64 string. |
dataFormat | DataFormat |
Data format of the input data. |
Returns void
Imports the form data from the PDF document.
Parameter | Type | Description |
---|---|---|
data | Uint8Array |
Form data as byte array. |
dataFormat | DataFormat |
Data format of the input data. |
Returns void
Copy the specific page and insert it as the next page
Returns void
Copy the specific page and insert it at the specified target page index and page rotation.
Returns void
Import the specified page into the current document pages collection as the last page
Parameter | Type | Description |
---|---|---|
page | PdfPage |
Page to import. |
sourceDocument | PdfDocument |
PDF document to get pages to import. |
Returns void
Create a new page with default settings and insert it into the collection at the specified page index.
Parameter | Type | Description |
---|---|---|
page | PdfPage |
Page to import. |
sourceDocument | PdfDocument |
PDF document to get pages to import. |
options (optional) | PdfPageImportOptions |
Options to customize the support of import PDF pages. |
Returns void
Import the pages specified by the start and end index into the current document’s pages collection.
Parameter | Type | Description |
---|---|---|
sourceDocument | PdfDocument |
PDF document to get pages to import. |
startIndex | number |
Start page index. The default value is 0. |
endIndex | number |
End page index. The default value is the index of the last page in the source document. |
Returns void
Import the pages specified by start and end index into the current document’s pages collection.
Parameter | Type | Description |
---|---|---|
sourceDocument | PdfDocument |
PDF document to get pages to import. |
startIndex | number |
Start page index. The default value is 0. |
endIndex | number |
End page index. The default value is the index of the last page in the source document. |
options (optional) | PdfPageImportOptions |
Options to customize the support of import PDF pages. |
Returns void
Removes the specified page.
Parameter | Type | Description |
---|---|---|
page | PdfPage |
The page to remove.typescript<br>// Load an existing PDF document<br>let document: PdfDocument = new PdfDocument(data, password);<br>// Access the first page<br>let page: PdfPage = document.getPage(0);<br>// Removes the specified page<br>document.removePage(page);<br>// Save the document<br>document.save('output.pdf');<br>// Destroy the document<br>document.destroy();<br> |
Returns void
Removes the page from the specified index.
Parameter | Type | Description |
---|---|---|
index | number |
The page index to remove.typescript<br>// Load an existing PDF document<br>let document: PdfDocument = new PdfDocument(data, password);<br>// Removes the first page<br>document.removePage(0);<br>// Save the document<br>document.save('output.pdf');<br>// Destroy the document<br>document.destroy();<br> |
Returns void
Reorders the pages in the PDF document.
Parameter | Type | Description |
---|---|---|
orderArray | number[] |
The page sequence to arrange the pages. |
Returns void
Saves the modified document.
Returns Uint8Array
Saves the modified document to the specified filename.
Parameter | Type | Description |
---|---|---|
filename | string |
Specifies the filename to save the output pdf document.typescript<br>// Load an existing PDF document<br>let document: PdfDocument = new PdfDocument(data, password);<br>// Save the document<br>document.save('Output.pdf');<br>// Destroy the document<br>document.destroy();<br> |
Returns void
Saves the document to the specified output stream and return the stream as Blob.
Returns Promise
Splitting a PDF file into individual pages.
Returns void
Splits the PDF document into parts, each containing a maximum number of pages specified.
Parameter | Type | Description |
---|---|---|
fixedNumber | number |
specifies the maximum number of pages in each split PDF. The default value is 1. |
Returns void
Splits the PDF document into multiple parts based on the specified page ranges.
Parameter | Type | Description |
---|---|---|
ranges | number[][] |
The two dimensional number array specified for start and end page indexes to split PDF documents. |
Returns void