XObject: call to earlier spawn is lost after closing session
Hi there,
Very very new to javascript and still plowing through trying to get my document to work. I have had success with using this code (from George) on a spawn button to spawn two pages as XObjects, and then spawn two pages that refer to those XObjects (saving file space).
var aTemplates = this.templates;
var T1 = aTemplates[0];
var T2 = aTemplates[1];
var XO1 = T1.spawn(this.numPages, true, false);
var XO2 = T2.spawn(this.numPages, true, false);
for (var i = 0; i < 1; i++) {
T1.spawn(this.numPages, true, false, XO1);
T2.spawn(this.numPages, true, false, XO2);
}
This did well to shave the file size by over 50%, however I still have to spawn the XObjects each time for the subsequent spawns to have something to refer back to.
The document is to eventually spawn 60 pages (30 generations of a two page template), and I thought I was oh so smart thinking that I could further save space by running the script in console to set the XObject pages, and then only apply the portion of the script to the button that calls back to the XObject, meaning I could spawn all the pages while only referring to the earlier XObject pages.
This seems to work only in the same Adobe session - even after saving within the session it works, but once I save and close the document and reopen it, there is no recognition of the earlier XObject spawn (T1 is undefined).
Is there a way to spawn and retain the reference to the XObject at a different level than at the time of the event trigger button, or do I absolutely have to spawn the XObject each and every time with the even trigger button?
Thank you!
