PDF - Create

Declaration

<AMPDF ACTIVITY="create" CREATEFROM="text (options)" SOURCE="text" TEXT="text" SETFONT="YES/NO" FONT="text (options)" SIZE="number" FORGROUNDCOLOR="text (options)"  BACKGROUNDCOLOR="text (options)" LEFT="number" TOP="number" BOTTOM="number" RIGHT="number" DESTINATION="text" OVERWRITE="YES/NO" LANDSCAPE="YES/NO" />

Related Topics

Description

Creates a new portable document format (PDF) file using plain text, text contained in a text file, HTML formatted text, or text contained in an HTML document as the source data. When converting HTML formatted text, this activity renders the text according to its HTML tags, therefore, its appearance in the new PDF file would be displayed in the same HTML format as the source.

IMPORTANT: Using HTML formatted text that contains the <br> tag with no text to break and/or deprecated tags/attributes with this activity will cause rendering issues with PDF files.

Practical usage

Useful for embedding the contents of an existing HTML file to a new PDF file to apply new text formatting. Can also be used to easily and efficiently convert the contents of a text file to a PDF file.

Parameters

Resource

Property Type Required Default Markup Description
From Text (options) Yes Plain text
  • CREATEFROM="html"
  • CREATEFROM="text_file"
  • CREATEFROM="html_file"
Specifies the original source data to create into a PDF file. The available options are:
  • Plain text (default) - Converts plain text into a PDF file.
  • HTML- Converts HTML text into a PDF file.
  • Text file - Converts the data contained in a text file into a PDF file.
  • HTML file - Converts the data contained in an HTML file into a PDF file.
Plain text Text Yes, if Fromis set to Plain text (Empty) TEXT="thePlainText" The text to covert into a PDF file. This parameter becomes active and is required if the From parameter is set to Plain text.
HTML text Text Yes, if Fromis set to HTML text (Empty) TEXT="theHTMLText" The HTML formatted text to convert into a PDF file. This parameter becomes active and is required if the From parameter is set to HTML text.
Source Text Yes, if Fromis set to Text file or HTML file (Empty)
  • SOURCE="C:\theFile.txt"
  • SOURCE="C:\theFile.html"
The path and file name of the text or HTML file to convert into a PDF file. This parameter becomes active and is required if the From parameter is set to Text file or HTML file.
PDF Text Yes (Empty) DESTINATION="C:\newFile.pdf" The path and file name where the newly-created PDF file is stored. Click the folder icon to browse to the desired location, or manually enter the full path and file name in the provided text box.
Overwrite if PDF already exists Yes/No No No OVERWRITE="YES" If selected, a PDF file with the same file name in the destination folder is overwritten when this activity runs. If disabled (default), a PDF file with the same file name in the destination folder is not overwritten, however, a runtime error occurs as a result.

Advanced

Property Type Required Default Markup Description
These parameters become available if From is set to Plain text or Text file.
Set Yes/No No No SETFONT="YES" If selected, the default settings for Font, Font size, Text color, and Background color of the PDF file can be modified. It is disabled by default.
Font Text (options) Yes, if Set is set to YES Segoe UI FONT="Times New Roman" Sets the font typeface of the PDF file. The default value is Segoe UI. This parameter becomes active and is required if the Set parameter is set to YES.
Font size Number Yes, if Set is set to YES 11 SIZE="10" Sets the font size of the PDF file. The default value is 11. This parameter becomes active and is required if the Set parameter is set to YES.
Text color Text (options) Yes, if Set is set to YES Black FORGROUNDCOLOR="Blue" Sets the text color of the PDF file. The default value is Black. This parameter becomes active and is required if the Set parameter is set to YES.
Background color Text (options) Yes, if Set is set to YES White BACKGROUNDCOLOR="SeaShell" Sets the background color of the PDF file. The default value is White. This parameter becomes active and is required if the Set parameter is set to YES.

Page

Property Type Required Default Markup Description
Orientation Text (options) Yes Portrait LANDSCAPE="YES" Sets the page orientation of the PDF file. The options are:
  • Portrait (default) - The PDF file opens in a vertical direction.
  • Landscape - The PDF file opens in a horizontal direction.
Left Text No 10 LEFT="12" Sets the left page margin, specified in points. The default value is 10.
NOTE: 1 inch = 72 points/96 pixels.
Top Text No 50 TOP="550" Sets the top page margin, specified in points. The default value is 50.
NOTE: 1 inch = 72 points/96 pixels.
Bottom Text No 50 BOTTOM="55" Sets the bottom page margin, specified in points. The default value is 50.
NOTE: 1 inch = 72 points/96 pixels.
Right Text No 10 RIGHT="55" Sets the right page margin, specified in points. The default value is 10.
NOTE: 1 inch = 72 points/96 pixels.

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 simple task creates a PDF file from plain text and then saves it.

Copy
<AMPDF ACTIVITY="create" TEXT="the text" SETFONT="YES" SIZE="12" DESTINATION="C:\temp\sample.pdf" OVERWRITE="YES" />