Get PDF Pages
Gets the contents in a range of pages from a PDF file, saving them on a new 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.
pdfExtract --range(String) --outputpath(String) [--overwrite(Boolean)] --file(Pdf) (Pdf)=value (String)=file
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 |
---|---|---|---|---|
Pages | range |
Required |
Text |
The desired page numbers to get. They can be written separated by a semicolon (1;5) to represent each page or by a hyphen to determine the range between pages (1-5). |
Output path | outputpath |
Required |
Text |
Path of the PDF file to save the contents of the obtained pages. |
Overwrite | overwrite |
Optional |
Boolean |
Enable to replace existing content in target file. |
Original file | file |
Required |
PDF |
File from which pages are obtained. |
Output parameter
Designer mode label | Script mode name | Accepted variable types | Description |
---|---|---|---|
value |
PDF |
Return the PDF file with the content of the obtained pages. | |
Output path | file |
Text |
Return the PDF file path with the new content saved. |
Example
This command retrieves the contents of pages 2-4, as reported in the Pages parameter, and saves the contents of these pages to another PDF file, returning the path of that other file with the content obtained.
defVar --name pdfOpen --type Pdf
defVar --name outputPDFFile --type String
defVar --name desktopFolder --type String
getSpecialFolder --folder "Desktop" desktopFolder=value
pdfOpen --file "${desktopFolder}\\sourcePDFFile.pdf" pdfOpen=value
pdfExtract --range "2-4" --outputpath "${desktopFolder}\\outputPDFFile.pdf" --file ${pdfOpen} outputPDFFile=file
pdfClose --file ${pdfOpen}
//Returns the file path with the pages that were fetched.
❕ Important: To run the sample script, you would use the path to a PDF file with more than 4 pages in the Path parameter of the Open PDF File command.