Forum Replies Created
-
AuthorPosts
-
mikayle
MemberUwe Laubender said:
I've written a scripting solution for exporting PDFs in “foreground”. Please test it with care, no guarantee that it will work in every case. There is a very basic UI for setting up the location where to save the pdf and to name it. After that the usual PDF preset dialog of InDesign will pop up where you can do your usual stuff like setting up page ranges etc.
A little error handling is also present, so the script will check if a given file is already present and you can decide to overwrite it or not. Further on the script errors out smoothly if you decide to overwrite a pdf and that particular pdf is already open in an pdf viewer app.
I hope the following lines of code are not messed up by the forum software (if so I will write a follow-up or try to edit the html-code):
//ExportPDF_in_Foreground_CS5.jsx
//Uwe Laubender
/**
* @@@BUILDINFO@@@ ExportPDF_in_Foreground_CS5.jsx !Version! Thu Jul 08 2010 10:51:10 GMT+0200
*/
//DESCRIPTION:PDF-Export in foreground (old school) for InDesign CS5 only!if(app.documents.length>0){
var d=app.activeDocument;
};
else{
alert("Please open a document to execute Export to PDF. Script will be aborted.");
exit();
}
if(d.saved == false){
alert("Save your document first before executing Export to PDF. Script will be aborted.");
exit();
};var pdfPath = Folder.selectDialog("Folder to save PDF:");
var pdfName = d.name+".pdf";var userDefFileName = prompt("File name:",pdfName,undefined);
if(userDefFileName == null){
exit();
};var pdfFullName = pdfPath+"/"+userDefFileName;
if(File(pdfFullName).exists){
c=confirm("The PDF-file "+userDefFileName+" is already existing. Do you want to overwrite it?",true,undefined);
if (c==0){exit()};
};
//Error-handling if PDF file override is on and PDF is already opened in PDF reader app:
try{
d.exportFile(ExportFormat.PDF_TYPE,File(pdfFullName),true,undefined,undefined);
}catch(e){
alert("Error: "+e.message+" (Line "+ e.line+" in script code.)");
exit();
};Uwe
Uwe, how do I apply this code exactly?
mikayle
MemberUwe Laubender said:
I've written a scripting solution for exporting PDFs in “foreground”. Please test it with care, no guarantee that it will work in every case. There is a very basic UI for setting up the location where to save the pdf and to name it. After that the usual PDF preset dialog of InDesign will pop up where you can do your usual stuff like setting up page ranges etc.
A little error handling is also present, so the script will check if a given file is already present and you can decide to overwrite it or not. Further on the script errors out smoothly if you decide to overwrite a pdf and that particular pdf is already open in an pdf viewer app.
I hope the following lines of code are not messed up by the forum software (if so I will write a follow-up or try to edit the html-code):
//ExportPDF_in_Foreground_CS5.jsx
//Uwe Laubender
/**
* @@@BUILDINFO@@@ ExportPDF_in_Foreground_CS5.jsx !Version! Thu Jul 08 2010 10:51:10 GMT+0200
*/
//DESCRIPTION:PDF-Export in foreground (old school) for InDesign CS5 only!if(app.documents.length>0){
var d=app.activeDocument;
};
else{
alert("Please open a document to execute Export to PDF. Script will be aborted.");
exit();
}
if(d.saved == false){
alert("Save your document first before executing Export to PDF. Script will be aborted.");
exit();
};var pdfPath = Folder.selectDialog("Folder to save PDF:");
var pdfName = d.name+".pdf";var userDefFileName = prompt("File name:",pdfName,undefined);
if(userDefFileName == null){
exit();
};var pdfFullName = pdfPath+"/"+userDefFileName;
if(File(pdfFullName).exists){
c=confirm("The PDF-file "+userDefFileName+" is already existing. Do you want to overwrite it?",true,undefined);
if (c==0){exit()};
};
//Error-handling if PDF file override is on and PDF is already opened in PDF reader app:
try{
d.exportFile(ExportFormat.PDF_TYPE,File(pdfFullName),true,undefined,undefined);
}catch(e){
alert("Error: "+e.message+" (Line "+ e.line+" in script code.)");
exit();
};Uwe
Uwe, how do I apply this code exactly?
-
AuthorPosts
