PDF - Add attachment(s)

Declaration

<AMPDF ACTIVITY="add_attachment" SESSION="text" SOURCE="text" PASSWORD="text (encrypted)" SAVETYPE="text (options)" DESTINATION="text" PFDOCUMENTFROM="text (options)" NEWPDF="text" OVERWRITE="YES/NO" CREATEEMPTY="YES/NO" FILENAME="text" DESCRIPTION="text" />

Related Topics  

Description

Attaches one or more files to a PDF file. To specify more than one file, use wildcard characters (for example, * or ?). To specify multiple files or file masks, separate them with a pipe character (for example, c:\file.txt|c:\file.xls).

Practical usage

Used to enable a PDF file to carry attached files, just as email messages can carry attached files. Attachments can contain a wide variety of information, and can be of a variety of file types. If you move the PDF file to a new location, the attachments move with it.

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 add attachments to 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) - Attachments are added to an existing PDF file.
  • New PDF - Attachments are added to 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 add the attachments. 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.

Attachment

Property Type Required Default Markup Description
Source Text Yes (Empty)
  • FILENAME="c:\folder\file.txt"
  • FILENAME="c:\folder\*.txt"
  • FILENAME="c:\file.txt|c:\file.xls
The paths and file names of the attachments to add. This field supports single file, multiple files, or file masks entries. Wildcard characters (for example, * or ?) may be used to attach files matching a certain mask. Multiple files or file masks may be entered by separating each entry with a pipe symbol (for example, c:\file.txt|c:\file.xls).
Description (optional) Text No Text DESCRIPTION="Excel_attachments" An optional description to label the attached files.

Description

Error Causes

On Error

Examples

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.

Example 1

This sample task attaches an Excel document to an existing PDF file.

Copy
<AMPDF ACTIVITY="add_attachment" SOURCE="C:\temp\sample1.pdf" FILENAME="C:\temp\employees.xls" DESCRIPTION="Primary Employee List" />

Example 2

This sample task attaches all Word documents found in a specific directory to new PDF file.

Copy
<AMPDF ACTIVITY="add_attachment" PDFDOCUMENTFROM="new_file" NEWPDF="c:\temp\documents.pdf" FILENAME="C:\temp2\*.doc" DESCRIPTION="MS Word Documents Attached" />