ImportPDF

Imports an existing PDF document to a new PDF document.

To import

Use

An existing PDF document to the end of a new PDF document

Syntax 1

An existing PDF document to the end of a new PDF document and set a password

Syntax 2

An existing PDF document to a new PDF document before the specified position

Syntax 3

An existing PDF document to a new PDF document before the specified position and set a password

Syntax 4

Specified pages of an existing PDF document to a new PDF document before the specified position

Syntax 5

Specified pages of an existing PDF document to a new PDF document before the specified position and set a password

Syntax 6


Syntax 1: Importing an existing PDF document to the end of a new PDF document

Description

Imports an existing PDF document to a new PDF document. All pages are added to the end of the new PDF document.

Applies to

PDFDocument object

Syntax

objectname.ImportPDF (string fileName)

Argument

Description

objectname

The name of the PDFDocument object in which you want to import an existing PDF document to a new PDF document

fileName

The name of the PDF document to be imported (including the file path)


Return value

Long.

Returns 1 if the function succeeds and a negative value if an error occurs.

1 -- Success

-1 -- General error

-3 -- Invalid PDFDocument object

-4 -- Invalid PDFPage object

-13 -- The index is out of range

-15 -- Invalid PDFImportContent object

-16 -- The start index is out of range

-17 -- Invalid index range

-19 -- Invalid file name

-22 -- Invalid password. The master password and the user password cannot be empty, and they cannot be the same.

-23 -- Invalid PDFDocumentProperties object

-24 -- Invalid handle of PDFlib

-25 -- An exception occurred while executing the PDFlib operation

-26 -- Failed to open the PDF document

-27 -- Failed to create the PDF document

-32 -- The PDF object does not exist

-33 -- The object already has its owner

-34 -- The ReadOnly object is not allowed to be modified

Examples

This statement imports all pages of the PDF document standard_none.pdf and saves the contents to a new PDF document called importpdf.pdf.

PDFDocument lpdf_doc
long ll_return,ll_return1

lpdf_doc = Create PDFDocument

ll_return = lpdf_doc.importpdf( "D:\standard_none.pdf")
ll_return1 = lpdf_doc.save( "D:\importpdf.pdf")

destroy lpdf_doc

See also

ImportDataWindow

Save

Syntax 2: Importing an existing PDF document to the end of a new PDF document and setting a password

Description

Imports an existing PDF document to a new PDF document. All pages are added to the end of the new PDF document. The master password is set when importing the PDF document.

Applies to

PDFDocument object

Syntax

objectname.ImportPDF (string fileName, string masterPassword)

Argument

Description

objectname

The name of the PDFDocument object in which you want to import an existing PDF document to a new PDF document

fileName

The name of the PDF document to be imported (including the file path)

masterPassword

The master password of the imported PDF document to be set


Return value

Long.

Returns 1 if the function succeeds and a negative value if an error occurs.

1 -- Success

-1 -- General error

-3 -- Invalid PDFDocument object

-4 -- Invalid PDFPage object

-13 -- The index is out of range

-15 -- Invalid PDFImportContent object

-16 -- The start index is out of range

-17 -- Invalid index range

-19 -- Invalid file name

-22 -- Invalid password. The master password and the user password cannot be empty, and they cannot be the same.

-23 -- Invalid PDFDocumentProperties object

-24 -- Invalid handle of PDFlib

-25 -- An exception occurred while executing the PDFlib operation

-26 -- Failed to open the PDF document

-27 -- Failed to create the PDF document

-32 -- The PDF object does not exist

-33 -- The object already has its owner

-34 -- The ReadOnly object is not allowed to be modified

Example 1

This statement imports all pages of the PDF document noannotsPwd.pdf, sets the master password and saves the contents to a new PDF document called importpdfpwd.pdf.

PDFDocument lpdf_doc
long ll_return,ll_return1

lpdf_doc = Create PDFDocument

ll_return = lpdf_doc.importpdf( "D:\noannotsPwd.pdf","appeon")
ll_return1 = lpdf_doc.save( "D:\importpdfpwd.pdf")

destroy lpdf_doc

See also

ImportDataWindow

Save

Syntax 3: Importing an existing PDF document to a new PDF document before the specified position

