PDF - Get Attachments

Declaration

<AMPDF ACTIVITY="extract_attachment" SOURCE="text" 
PASSWORD="text (encrypted)" DESTINATION="text" 
FILENAME="text" />

Description: Extracts all files or specific files attached to a PDF document and saves them to the location identified.

Practical Usage

Can be used to extract PDF attachment files onto disc to open them or process them using subsequent activities.

Resource Parameters

Property

Type

Required

Default

Markup

Description

Resource

---

---

---

---

Indicates where the source PDF document should originate from. This is a design mode parameter used only during task construction and configuration, thus, comprises no markup. 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 are 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.

Session

Text

Yes if Resource is set to Session

PDFSession1

SESSION="mySession"

The name of an existing session to associate this activity with. This parameter is active only if the Resource parameter is set to Session.

Use

Text (options)

Yes if Resource is set to File

Existing PDF

  1. PDFDOCUMENTFROM="existing_file"

  2. PDFDOCUMENTFROM="new_file"

Specifies whether this activity will be performed on an existing PDF document or on a new document. This parameter is active only if the Resource parameter is set to File. The available options are:

  • Existing PDF (default) - >Attachments will be added to an existing PDF document.

  • New PDF - Attachments will be added to a newly created PDF file.

Source PDF

Text

Yes if using existing PDF

(Empty)

SOURCE="C:\PDFFileName.pdf"

The path and filename of the PDF document in which files will be attached. This parameter is active only if the Use parameter is set to Existing PDF.

Password (optional)

Text

No

(Empty)

PASSWORD="encrypted"

The password required to open an existing PDF document (if required). This parameter is active only if the Use parameter is set to Existing PDF.

On completion

Text (options)

Yes if using existing PDF

Save

  1. SAVETYPE="save"

  2. SAVETYPE="do_not_save"

  3. SAVETYPE="save_as"

Specifies what action should be performed on the existing PDF file upon completion of this activity. This parameter is active only if the Use parameter is set to Existing PDF. The available options are:

  • Save (default) - Changes will be saved under the PDF document's original file name.

  • Do not save changes - Any changes made to the existing PDF document will not be saved.

  • Save As - Changes will be saved to a new path and filename.

Destination PDF

Text

Yes if set to Save As

(Empty)

DESTINATION="C:\PDFFileName.pdf"

The new path and filename in which to save a copy of the original PDF file. This parameter is active only if the On completion parameter is set to Save as.

New PDF

Text

Yes if creating new PDF

(Empty)

NEWPDF="C:\PDFFileName.pdf"

The path and filename in which to save the newly generated PDF document. This parameter is active only if the Use parameter is set to New PDF.

Overwrite if PDF already exists

Yes/No

No

No

OVERWRITE="YES"

If set to YES, files matching the name of the new PDF file will be overwritten. If set to NO, matching files will not be overwritten, however, a runtime error will occur as a result.  

Attachment Parameters

Property

Type

Required

Default

Markup

Description

Destination

Text

Yes

(Empty)

Source="c:\temp\folderName"

The destination folder in which extracted file(s) will be saved.

Extract

---

---

---

---

Determines the attachment(s) to extract. This is a design mode parameter used only during task construction and configuration, thus, comprises no markup. The available options are:

  • All - Gets all files attached to the PDF document.

  • Specific file(s) - Gets one or more specified files attached to the PDF document.

File name

Text

Yes if Extact parameter is set to Specific file(s)

(Empty)

  1. SOURCE="file.txt"

  2. SOURCE="c:\folder\*.txt"

  3. SOURCE="c:\file.txt|c:\file.xls

The filename(s) to get. Click the folder icon to open the Attachment Browser which allows you browse and select files currently attached to the PDF document or you can manually enter the desired filename(s) in the provided text-box. Use a comma to delimit each entry (e.g., file1.txt,file2.txt,fileA.png).

Description tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.

Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)

On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)

Examples

The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

This sample task extracts specific attachments from PDF and stores them into folder "C:\temp101\".

<AMPDF ACTIVITY="extract_attachment" SOURCE="C:\temp\sample.pdf" 
DESTINATION="C:\temp101\" FILENAME="C:\temp\AM10_BPA10_combined_data.txt,
C:\temp\HR_Department.txt,C:\temp\process_info2.txt" />