Attach Image and Print PDF
This sample shows how to run a job to open an existing drawing, attach an image and saves the drawing as PDF. In this case the output file is a PDF mapped on the configuration file.
Also a position of the rectangle will be passed as a parameter to the script by adding a variable to the configuration file.
Script
(command "_-IMAGE" "_ATTACH" "SOURCEIMG" (list 0.0 0.0 0.0) 1.0 0.0)
(command "_-PRINT" "_NO" "Model" "" "PDF" "OUTPUTPDF" "_NO" "_YES")
(command "EXIT" "YES")
Line by line:
(command "_-IMAGE" "_ATTACH" "SOURCEIMG" (list 0.0 0.0 0.0) 1.0 0.0)
- This line fires the command IMAGE adding the image from SOURCEIMG
.
SOURCEIMG
- Is the placeholder that receives the image path from the Configuration file.
(command "_-PRINT" "_NO" "Model" "" "PDF" "OUTPUTPDF" "_NO" "_YES")
- This line exports the drawing as PDF with some specific options.
OUTPUTDWG
- Is the placeholder that receives the location path to save the PDF file from the Configuration file..
(command "EXIT" "YES")
- This line closes ARES Commander instance.
Environment package
For this sample, the environment package requires the script and the image to be attached.
As convention, we place the script on Script folder on the root of the compacted (.zip) folder.
Configuration file
{
"Inputs": {
"inputfileformat": "dwg",
"script": {
"scriptpath": "scripts/PrintPDF.scr",
"scriptformat": "scr",
"scriptvariables": [{
"name": "OUTPUTPDF",
"value": "output/MyFile.pdf"
}, {
"name": "SOURCEIMG",
"value": "images/Graebert.png"
}]
}
},
"Outputs": {
"outputfileformat": "pdf",
"outputfilename": "output/MyFile.pdf"
}
}
The configuration file maps the file locations and variables to be used on the Script.
For this sample we are providing the output file path, location where the file will be saved, and the location of the image to be attached.
Inputs
Default parameters:
"scriptpath": "scripts/PrintPDF.scr",
"scriptformat": "scr",
Custom variable
Outputs
On output session the output files are declared so the server can locate it and place on the download link in the Job result page.
Default parameters:
Resources:
Environment:
Configuration file: