• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

AS) export single page PDFs from multi-artboards

New Here ,
May 06, 2009 May 06, 2009

Copy link to clipboard

Copied

I'm not exactly sure where my new problem lies. I'm trying to save out single page PDFs from an Illustrator CS4 document with multiple artboards. Each artboard should become a PDF. I can get a multi page PDF, but when it saves single page files, I get white PDFs with error messages on them (I think it is saving .ai files with a .pdf extension).

this is where I am now (simplified, of course):



tell application "Adobe Illustrator"
set docName to name of current document

set itemNumber to 1
tell application "Finder" to set fileLoc to path to desktop as string

set pageCount to (count artboards in document docName)

tell current document
set allPlacedItems to placed items
repeat with h from 1 to (count of allPlacedItems)
set thisPlacedItem to item h of allPlacedItems
tell thisPlacedItem to embed
end repeat

set allTextItems to text frames
repeat with j from 1 to (count of allTextItems)
set thisTextItem to item j of allTextItems
tell thisTextItem to convert to paths
end repeat
end tell

repeat with i from 1 to pageCount

set pdfSaveOptions to {class:PDF save options, pdfXstandard:PDFX None, compatibility:Acrobat 6, preserve editability:false, generate thumbnails:false, optimization:false, acrobat layers:false, artboard range:i, view pdf:false, color downsampling:0, color resample:nodownsample, color compression:none, grayscale downsampling:0, grayscale resample:nodownsample, grayscale compression:none, monochrome downsampling:0, monochrome resample:nodownsample, monochrome compression:none, compress art:false, trim marks:false, registration marks:false, color bars:false, page info:false, page marks style:Roman, trim mark weight:trimmarkweight025, offset:6.0, bleed link:true, bleed offset:{0, 0, 0, 0}, color conversion id:none, color destination id:none, color profile id:include all profiles, trapped:false, font subset threshold:50.0}

set pdfName to docName & "TEST" & itemNumber & ".pdf"
set destFile to (fileLoc & pdfName) as string

save document 1 in file destFile as pdf with options pdfSaveOptions

set itemNumber to (itemNumber + 1)
end repeat
close current document without saving
end tell

TOPICS
Scripting

Views

4.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
New Here ,
May 13, 2009 May 13, 2009

Copy link to clipboard

Copied

bump...

Nobody has any ideas? Am I the only one looking for this ability out of CS4? Am I unclear or just doing something wrong?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 23, 2010 Oct 23, 2010

Copy link to clipboard

Copied

artboardRange doesn't seem to work in CS4.

It worked fine in CS5, in this example I saved all artboards, but I was also able to do 1 or 2 at a time.

http://forums.adobe.com/thread/727945?tstart=0

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 23, 2010 Oct 23, 2010

Copy link to clipboard

Copied

LATEST

Thanks for the confirmation. I just did a manual Save As… .AI version CS3 (or earlier) and it splits artboards — because it has to I guess — no multipage exists in that format.

2 or more hours to find the 10 second workaround . Still I learnt some more scripting tricks and tools along the way.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 23, 2010 Oct 23, 2010

Copy link to clipboard

Copied

I'm trying to do this right now using the Adobe sample script "SaveArtboardsAsPDF.jsx" as a start.

I don't no how to set the PDF options for page range. Where can I find the properties for this. I know pretty good JS (all be it in a different context than scripting Adobe apps) as opposed to almost no AppleScript. Will take either language for a result!

Please advice on PDF options properties to get me home somebody! Or at least point me in direction of the AI methods documentation

In JS and Pseudo Code so far:

// Save the artboards to PDF. // Get the folder location var destFolder = Folder.selectDialog('Select the folder to save the PDF files to:'); // Get the number of artboards to export from a dialogue

// Would be better to have an option to just query the appropriate property for total number of artboards in current document var total = Number.selectDialogue('Total Number of Files to be made') if (destFolder) {      for (i=0; i<total; i++)      {           var destFile = new File(destFolder + i);          //     Assign incrementing filename           var pdfSaveOptions = new PDFSaveOptions();           pdfSaveOptions.viewAfterSaving = false          //     Don't want to see these fles in Reader

        //     Need to Set a pdfSaveOption for page range as: from i to i // what property           documsaveAs (destFile,  pdfSaveOptions);     //  Is this going to save a new document rather than over the existing document 1?      } }     

Thanks in advance

Alastair

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 23, 2010 Oct 23, 2010

Copy link to clipboard

Copied

As a work around I opened some multipage AI docs in Acrobat. Then used the Extract pages… and Split… commands to generate multiple files. Only thing is each file has all the artwork in it.

When I open in the split files in AI, they have all the original artboards and artwork.

Thank you, Adobe. That just works, nice.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 23, 2010 Oct 23, 2010

Copy link to clipboard

Copied

I don't have a version of CS that has multi artboards but there is an artboardRange property that takes a string as parameter… Passing an empty string does all artboards… The easiest way to work with PDF options is just get a saved preset by name.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 23, 2010 Oct 23, 2010

Copy link to clipboard

Copied

Okay how can I get a Saved Preset assigned (by name)? Sorry I don't know how to access Application and Document properties yet 😕

How can I adjust the assigned var to reflect the iteration of page range (ie from: i, to: i)?

Meanwhile i'll try artboardRange, thanks for that!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 23, 2010 Oct 23, 2010

Copy link to clipboard

Copied

This is a list of the preset you have to choose from

alert(app.PDFPresetsList.join('\r'));

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 23, 2010 Oct 23, 2010

Copy link to clipboard

Copied

Thanks I'll look at PDFPresetsList.

I'll still need to adjust the preset for incrementing artBoard range though so not sure it's a step forward…

