Skip to main content
Balaji Murugesan
Known Participant
November 23, 2022
Answered

How to create postscript file using Javascript

  • November 23, 2022
  • 3 replies
  • 1274 views

Hi

 

I'm new to InDesign and ID scripting and am mainly trying to work with sample scripts to figure this out. how to assign print presets and the same ID path and same filename for a postscript file into ID.

 

Thanks

This topic has been closed for replies.
Correct answer rob day

Hi @Balaji Murugesan , Also here’s an example that creates a print preset if it doesn’t already exist, and then sets the page range and file path via printPreferences:

 

 

 

var doc = app.activeDocument
//makes a print preset
var pp = makePrintPreset("PSPrint");
//the .ps file path
var sf = File (doc.filePath + "/" + doc.name + ".ps");

//sets the preset’s properties
//https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PrinterPreset.html
pp.properties = {ppd:"Adobe PDF 9.0", 
                paperSize:"Letter",
                colorOutput: ColorOutputModes.COMPOSITE_CMYK,
                printer: Printer.POSTSCRIPT_FILE,
                flattenerPresetName:"[High Resolution]"};

//set the page range and .ps file path
//https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PrintPreference.html#d1e317722
doc.printPreferences.properties = {printFile: sf, pageRange: PageRange.ALL_PAGES}

doc.print(false, pp)


/**
* Makes a new print preset 
* @ param preset name name 
* @ return the new preset 
*/
function makePrintPreset(n){
    if (app.printerPresets.itemByName(n).isValid) {
        return app.printerPresets.itemByName(n);
    } else {
        return app.printerPresets.add({name:n});
    }
}


 

 

 

3 replies

rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
November 23, 2022

Hi @Balaji Murugesan , Also here’s an example that creates a print preset if it doesn’t already exist, and then sets the page range and file path via printPreferences:

 

 

 

var doc = app.activeDocument
//makes a print preset
var pp = makePrintPreset("PSPrint");
//the .ps file path
var sf = File (doc.filePath + "/" + doc.name + ".ps");

//sets the preset’s properties
//https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PrinterPreset.html
pp.properties = {ppd:"Adobe PDF 9.0", 
                paperSize:"Letter",
                colorOutput: ColorOutputModes.COMPOSITE_CMYK,
                printer: Printer.POSTSCRIPT_FILE,
                flattenerPresetName:"[High Resolution]"};

//set the page range and .ps file path
//https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PrintPreference.html#d1e317722
doc.printPreferences.properties = {printFile: sf, pageRange: PageRange.ALL_PAGES}

doc.print(false, pp)


/**
* Makes a new print preset 
* @ param preset name name 
* @ return the new preset 
*/
function makePrintPreset(n){
    if (app.printerPresets.itemByName(n).isValid) {
        return app.printerPresets.itemByName(n);
    } else {
        return app.printerPresets.add({name:n});
    }
}


 

 

 

Legend
November 23, 2022

Hello @Balaji Murugesan,

 

Take a look at the link below for a example...

https://adobe.scripting.indesign.narkive.com/1Qey2ePc/js-print-to-postscript-file

As mentioned by @grefel all the necessary scripting methods and properties can be found here:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/index.html#$.html

 

Regards,

Mike

grefel
Community Expert
Community Expert
November 23, 2022

Its all in the Document https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Document.html and Application Object https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Application.html

Print Preset you get via app.printerPresets.itemByName("Name"); The full Path is in Document.fullName start printing with Document.print(false, preset) https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Document.html#d1e49521__d1e55139