I'm currently developing script (JS) for automated generating PDFs from templates filled with data from transformed XML.
I've prepared tagged and styled templates so it should be enough to import xml file and place it in the right way..
Everything is okay until I try to export PDF. At this point InDesign crashes and nothing is exported. I tested this issue on OSX 10.6.2.; OSX 10.5.8. Win XP. All machines have InDesign from legal CS4 Master Collection with all available updates. All machines have strong enough processor and RAM.
In case of automated import and manual export from InDesign it works. Automated export fails.
I enclose log from console:
12.11.09 12:40:53 com.apple.launchd.peruser.501 ([0x0-0x74074].com.adobe.InDesign) Job appears to have crashed: Segmentation fault
12.11.09 12:40:53 ReportCrash Saved crash report for Adobe InDesign CS4 version 126.96.36.1998 (6040) to /Users/Virus31/Library/Logs/DiagnosticReports/Adobe InDesign CS4_2009-11-12-124053_ASIANSTAR-3.crash
And also the script generating PDF
var myDocument = app.open(File("DocumentTemplate.indd"), true); //Set import prefs var myXMLImportPreferences = myDocument.xmlImportPreferences; myXMLImportPreferences.allowTransform = true; myXMLImportPreferences.createLinkToXML = false; myXMLImportPreferences.ignoreUnmatchedIncoming = true; myXMLImportPreferences.ignoreWhitespace = false; myXMLImportPreferences.importCALSTables = false; myXMLImportPreferences.importStyle = XMLImportStyles.mergeImport; myXMLImportPreferences.importTextIntoTables = false; myXMLImportPreferences.importToSelected = true; myXMLImportPreferences.removeUnmatchedExisting = false; myXMLImportPreferences.repeatTextElements = false; //Import and apply data (xml) with(myDocument) myDocument.importXML(File("Fake-Content.xml")); myDocument.xmlElements.item(0).placeXML(pages.item(0).pageItems.itemByName("Page1")); //Export and quit app.activeDocument.exportFile(ExportFormat.pdfType, File("TestDocument.pdf"),false); app.activeDocument.close(SaveOptions.no);
There are 2 more attached files (archive with source files + crash report) so you can try it on your own. I can't get what I'm doing wrong and I'm getting mad.
If you ever had this trouble let me know. Thank you.
It may not be relevant, but you have not set a path for the PDF. Put ~/ before the doc name for the PDF to be created in the top level of your home folder. Otherwise the PDF will be put inside the actual InDesign app (Right click app, show Package Contents - contents - MacOS)
This is the case with CS3 anyway. Not checked on CS4.
Thanks for the hint, didn't know that about saving, useful
Anyway even if I set the right path InDesign crashes.
I removed placeXML function and it works.. that's wierd. I finally found out that I dont need it.
This is just a pick from the whole code that creates pdfs from templates and xml data coming from webservice from Flex app.