6 Replies Latest reply on Oct 11, 2010 8:53 AM by jojoleo113

    Indesign Scripting : Generate a PDF

    jojoleo113 Level 1

      Hello,

       

      I've a bug with my script. All is OK:

       

      The script imports the xml file in my Indesign file and the new file generated (.indd) is correct...

       

      But this script generates PDF files with only 2 pages.

       

      Do you know the right code to generate big PDF files?

       

       

      This is my script:

       

      var myTemplate = File.openDialog("choose a template");

      var myFolder = Folder.selectDialog("choose a folder to process");


      var myDocs = myFolder.getFiles("*.xml");

      for (i = 0; i < myDocs.length; i++) {

      // open template :

      var newDoc = app.open(myTemplate);


      // import XML :

      var myXMLImportPreferences = newDoc.xmlImportPreferences;

      myXMLImportPreferences.allowTransform = false;

      myXMLImportPreferences.createLinkToXML = false;

      myXMLImportPreferences.ignoreUnmatchedIncoming = false;

      myXMLImportPreferences.importCALSTables = false;

      myXMLImportPreferences.importTextIntoTables = false;

      myXMLImportPreferences.importToSelected = false;

      myXMLImportPreferences.removeUnmatchedExisting = true;

      myXMLImportPreferences.ignoreWhitespace = true;

      myXMLImportPreferences.repeatTextElements = true;

      newDoc.importXML(myDocs[i]);

      // add additional document-specific processing steps here


      // save :

      var newFileName = myFolder.absoluteURI + '/' + myDocs[i].name.replace(/xml/, "pdf");

      app.activeDocument.exportFile(ExportFormat.pdfType, File(newFileName),false);


      var newFileName = myFolder.absoluteURI + '/' + myDocs[i].name.replace(/xml/, "indd");

      newDoc.save( new File( newFileName ) );

      app.activeDocument.close();

      }

       

       

      Thanks