Print Document
Prints a document on a printer.
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.
printDocument --file(String) [--printerExtraParameters(String)] [--selectPrinter(Boolean)] --printer(String) (Boolean)=value
Input parameters
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 |
---|---|---|---|---|
File Name | file |
Required |
Text |
File path of the document that is printed. |
Additional Parameters | printerExtraParameters |
Optional |
Text |
Additional parameters to be sent for printing. |
Select Printer | selectPrinter |
Optional |
Boolean |
Enable to activate the Printer Name parameter to specify the name of the printer to print the document. |
Printer Name | printer |
Only when Select Printer is True |
Text |
Name of the printer to be set as the system's default. The printer name may change according to the printers available in the current machine. |
Output parameter
Designer mode label | Script mode name | Accepted variable types | Description |
---|---|---|---|
Success | value |
Boolean |
Returns True if the print is successful, or False otherwise. |
Example
Example 1: The command prints a document obtained by the Select File (selectFile
) command on the default printer defined by Get Default Printer (getDefaultPrinter
) command. Finally, it returns if the printing was successful.
defVar --name defaultPrinter --type String
defVar --name success --type Boolean
defVar --name documentToPrint --type String
// Select which document to print.
// fileForPDFCommandsEditable.pdf.
selectFile --filter "*.pdf" documentToPrint=value
// Get the default printer.
getDefaultPrinter defaultPrinter=value
// Print the document.
printDocument --file "${documentToPrint}" --selectPrinter --printer "${defaultPrinter}" success=value
logMessage --message "${success}" --type "Info"
// Returns the success of the impression.
Example 2: The following example shows a scenario where the command prints two PDFs files merged by the Merge PDF (pdfMerge
) command. After printing, it returns
a message informing if the print was successful.
defVar --name documents_folder --type String
defVar --name example_pdf1 --type String
defVar --name example_pdf2 --type String
defVar --name list_pdfs --type List --innertype String --value "[$(example_pdf1),$(example_pdf2)]"
defVar --name merged_pdf --type Pdf
defVar --name success --type Boolean
defVar --name merged_files_folder --type String
// Get the "My documents" folder.
getSpecialFolder --folder "MyDocuments" documents_folder=value
// Open the first PDF.
pdfOpen --file "${example_pdf1}"
// Open the second PDF.
pdfOpen --file "${example_pdf2}"
// Merge both files into one.
pdfMerge --files "${list_pdfs}" --outputpath "${documents_folder}" merged_pdf=value merged_files_folder=file
//// Print the file with the merged PDFs
printDocument --file "${merged_pdf}" --selectPrinter --printer example_printer success=value
// Returns the success of the impression.
logMessage --message "${merged_files_folder}\r\n${success}" --type "Info"