Posts Tagged PDF
InDesign CS2 export script
This very useful JavaScript code was developed by Peter Kahrel as he found my problem interesting. Bless you Peter! The full thread is over on the Adobe’s InDesign Scripting Forum here abouts. Because there’s only a limited life for any post over there – I’m dumping here too for posterity.
The purpose of the script is to export single page PDFs from a multi-page InDesign CS2 document where the page numbering has been set via page Numbering and Section Options. PDFs are exported to a predetermined PDF setting: “PDF_X-1a with Bleed & co” in my case. The resulting file PDFs are named with a three-digit prefix corresponding to the page number in the InDesign document and a user defined base name – defined when the script is run.
A basic version of this script is supplied by Adobe in with the extras for an InDesign install but unfortunately that falls over when there is a Named Section present. Getting a stray Named Section in your document is very easy. Easier for some users mind – but still very easy. Peter – I still owe you a beer or three…
Here is the magic script:
#target indesign
if(app.documents.length != 0)
{
var myFolder = Folder.selectDialog ("Choose a Folder");
if(myFolder != null)
{
myExportPages(myFolder);
}
}
else
{
alert("Please open a document and try again.");
}
function myExportPages(myFolder)
{
var myPageName, myFilePath, myFile;
var myDocument = app.activeDocument;
var myDocumentName = myDocument.name;
//This next line sets the PDF export Setting
var myPDFExportPreset = app.pdfExportPresets.item("PDF_X-1a with Bleed & co")
var myDialog = app.dialogs.add();
with(myDialog.dialogColumns.add().dialogRows.add())
{
staticTexts.add({staticLabel:"Base name:"});
var myBaseNameField = textEditboxes.add({editContents:myDocumentName, minWidth:160});
}
var myResult = myDialog.show({name:"ExportPages"});
if(myResult == true)
{
var myBaseName = myBaseNameField.editContents;
myDialog.destroy();
// Remember the state of each section prefix
var section_states = myDocument.sections.everyItem().includeSectionPrefix;
// Get all section-prefix names
var section_names = app.activeDocument.sections.everyItem().name;
// Enable all section prefixes
myDocument.sections.everyItem().includeSectionPrefix = true;
// Create two parallel arrays with page numbers:
// one with numbers preceded by section prefixes,
// the other with bare page numbers
var page_ranges = [];
var filename_pagenames = [];
for(var i = 0; i < myDocument.pages.length; i++)
{
page_ranges.push (myDocument.pages.item(i).name);
var temp = strip_section (myDocument.pages[i].name, section_names);
filename_pagenames.push (("00" + temp).slice(-3))
}
// Restore the section-prefix settings
restore_section_states (myDocument, section_states);
// Export each page
for(var i = 0; i < myDocument.pages.length; i++)
{
app.pdfExportPreferences.pageRange = page_ranges[i];
myFilePath = myFolder + "/" + filename_pagenames[i] + "-" + myBaseName + ".pdf";
myFile = new File(myFilePath);
myDocument.exportFile(ExportFormat.pdfType, myFile, false, myPDFExportPreset);
}
}
else
{
myDialog.destroy();
}
}
function restore_section_states (doc, states)
{
for (var i = 0; i < doc.sections.length; i++)
doc.sections[i].includeSectionPrefix = states[i];
}
function strip_section (pg, array)
{
for (var i = 0; i < array.length; i++)
if (array[i].length > 0)
if (pg.match (RegExp ('^'+array[i])) != null)
{
pg = pg.replace (RegExp ('^'+array[i]), '');
break
}
return pg
}
Illustrator PDF reply on Adobe forums
Posted by admin in Graphic arts, Technology on November 10th, 2007
What I said was…
There are many pitfalls to be avoided when working in Illustrator. Beyond it being buggy and a hog I find it’s not a great tool for working on any press-ready artwork. [Disclosure: InDesign fanboy here].
Firstly, as Aandi notes, avoid flattening artwork (ie printing to PostScript or saving as PDF 1.3 or under) – as that causes many transparency effects, including drop-shadows, to be converted into raster art.
If you must export flattened artwork don’t forget to set the “Document Raster Effects Settings” (under Effect on the menu bar) to a suitable level. Unfortunately the default is 72dpi.
Also ensure that any important type or vector information is kept in a separate layer above “background” objects. The idea is to add a virtual layer of separation between type and effects. “In Front” and “Behind” is not enough – use layers. [The same applies for InDesign.]
Again Aandi is spot on: the “Save PDF with editing capability” feature can cause massive file sizes; the difference with the PDF of the cover of the magazine I work on: a few hundred MB or just a few MB!
Another thing try to remember to use “Save a Copy” or to otherwise be careful not to get your final delivery artwork confused with the working file. Its’s an inherent confusion in Illustrator: PDFs should really only be used as final artwork – not as a working file. I don’t like that at all. Particularly as I have to deal with these ambiguous duplicate files at work. Add an extra note to the file name or something. Please!
I said it here