Get PDF Image
Gets the image of an entire page or a region-delimited part of a page from a PDF file.
Command availability: IBM RPA SaaS and IBM RPA on premises
Script syntax
IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.
pdfImage [--useregion(Boolean)] --region(Rectangle) --page(Numeric) --dpix(Numeric) --dpiy(Numeric) --file(Pdf) (Image)=value
Dependencies
The region is formed by the X and Y coordinates, in addition to the width and height. To obtain the region of the file used in the Region parameter, use the Region Selector tool in IBM RPA Studio, located in the upper menu: Tools> Pdf> Region Selector.
Input parameter
The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.
Designer mode label | Script mode name | Required | Accepted variable types | Description |
---|---|---|---|---|
Use Region | useregion |
Optional |
Boolean |
Enable it to get only a part of the file and not the entire page. |
Region | region |
Only when Use Region is True |
Rectangle |
Region composed of a tuple of X, Y, width, and height coordinates obtained by the region selector. |
Page | page |
Required |
Number |
Number of the page from which the image is taken. |
DpiX | dpix |
Required |
Number |
Number of pixels per inch on the horizontal axis of the PDF file. By default the value is set to 110. |
DpiY | dpiy |
Required |
Number |
Number of pixels per inch on the vertical axis of the PDF file. By default the value is set to 110. |
file |
Required |
PDF |
PDF file to obtain the image. |
Output parameter
Designer mode label | Script mode name | Accepted variable types | Description |
---|---|---|---|
Image | value |
Image |
Return a variable with the obtained image. |
Example
This command obtains an image of the first page of the PDF file, informed in the Open PDF File (pdfOpen
) command, returning this image in a variable.
defVar --name pdfFile --type Pdf
defVar --name filePath --type String
defVar --name obtainedImage --type Image
pdfOpen --file "fileForPDFCommands.pdf" filePath=file pdfFile=value
// Get the image of the first page of the informed PDF.
pdfImage --page 1 --dpix 110 --dpiy 110 --file ${pdfFile} obtainedImage=value
logMessage --message "${obtainedImage}" --type "Info"
// Returns the image variable with the obtained image.
❕ Important: To run the sample script, you would use the path to a PDF file in the Path parameter of the Open PDF File (pdfOpen
) command.
Limitations
-
Selecting a specific region of the file, the values of the DpiX and DpiY parameters must be maintained at 110. This prevents the obtained image from being different from the selected image.
-
Modifying the DpiX and DpiY values changes the resolution of the image making it more or less sharp. When the PDF file is opened in Studio the Dpi scales are changed to 110.