This is where I'm at presently. Mind you even if I get this going. I'm starting to doubt it will do what I want.

Manual Saving of page range 1-1 in Illustrator creates a file with ALL the artwork and ALL the artboards intact. Same for Split… and Extract commands in Acrobat Pro. This whole thing sucks. I should have just gone do it manually path like before. Only 22 pages to open and delete excess from, 3 minutes work turned into a 2 hour how could I script this now my JS is much stronger exercise.

Thanks for offering the advice though, Mark!

// Save the artboards to PDF. var myDoc = Document; // Get the folder location var destFolder = Folder.selectDialog('Select the folder to save the PDF files to:'); // Get the number of artboards to export from a dialogue var total =  myDoc.artboards.length //     Number.selectDialogue('Total Number of Files to be made') if (destFolder) {      for (i=0; i<total; i++)      {           var destFile = new File(destFolder+MyDoc.name+"_"+i);          //     Assign incrementing filenames           var pdfSaveOptions = new PDFSaveOptions();           pdfSaveOptions.viewAfterSaving = false;          //     Don't want to see these fles in Reader           pdfSaveOptions.artboardRange( i + "," + i);     //     Assign incrementing page range           documsaveAs (destFile,  pdfSaveOptions);           } }     

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 23, 2010 Oct 23, 2010

Copy link to clipboard

Copied

There are a few things that I see that are not quite right with your code. This is how I would go about this if I had CS4+ The artboards thing is pseudo code as I can't check this… But it may get you closer to what you want… I have seen posts B4 now on problems with artboard ranges but I have never been able to look at them…

#target illustrator function artboardsToPDFs() {      if (app.documents.length = 0) {           reurn;      }else{           var docRef = app.activeDocument;           var docName = docRef.name;           var nameString = '';           var extOffset = docName.lastIndexOf('.');           if (extOffset == -1) {                nameString = docName;           } else {                nameString = docName.substr(0, extOffset);           }           var destFolder = Folder.selectDialog('Select the folder to save the PDF files to:');           if (destFolder != null) {                var pdfSaveOptions = new PDFSaveOptions();                pdfSaveOptions.pDFPreset = '[Press Quality]';                /*                for (var i = 0; i < docRef.artboards.length; i++) {                     pdfSaveOptions.artboardRange(i);                     var destFile = new File(destFolder.fsName+'/'+nameString+'_'+i+'.pdf');                     docRef.saveAs(destFile, pdfSaveOptions);                }                */                     }      } } artboardsToPDFs();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 23, 2010 Oct 23, 2010

Copy link to clipboard

Copied

// Save the artboards to PDF. var myDoc = app.activeDocument; var original_filename = myDoc.name.toString(); // alert (myDoc.name.toString() ) // Get the folder location var destFolder = Folder.selectDialog('Select the folder to save the PDF files to:'); // Get the number of artboards to export from a dialogue var total =  myDoc.artboards.length //     Number.selectDialogue('Total Number of Files to be made') if (destFolder) {      for (i=0; i<total; i++)      {           var destFile = new File(destFolder+original_filename+"_"+i);          //     Assign incrementing filenames           var pdfSaveOptions = new PDFSaveOptions();           pdfSaveOptions.viewAfterSaving = false;          //     Don't want to see these fles in Reader           pdfSaveOptions.SaveMultipleArtboards = true;           var range = new String();           range = (i+1).toString();           pdfSaveOptions.artboardRange= range;     //     not Assign incrementing page range           myDoc.saveAs (destFile,  pdfSaveOptions);           } }     


I've run this script on the 3 art board document the Adobe sample scripts create. It's a just different coloured star on each artboard.

This script appears to work in as far as I get 3 files with just one artboard showing when I open the files in Adobe Reader. Problem is when I open them in AI, I can see all the artwork is still there and even more stranger is the fact that the numbers are still 1,2,3 whereas in Reader it's just page i showing as page 1 each time.

This could be a problem when the application I'm writing generates an image structure from the files if it sticks the excess data onto the GPU (not sure if it will or not). If it includes all the data, also it just makes the Application footprint bigger by a 8 MB or so of unnecessary baggage. An issue for a 'light weight' app.

I noticed the export ExportArtboardsPhotoshop.jsx script has this line:

psdExportOptions.saveMultipleArtboards = true;

It works in that context but in PDF context it only works in terms of what Reader shows not what exists in the files. Good one Adobe… Makes me wonder what the Multiple art boards method did before AI had multiple art boards. How was AI dividing the objects?!

Also I really need a SaveAsCopy (non-existent I think) method or I'll have to keep reopening the original file and then doing SaveAs.

Back to manual duplicating files in finder, batch renaming, opening them all and deleting excess. Or export to PSD and get my dimensions right or just oversized (I can always down sample in the app)…

This is truly a painful exercise!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Oct 23, 2010 Oct 23, 2010

Copy link to clipboard

Copied

wideEyedPupil wrote:


Makes me wonder what the Multiple art boards method did before AI had multiple art boards. How was AI dividing the objects?!

So I got to thinking lets try saying as a Legacy version because they can't have multipages, surely. Sure enough exporting as .ai then choosing CS version and Checking "Save each Artboard as a separate file": Radio button: All gives a fie with all artwork and one artboard and a series of files, one from each artboard with just the artwork inside the bounds of the respective artboard in the file. Only thing this time is the file size actually goes UP! by some 300% from 108 KB to 348 KB.

Guess that's how it is… now to write a script to save as Legacy then reopen them all and save to CS4 .ai or .pdf or something else vector and smaller. Compressed Tiffs are starting to look really handy about now

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines