Skip to main content
February 20, 2020
Answered

script to provide preflight options

  • February 20, 2020
  • 2 replies
  • 2979 views
Hi All 
Any response will be appriciated for that 
i wanted to Add a option 
Option to Run Preflighting and show report :
   – All Color Images should be in CMYK
   – All Black & White images should be in Grayscale
   – No RGB and Pantone colors
   – Identification of Lowres Images
   – No Type 3 fonts
This topic has been closed for replies.
Correct answer Laubender

Hi Anupam,

there is app.loadPreflightProfile() that takes a preflight profile file as argument.

 

You could assign the returned profile as the activeProcess through document.preflightOptions.preflightWorkingProfile together with document.preflightOptions.preflightOff == false plus other properties in document.preflightOptions that control the active processes.

 

See DOM documentation:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PreflightOption.html#d1e409856

 

Regards,
Uwe Laubender

( ACP )

 

 

 

2 replies

LaubenderCommunity ExpertCorrect answer
Community Expert
February 21, 2020

Hi Anupam,

there is app.loadPreflightProfile() that takes a preflight profile file as argument.

 

You could assign the returned profile as the activeProcess through document.preflightOptions.preflightWorkingProfile together with document.preflightOptions.preflightOff == false plus other properties in document.preflightOptions that control the active processes.

 

See DOM documentation:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PreflightOption.html#d1e409856

 

Regards,
Uwe Laubender

( ACP )

 

 

 

February 22, 2020

Thanks Sir,

Now its working Fine i am loaded indpp file  externally indpp file 

Here my updated Code 

var myDoc=app.documents[0]
checkPreflight(myDoc)
//var checkPreflightOption="PreflightForIsuueAnupam.idpp";
function checkPreflight(myDoc) {
var x=0;
var logArray=[];
var checkPreflightOption="PreflightForIsuueAnupam.idpp";

scriptPath=myGetScriptPath();
if(app.documents.length > 0)
{
if (app.documents[0].preflightOptions.preflightOff)
{
app.documents[0].preflightOptions.preflightOff=false;
}
//~ else
//~ {
fpath = Folder(Folder(myDoc.filePath).parent.absoluteURI+"/Error");
scriptPath=myGetScriptPath()
var file=new Folder(scriptPath.parent+"/Preflght")
if(!file.exists)
{
file= file.create()
}
file=new File(file+"/"+checkPreflightOption)
for(var tk=0;tk < app.preflightProfiles.length;tk++)
{
var prefLightname=app.preflightProfiles[tk].name;
if( prefLightname == checkPreflightOption.split(".")[0])
{
app.preflightProfiles[tk].remove();
tk=app.preflightProfiles.length;
}
}
var myProfile = app.loadPreflightProfile(File(file)); // Get the profile itself using the name derived above
// myDoc.preflightOptions.preflightWorkingProfile=myProfile ; // Get the currently selected preflight profile name
if (!myProfile.isValid) {
// alert('Invalid preflight profile is active');
}
else
{
var allProcess=app.preflightProcesses;
{
var myPreflight = app.preflightProcesses.add(myDoc, myProfile); // Set the preflight var
myPreflight.waitForProcess(); // Don't process the results until it has finished running
var results = myPreflight.aggregatedResults[2]; // Store the results in a variable
if (results.length > 0)
{
// alert('Preflight errors found - check preflight menu for errors'); // This needs some love formatting-wise
var array=[];
for (var x=0; x <results.length;x++)
{
if(results[x].toString().indexOf("Fix") !=-1)
{
tmp = results[x].toString().split("Fix: ")[0]
logArray.push(tmp+"\n");
}
else
{
var array1=(results[x]+"\n");
logArray.push(array1);
//
}
}
if(fpath.exists == false)
{
fpath.create();
fpath = Folder(Folder(myDoc.filePath).parent.absoluteURI+"/Error");
}
var errorLog = File(fpath.absoluteURI+"/"+"preflight.log");
errorLog.open("w");
errorLog.write("Preflight Profile Name : "+myProfile.name+"\n"+"JOB-NAME : "+myDoc.name+"\n"+logArray);
errorLog.close();
}
}
}
// }
}
}

 

function myGetScriptPath() {
try{
try {
return app.activeScript;
}
catch (myError) {
return File(myError.fileName);
}
}
catch(e)
{
error(e);
}
}

 

Participant
November 8, 2023

Hello, @3472989  can you provide me your preflight file, that would be really helpful.

Thanks.

Community Expert
February 20, 2020

Hi Anupam,

 

What have you done so far? We can fixup your code if you are stuck. This seems like a small project, people here are willing to help but not dish out scripts for very specific workflows. It is a job that you need to get done, better to hire a developer to get it done and pay a bit for the efforts. I hope you understand and either put some effort to learn and ask for specific questions to help you write the code yourself or get a developer develop a specific script for you

 

-Manan

-Manan
February 21, 2020

function checkPreflight(myDoc) {
var x=0;
var logArray=[];
if(app.documents.length > 0)
{
if (app.activeDocument.preflightOptions.preflightOff)
{

}
else
{
var myDoc = app.activeDocument;
var myProfile = myDoc.preflightOptions.preflightWorkingProfile; // Get the currently selected preflight profile name
var myProfile = app.preflightProfiles.item(3); // Get the profile itself using the name derived above
if (!myProfile.isValid) {
alert('Invalid preflight profile is active');
}
else
{
var myPreflight = app.preflightProcesses.add(myDoc, myProfile); // Set the preflight var
myPreflight.waitForProcess(); // Don't process the results until it has finished running
var results = myPreflight.aggregatedResults[2]; // Store the results in a variable
if (results.length == 0)
{

}
else
{
alert('Preflight errors found - check preflight menu for errors'); // This needs some love formatting-wise
var array=[];
for (x in results[x])
{
if(results[x].toString().indexOf("Fix") !=-1)
{

}
else
{
var array1=('[' + x + "]\t" + results);
logArray.push(array1);
var scriptPath=myGetScriptPath()
fpath = Folder(Folder(myDoc.filePath).parent.absoluteURI+"/Error");
}
}
if(fpath.exists == false)
{
fpath.create();
fpath = Folder(Folder(myDoc.filePath).parent.absoluteURI+"/Error");
}
var errorLog = File(fpath.absoluteURI+"/"+"preflight.log");
errorLog.open("w");
errorLog.write(array);
errorLog.close();
}
}
}
}
}

February 21, 2020

i am stuck here i am developing the code to run on server 

but the preflight profile i have added manually in indesign 

myProfile = app.preflightProfiles.item(3)//////////////hard coded 

how can i call this profile on indesign server