Save artboards to pdf with customizable number of artboards
Hi community, hope you are doing awesome, can I get some help with some pdf export issues I am facing?
What I have is:
try {
var doc = app.activeDocument;
var totalArtboards = doc.artboards.length;
for (var i = 0; i < totalArtboards; i++) {
doc.artboards.setActiveArtboardIndex(i);
alert("seleccionando artboard " + i);
doc.selection = doc.artboards[i].artboardRect;
alert("exportar")
var exportFile = new File(doc.path + "/Artboard_" + (i + 1) + ".pdf");
var saveOpts = new PDFSaveOptions();
doc.saveAs(exportFile, saveOpts);
alert("exportado " + i);
}
doc.artboards.setActiveArtboardIndex(0);
alert("Each artboard exported as a separate PDF file.");
} catch (e) {
alert("Error: " + e);
}
and what I am looking for is to let the user specify how many artboards he wants to export, if I have a 17 artbaords file and I typed number "5" as the artbaords I need to be exported, the code will create 4 files, meaning: files 1,2 and 3 will have 5 of the artboards (using a loop with the artboard index) and the 4th file will have 2 artboards, total: 17 artboards. If i have an 8 artboards document and I typed 2 as the number of artboards the code will export 4 files with 2 arborads inside each file, do I explain?
I found this, but I have no idea how to modify it, right now, Illustrator crashes every time I try my code, can I have some help please? thanks
