ImportPDF

Description

Creates a reference to the PDF document to be imported. The "reference" points to the location of the document. The document will not be imported until the Save function is executed.

Applies to

PDFDocument object

Syntax

long ImportPDF(string fileName)
long ImportPDF(string fileName, long targetIndex)
long ImportPDF(string fileName, string masterPassword)
long ImportPDF(string fileName, long targetIndex, string masterPassword)
long ImportPDF(string fileName, long startSourceIndex, long endSourceIndex, long targetIndex)
long ImportPDF(string fileName, long startSourceIndex, long endSourceIndex, long targetIndex, string masterPassword) 

Argument

Description

fileName

The name of the PDF document to be imported.

targetIndex The page index at which to insert the PDF document. If not specified, the content will be inserted to the end of the document.
masterPassword If required, the master password required by the PDF document that will be imported.
startSourceIndex The page index from which to start the import of the content of the PDF document.
endSourceIndex The ending page at which to end the import of the content of the PDF document.

Return value

Long. Returns 1 if it succeeds and -1 if it fails. For more errors, see the Error Codes.

Usage

Unlike ImportDataWindow and ImportRichTextEdit functions which will import the content to a temporary PDF file, the ImportPDF function does not import the PDF document to any form of temporary files; instead it creates a reference that points to the location of the specified PDF document (source document). The source document will be imported to the current PDF document (target document) when the Save function is executed. Therefore, to import the PDF document via ImportPDF successfully, you will need to make sure the source document exists and stays valid till after Save is executed.

Note

  • The source document and target document must follow the same standard (for example, "PDF_None!"). Otherwise, the imported PDF will show as blank pages.

  • After importing a PDF document with form fields (such as checkbox, combobox, listbox, radiobutton, signature, and textfield) into a target document, it is not possible to import another PDF document that also contains form fields. The function will throw an error.

Examples

The following example inserts the PDF file content to the end of the document:

PDFdocument lpdf_doc
lpdf_doc = create PDFdocument

//Import the PDF content
lpdf_doc.importpdf("D:\import\testdocument.pdf")
lpdf_doc.save( "D:\save\importcomplete.pdf")

See also

AddPage

Clone

GetPage

GetPageCount

GetTableOfContents

ImportDataWindow

ImportRichTextEdit

IndexOf

InsertPage

RemovePage

Save

SearchObject

SetTableOfContents