Copy link to clipboard
Copied
Hi,
I want to add a print to PDF in this script using my Print Preset named "Print Ready". Any idea how?
d = app.activeDocument; |
preset1 = app.pdfExportPresets.itemByName("WEB READY"); | |
preset2 = app.pdfExportPresets.itemByName("PDF/X-1a:2001"); | |
if (!(preset1.isValid && preset2.isValid)){ | |
alert("One of the presets does not exist. Please check spelling carefully."); | |
exit(); | |
} | |
if (d.saved){ | |
thePath = String(d.fullName).replace(/\..+$/, "") + ".pdf"; | |
thePath = String(new File(thePath).saveDlg()); | |
} | |
else{ | |
thePath = String((new File).saveDlg()); | |
} | |
thePath = thePath.replace(/\.pdf$/, ""); | |
name1 = thePath+"_web.pdf"; |
name2 = thePath+"_edgar.pdf"; | |
d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1); | |
d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2); |
Copy link to clipboard
Copied
after this line at the top of the script:
preset1 = app.pdfExportPresets.itemByName("WEB READY"); | |
add this line:
preset3 = app.pdfExportPresets.itemByName(Print Ready"); | |
at the end of the script, after these lines:
name2 = thePath+"_edgar.pdf";
d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1);
add the following lines:
name3 = thePath+"_printready.pdf";
d.exportFile(ExportFormat.PDF_TYPE, new File(name3), false, preset3);
There is also a great pre-baked script worth looking at: http://www.id-extras.com/script-to-export-multiple-pdfs-at-once
Copy link to clipboard
Copied
Thanks Colin but I'm asking for Print to PDF not Export PDF
Copy link to clipboard
Copied
manilap94829696 wrote
Thanks Colin but I'm asking for Print to PDF not Export PDF
Hi,
Print to PDF is not supported as default.
To make that work you have to install things ( a distinct PPD file ) first. And in that process create a new folder in InDesign's application folder Presets that is named PPDs. It could be that this is not allowed in a system under a distinct user. Hard to script though. You cannot circumvent security settings of the OS without permissions.
So my suggestion is better to script PDF Export.
May I ask why you have to script Print to PDF? Is there something you can do with this workflow you would not be able to do with PDF Export?
Regards,
Uwe
Copy link to clipboard
Copied
Thanks L for the reply.
The reason why I need to use Print to PDF because the final PDF for print should be scaled down to 98.5%. Right now I have a working script using Both but I need to make the script to save the Print to PDF output in same location as the Export output. Any idea how?
d = app.activeDocument; | |
// Here you can choose the PDF preset | |
preset1 = app.pdfExportPresets.itemByName("T. ROWE WEB READY"); | |
preset2 = app.pdfExportPresets.itemByName("[PDF/X-1a:2001]"); | |
if (!(preset1.isValid && preset2.isValid)){ | |
alert("One of the presets does not exist. Please check spelling carefully."); | |
exit(); | |
} | |
if (d.saved){ | |
thePath = String(d.fullName).replace(/\..+$/, "") + ".pdf"; | |
thePath = String(new File(thePath).saveDlg()); | |
} | |
else{ | |
thePath = String((new File).saveDlg()); | |
} | |
thePath = thePath.replace(/\.pdf$/, ""); |
name1 = thePath+"_web.pdf"; | |
name2 = thePath+"_edgar.pdf"; | |
name3 = thePath+"_print.pdf"; |
d.exportFile(ExportFormat.PDF_TYPE, new File(name1), false, preset1); | |
d.exportFile(ExportFormat.PDF_TYPE, new File(name2), false, preset2); | |
app.activeDocument.print (false, "T. ROWE PRINT READY"); |
Copy link to clipboard
Copied
All code you are posting is for PDF Export. That would be the wrong workflow to scale pages.
If the script is for your personal usage where you have admin rights I see a chance. But that means you have to install a PPD file. You would print to PostScript to a folder where Acrobat Distiller will pick up the PostScript file to distill to PDF and moves the file to a predefined output folder. You have to prepare that workflow with Distiller. This is not in the scope of ExtendScript for InDesign. You'd only be able to open Distiller by executing the result PostScript file from InDesign.
Alternatives:
Maybe it's better to scale down the document pages including contents and export to PDF.
Or you export to PDF ( use the PDF/X-4 preset without downsampling images ) and place the pages of the PDF in a new document where you scale the placed PDF pages.Then you could export to PDF again.
And then we have Acrobat Pro DC where are means to resize an opened PDF by means of a Acrobat Preflight rule.
Also investigate in that direction.
Regards,
Uwe
EDITED
Copy link to clipboard
Copied
this code is already working but what i need is just to save it in the same directory where the export file save
app.activeDocument.print (false, "T. ROWE PRINT READY");
Copy link to clipboard
Copied
Hi,
I see no way to define the folder where you print to by using ExtendScript.
You could set the first argument of print() to true but that would mean user intervention.
Hm. I think there is a default folder, the user's document folder, where the printed file will show up.
Pick it up there and copy the file over to the folder you defined with export to PDF. But first check if the file size isn't growing anymore or the file's value for modified isn't changing anymore and therefore the file you want to copy is fully printed.
Regards,
Uwe
Copy link to clipboard
Copied
There are other ways to scale a PDF besides printing to PDF. Perhaps use your export to PDF function and export it to a folder that has an acrobat droplet to scale the content you're after. If you've not used Acrobat's preflight droplets (they act as hot folders) have a look here: Adobe DC Action Wizard and Preflight page scaling