PDF - Replace

Declaration

<AMPDF ACTIVITY="replace" SOURCE="text" SAVETYPE="text (options)" DESTINATION="text" TEXT="text" 
REPLACE="text" PAGE="number" OCCURRENCES="number" 
SETFONT="YES/NO" FONT="text (options)" SIZE="number" 
FORGROUNDCOLOR="text (options)" BACKGROUNDCOLOR="text (options)" />

Description: Finds and replaces a text string with another text string from single page or all pages of a PDF document.  

Practical Usage

Can be used as a means to update PDF documents with new data.

Resource Parameters

Property

Type

Required

Default

Markup

Description

Resource

---

---

---

---

Indicates where the source PDF 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) - Specifies that the source PDF derives from a file located on the system. This option is normally chosen if only a single activity is required to complete an operation.

  • Session - Specifies that 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 options is normally chosen if a combination of activities within the same action group are required. Linking several activities to a single session eliminates redundancy and improves efficiency. Several sessions can exist in a single task. In addition, multiple sessions can run simultaneously without interference.

Session

Text

Yes if Resource parameter 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 parameter  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) - This activity will be performed on an existing PDF document.

  • New PDF - This activity will be performed on a newly created PDF file.

Source PDF

Text

Yes if Use parameter is set to Existing PDF

(Empty)

SOURCE="C:\PDFFileName.pdf"

The path and filename of an existing PDF document to be used as the source. This parameter is active only if the Use parameter is set to Existing PDF.

Password (optional)

Text

Yes if Use parameter is set to Existing PDF

(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 Use parameter is set to 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 this activity 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 On Completion parameter is set to Save as

(Empty)

DESTINATION="C:\PDFFileName.pdf"

The new path and/or 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 Use parameter is set to New PDF

(Empty)

NEWPDF="C:\PDFFileName.pdf"

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

Criteria Parameters

Property

Type

Required

Default

Markup

Description

Find

Text

Yes

(Empty)

FIND="PDF Security"

The text string to search for.

Replace with

Text

Yes

(Empty)

REPLACE="Helpsystems"

The text string to replace the found text.

Use regular expression

Yes/No

No

No

REGEX="YES"

If set to YES, indicates that the value entered in the Find parameter is a regular expression. If set to NO (default), the value is literal text.

Advanced Parameters

Property

Type

Required

Default

Markup

Description

Maximum replacement (optional)

Number

Yes

(Empty)

OCCURRENCES="3"

The total number of found text occurrences to replace with new text.

Replace font

---

---

---

---

If enabled, font details and background color will be replaced with the criteria specified below. This is a design-time parameter used only during task creation and  configuration, therefore, contains no properties or markups (disabled by default)

Font

Text

No

Segoe UI

FONT="Tahoma"

The new font to replace the original font.

Font size

Number

No

11

SIZE="10"

The new font size to replace the original size.

Text color

Text

No

Black

FOREGROUNDCOLOR="Cyan"

The new font color to replace the original color.

Background color

Text

No

White

BACKGROUNDCOLOR="Red"

The new background color to replace the original background color.

Pages Parameters

Property

Type

Required

Default

Markup

Description

All

---

---

---

---

If enabled, search and replace will be performed on all pages of the PDF document. This is a visual mode parameter used only during design time, therefore, contains no properties or markup.

Page(s)

Text

No

(Empty)

FIELDNAME="Field1"

If enabled, search and replace will be performed on an individual page or specific pages of the PDF document. Enter the page number to specify a single page. Use a comma (,) to specify more than one page (e.g., 1,3,5). Use a dash (-) to specify a range of pages (e.g., 5-10).

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.)

Example

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

Description: Replace text "extract" with "remove" from existing PDF "C:\temp\myDocument.pdf". Save output PDF as "C:\temp\myDocument_new.pdf".

<AMPDF ACTIVITY="replace" SOURCE="C:\temp\myDocument.pdf" 
SAVETYPE="save_as" DESTINATION="C:\temp\myDocument_new.pdf" 
TEXT="extract" REPLACE="remove" PAGE="1-6" />