Copy link to clipboard
Copied
Hi,
I'm trying to develop a script that adds a number of AI-files to a new ID-document, saves the document and then exports the ID-document as PDF. Most of it seems to be working fine, but when I reach page 30-35(depending on which files I add), ID runs out of memory.
It's using ~1,3 GB memory, which is quite a lot, so the error is understandable.
What I don't understand is why it takes that much. At first I tried exporting the entire file at once (which gave me the above mentioned error and no output-file at all). I then added a "while-loop" that exported each page into it's own file (called 1.pdf, 2.pdf, 3.pdf etc.). Same result.
I tried adding $.gc(); x 2 for every 10 page that gets exported, but that doesn't seem to change anything whatsoever. The code can be seen here (I removed the pdf-prefs, since they aren't relevant I think):
"Counter" is a variable starting a 1, and "numberOfPages" is a variable containing the number of pages in the document. I'm at a bit of a loss here. Shouldn't InDesign release the memory, once it has exported each page?
while(counter <= numberOfPages)
{
if(counter == 10 || counter == 20 || counter == 30)
{
$.gc();
$.gc();
}
with(app.pdfExportPreferences)
{
//set the pagerange to the current page (counter) - convert to string to set pageRange to accept input
myString = counter + "";
pageRange = myString;
lots of other pdf preferences goes here - deleted for readability
}
try
{
myDocument.exportFile(ExportFormat.pdfType, File(myFolder +"/" + counter +".pdf"), false, myPDFExportPreset);
}
catch(e)
{
alert(e);
}
counter = counter + 1;
}
Let me know if you need further info.
Thanks in advance,
Thomas
Copy link to clipboard
Copied
Are you running in #targetengine main and did you try adding var in front of your variables, they are missing from what you posted
Copy link to clipboard
Copied
Hi Trevor,
I just tried adding #targetengine main to the top of my script - no luck unfortunately.
All variables have been declared using the standard "var counter;", "var myString" etc.
Copy link to clipboard
Copied
my 2 cents:
it's not a scripting problem, but a data one.
for testing sake try changing from importing illustrator to simple TIFFs or JPGs.
rendering and exporting pdf (or .ai's) eats up tons of memory. at least in windows.
if that's the case, you can try to delete the page after it is exported.
Copy link to clipboard
Copied
You're probably correct. The files do tend to get quite heavy. But I was expecting Indesign to be able to release the memory after exporting a single page. Alas, it doesn't do that. I could also delete the page, but we would like to save the .indd-file as well
But I tried, just for the fun of it, to close the document and open it again after every 10 pages - and et voilá. It worked! It's not beautiful and I'm not gonna win any awards for it, but for now it'll have to do