Description

Imports an existing PDF document to a new PDF document. All pages are inserted before the specified position of a new PDF document, and if the index of the specified position is out of range, the pages are added to the end.

Applies to

PDFDocument object

Syntax

objectname.ImportPDF (string fileName, long targetIndex)

Argument

Description

objectname

The name of the PDFDocument object in which you want to import an existing PDF document to a new PDF document

fileName

The name of the PDF document to be imported (including the file path)

targetIndex

The target index of a new PDF document before which you want to import all pages of the existing PDF document


Return value

Long.

Returns 1 if the function succeeds and a negative value if an error occurs.

1 -- Success

-1 -- General error

-3 -- Invalid PDFDocument object

-4 -- Invalid PDFPage object

-13 -- The index is out of range

-15 -- Invalid PDFImportContent object

-16 -- The start index is out of range

-17 -- Invalid index range

-19 -- Invalid file name

-22 -- Invalid password. The master password and the user password cannot be empty, and they cannot be the same.

-23 -- Invalid PDFDocumentProperties object

-24 -- Invalid handle of PDFlib

-25 -- An exception occurred while executing the PDFlib operation

-26 -- Failed to open the PDF document

-27 -- Failed to create the PDF document

-32 -- The PDF object does not exist

-33 -- The object already has its owner

-34 -- The ReadOnly object is not allowed to be modified

Examples

This statement imports all pages of the PDF document noannotsnoPwd.pdf before the first page of a new PDF document and saves the document as importpdf1.pdf.

PDFDocument lpdf_doc
long ll_return,ll_return1

lpdf_doc = Create PDFDocument

ll_return = lpdf_doc.importpdf( "D:\noannotsnoPwd.pdf",1)
ll_return1 = lpdf_doc.save( "D:\importpdf1.pdf")

destroy lpdf_doc

See also

ImportDataWindow

Save

Syntax 4: Importing an existing PDF document to a new PDF document before the specified position and setting a password

Description

Imports an existing PDF document to a new PDF document. All pages are inserted before the specified position of a new PDF document, and if the index of the specified position is out of range, the pages are added to the end. The master password is set when importing the PDF document.

Applies to

PDFDocument object

Syntax

objectname.ImportPDF (string fileName, long targetIndex, string masterPassword)

Argument

Description

objectname

The name of the PDFDocument object in which you want to import an existing PDF document to a new PDF document

fileName

The name of the PDF document to be imported (including the file path)

targetIndex

The target index of a new PDF document before which you want to import all pages of the existing PDF document

masterPassword

The master password of the imported PDF document to be set


Return value

Long.

Returns 1 if the function succeeds and a negative value if an error occurs.

1 -- Success

-1 -- General error

-3 -- Invalid PDFDocument object

-4 -- Invalid PDFPage object

-13 -- The index is out of range

-15 -- Invalid PDFImportContent object

-16 -- The start index is out of range

-17 -- Invalid index range

-19 -- Invalid file name

-22 -- Invalid password. The master password and the user password cannot be empty, and they cannot be the same.

-23 -- Invalid PDFDocumentProperties object

-24 -- Invalid handle of PDFlib

-25 -- An exception occurred while executing the PDFlib operation

-26 -- Failed to open the PDF document

-27 -- Failed to create the PDF document

-32 -- The PDF object does not exist

-33 -- The object already has its owner

-34 -- The ReadOnly object is not allowed to be modified

Examples

This statement imports all pages of the PDF document noannotsPwd.pdf before the first page of a new PDF document, sets the master password and saves the document as importpdf3.pdf.

PDFDocument lpdf_doc
long ll_return,ll_return1

lpdf_doc = Create PDFDocument

ll_return = lpdf_doc.importpdf( "D:\noannotsPwd.pdf",1,"appeon")
ll_return1 = lpdf_doc.save( "D:\importpdf3.pdf")

destroy lpdf_doc

See also

ImportDataWindow

Save

Syntax 5: Importing specified pages of an existing PDF document to a new PDF document before the specified position

Description

Imports an existing PDF document to a new PDF document. The specified pages of the PDF document are inserted before the specified position of a new PDF document, and if the index of the specified position is out of range, the specified pages are added to the end.

Applies to

PDFDocument object

Syntax

objectname.ImportPDF (string fileName, long startSourceIndex, long endSourceIndex, long targetIndex)

Argument

Description

objectname

The name of the PDFDocument object in which you want to import an existing PDF document to a new PDF document

fileName

The name of the PDF document to be imported (including the file path)

startSourceIndex

The start index of the existing PDF document to be specified

endSourceIndex

The end index of the existing PDF document to be specified

targetIndex

The target index of a new PDF document before which you want to import the specified pages of the existing PDF document


Return value

Long.

Returns 1 if the function succeeds and a negative value if an error occurs.

1 -- Success

-1 -- General error

-3 -- Invalid PDFDocument object

-4 -- Invalid PDFPage object

-13 -- The index is out of range

-15 -- Invalid PDFImportContent object

-16 -- The start index is out of range

-17 -- Invalid index range

-19 -- Invalid file name

-22 -- Invalid password. The master password and the user password cannot be empty, and they cannot be the same.

-23 -- Invalid PDFDocumentProperties object

-24 -- Invalid handle of PDFlib

-25 -- An exception occurred while executing the PDFlib operation

-26 -- Failed to open the PDF document

-27 -- Failed to create the PDF document

-32 -- The PDF object does not exist

-33 -- The object already has its owner

-34 -- The ReadOnly object is not allowed to be modified

Examples

This statement imports page 1 of the PDF document noannotsnoPwd.pdf before the first page of a new PDF document and saves the document as importpdf4.pdf.

PDFDocument lpdf_doc
long ll_return,ll_return1

lpdf_doc = Create PDFDocument

ll_return = lpdf_doc.importpdf( "D:\noannotsnoPwd.pdf",1,1,1)
ll_return1 = lpdf_doc.save( "D:\importpdf4.pdf")

destroy lpdf_doc

See also

ImportDataWindow

Save

Syntax 6: Importing specified pages of an existing PDF document to a new PDF document before the specified position and setting a password

Description

Imports an existing PDF document to a new PDF document. The specified pages of the PDF document are inserted before the specified position of a new PDF document, and if the index of the specified position is out of range, the specified pages are added to the end. The master password is set when importing the PDF document.

Applies to

PDFDocument object

Syntax

objectname.ImportPDF (String fileName, long startSourceIndex, long endSourceIndex, long targetIndex, string masterPassword)

Argument

Description

objectname

The name of the PDFDocument object in which you want to import an existing PDF document to a new PDF document

fileName

The name of the PDF document to be imported (including the file path)

startSourceIndex

The start index of the existing PDF document to be specified

endSourceIndex

The end index of the existing PDF document to be specified

targetIndex

The target index of a new PDF document before which you want to import the specified pages of the existing PDF document

masterPassword

The master password of the imported PDF document to be set


Return value

Long.

Returns 1 if the function succeeds and a negative value if an error occurs.

1 -- Success

-1 -- General error

-3 -- Invalid PDFDocument object

-4 -- Invalid PDFPage object

-13 -- The index is out of range

-15 -- Invalid PDFImportContent object

-16 -- The start index is out of range

-17 -- Invalid index range

-19 -- Invalid file name

-22 -- Invalid password. The master password and the user password cannot be empty, and they cannot be the same.

-23 -- Invalid PDFDocumentProperties object

-24 -- Invalid handle of PDFlib

-25 -- An exception occurred while executing the PDFlib operation

-26 -- Failed to open the PDF document

-27 -- Failed to create the PDF document

-32 -- The PDF object does not exist

-33 -- The object already has its owner

-34 -- The ReadOnly object is not allowed to be modified

Examples

This statement imports page 1 of the PDF document noannotsPwd.pdf before the first page of a new PDF document, sets the master password and saves the document as importpdf4.pdf.

PDFDocument lpdf_doc
long ll_return,ll_return1

lpdf_doc = Create PDFDocument

ll_return = lpdf_doc.importpdf( "D:\noannotsPwd.pdf",1,1,1,"appeon")
ll_return1 = lpdf_doc.save( "D:\importpdf4.pdf")

destroy lpdf_doc

See also

ImportDataWindow

Save