Skip to main content
Participant
May 7, 2009
Question

AS) export single page PDFs from multi-artboards

  • May 7, 2009
  • 3 replies
  • 4210 views

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

This topic has been closed for replies.

3 replies

Inspiring
October 23, 2010

// 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!

Inspiring
October 23, 2010

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

Inspiring
October 23, 2010

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

Inspiring
October 23, 2010

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.

panda42_sAuthor
Participant
May 13, 2009

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?

CarlosCanto
Community Expert
Community Expert
October 23, 2010

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

Inspiring
October 23, 2010

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.