PDF - Insert

Declaration

<AMPDF ACTIVITY="insert" SESSION="text" SOURCE="text" PASSWORD="text (encrypted)" SAVETYPE="text (options)" DESTINATION="text" PDFDOCUMENTFROM="text (options)" NEWPDF="text" OVERWRITE="YES/NO" CREATEEMPTY="YES/NO"  LOCATION="number" SOURCETYPE="text (options)" EXTRACTPDF="text" INSERTPASSWORD="text (encrypted)" IMAGEFILE="text" ISFITINTOPAGE="YES/NO" PAGE="number" />

Related Topics

Description

Inserts pages into a PDF file, sourced from extracted pages from another PDF file or an image file.

Practical usage

Used to add images to a PDF file or concatenate PDF files.

Parameters

Resource

Property Type Required Default Markup Description
Resource --- --- --- --- Specifies the source of the PDF file. The available options are:
  • File (default) - The source derives from a PDF file located on the system. This option is normally selected if only a single activity is required to complete the operation.
  • Session - The source PDF is obtained from a pre-configured session created in an earlier step with the use of the PDF - Create session activity. This option is normally selected if a combination of related activities is required to complete an operation. Consolidating several activities to a single session can eliminate redundancy. Moreover, a single task supports multi-session executions which can improve efficiency and speed up production.
NOTE: This parameter does not contain markup and is only displayed in visual mode for task construction and configuration purposes.
Session Text Yes, if Resource is set to Session PDFSession1 SESSION="mySession" The existing session to associate with this activity. This parameter becomes active and is required if the Resource parameter is set to Session.
Use Text (options) Yes, if Resource is set to File Existing PDF
  • PDFDOCUMENTFROM="existing_file"
  • PDFDOCUMENTFROM="new_file"
Specifies whether to insert pages into an existing or newly-created PDF file.  This parameter becomes active and is required if the Resource parameter is set to File. The available options are:
  • Existing PDF (default) - Pages are inserted into an existing PDF file.
  • New PDF - Pages are inserted into a newly-created PDF file.
Source PDF Text Yes, if Use is set to Existing PDF (Empty) SOURCE="C:\PDFFileName.pdf" The PDF path and file name of where to insert pages. This parameter becomes active and is required if the Use parameter is set to Existing PDF.
Password (optional) Text No (Empty) PASSWORD="encrypted" The password required to open the existing PDF file (if required). This parameter becomes active if the Use parameter is set to Existing PDF.
On completion Text (options) Yes, if Use is set to Existing PDF Save
  • SAVETYPE="save"
  • SAVETYPE="do_not_save"
  • SAVETYPE="save_as"
Specifies how changes to the PDF file are saved upon completion of this activity. This parameter becomes active and is required if the Use parameter is set to Existing PDF. The available options are:
  • Save (default) - Changes are saved under the PDF file's original file name.
  • Do not save changes - Any changes made to the existing PDF file are not saved.
  • Save As - Changes are saved to a new path and file name.
Destination PDF Text Yes, if On completion is set to Save as (Empty) DESTINATION="C:\PDFFileName.pdf" The path and file name where the modified existing PDF file is stored. This parameter becomes active and is required if the On completion parameter is set to Save as.
New PDF Text Yes, if Use is set to New PDF (Empty) NEWPDF="C:\PDFFileName.pdf" The path and file name where the newly-generated PDF file is stored. This parameter becomes active and is required if the Use parameter is set to New PDF.
Overwrite if PDF already exists Yes/No No No OVERWRITE="YES" If selected, a PDF file with the same filename in the destination folder is overwritten when this activity runs. If disabled (default), a PDF file with the same filename in the destination folder is not overwritten, however, a runtime error occurs as a result.
Create empty PDF file Yes/No No No CREATEEMPTY="YES" If selected, the activity creates an empty, single-page PDF file. This parameter becomes active if the Use parameter is set to New PDF.

Data

Property Type Required Default Markup Description
Type Text (options) Yes PDF SOURCETYPE="image" The type of data to insert into a new or existing PDF file. The available options are:
  • PDF (default) - Extracts and inserts pages from an existing or new PDF file.
  • Image - Inserts the specified image into the PDF file.
PDF Text Yes, if Type is set to PDF (Empty) EXTRACTPDF="C:\temp\source.pdf" The PDF path and file name of where to extract the pages. This parameter becomes active and is required if the Type parameter is set to PDF.
Password (optional) Text No (Empty) INSERTPASSWORD="AM5/WnwXFn7cFRyKCmf/d1l0Q==aME" The password required to open the source PDF file (if required).
Image Text Yes, if Type is set to Image (Empty) IMAGEFILE="C:\temp\source.png" Specifies the path and file name of the source image to insert into the PDF file. Supported image formats are JPEG, TIFF, PNG, and BMP. This parameter becomes active and is required if the Type parameter is set to Image.
Fit into page size Yes/No No No ISFITINTOPAGE="YES" If selected, the source image will be resized to fit into the PDF page specified in the Insert at page parameter. If disabled, the source image will not be resized and, depending on its size, may not fit into the PDF page correctly. This parameter becomes active if the Type parameter is set to PDF.
Extract page range --- Yes All --- Specifies the pages to extract content from the source PDF file. The available options are:
  • All - Extracts content from all pages in the PDF file.
  • Page(s) - Extracts content from one or more specific pages in the PDF file.
NOTE: This parameter does not contain markup and is only displayed in visual mode for task construction and configuration purposes
Extract page(s) Number Yes, if Extract page range is set to Extract page(s) (Empty)

PAGE="1,3,5"

If selected, specifies the pages to extract content from in the source PDF file. For a single page, enter the page number. Use a comma (,) to specify more than one page (for example, 1,3,5). Use a dash (-) to specify a range of pages (for example, 5-10).
Insert at --- Yes Last page LOCATION="3" Specifies the location of where to insert pages in the PDF file. The available options are:
  • Last page - Inserts the pages after the last page in the PDF.
  • Specific page - Inserts the pages after the page number specified.

Description

Error Causes

On Error

Example

NOTE:
  • Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
  • To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.

Description

This example task extracts pages 1-3 from a PDF file and then inserts those pages at page 3 in different PDF file.

Copy
<AMPDF ACTIVITY="insert" SOURCE="C:\temp\savedForm.pdf" EXTRACTPDF="C:\temp\source.pdf" LOCATION="3" PAGE="1-3" />