2 Replies Latest reply on Jan 27, 2015 12:36 PM by BrettA

    Speedy Data Merge (in the background)



      Doing this manually, after linking the source file etc. with the:

      Data Merge (Panel) > "Export to PDF" (Flyout)

      I'm able to export to PDF successfully without doing any of the steps that will either ask InDesign to "Preview" the records or generate another copy document with the "Merged Records".

      I'm trying to match this in the script I'm working on (that it skips those steps in order to speed up the generation of the output file).

      Currently I'm having to use "app.activeDocument.dataMergeProperties.mergeRecords ()" before the traditional "ExportFile" which in turn is creating the separate "Merged Document", then having to close both (slow).


      So, if I can get some help with the question above, is there a way to trigger the functionality of "Data Merge (Panel) > "Export to PDF" (Flyout)" within Extendscript?


      Thanks so much for any help!

        • 1. Re: Speedy Data Merge (in the background)
          Loic.Aigon Adobe Community Professional



          Did you try the exportFile method of the DataMerge object ?


          void exportFile (to: File[, using: PDFExportPreset][, outputOversetReportFile: File])

          Merges records and exports to PDF.



          • 2. Re: Re: Speedy Data Merge (in the background)
            BrettA Level 1

            Hi Loic, thanks for taking the time to answer. I've tried everything I can think to throw at merging and exporting a PDF in one step.


            I even found this in the Object Model Viewer:

            DataMerge.exportFile (to: File , using: PDFExportPreset , outputOversetReportFile: File )

            Adobe InDesign CC 2014 (10.0) Object Model


            But for me (may be doing something wrong), it always generates an "un-merged" PDF with the placeholder (i.e. <<FirstName>>). Yes, running "dataMergeProperties.mergeRecords ();" works, but it's slow, and leaves me with the "Template" and the merged InDesign Document open.


            Still, manually using "Data Merge (Panel) > "Export to PDF" (Flyout)" merges and exports without 1) creating a separate Merged Document and 2) or even having to invoke "Preview" which would speed up this script.


            Here's a rough draft script, any thoughts? and... thanks again!


            var curFile = File ("~/Desktop/myTemplate.indt");
              var curDoc = app.open(curFile, false);
              var curData = File("~/Desktop/myData.txt");
              with (curDoc){
                   dataMergeOptions.fittingOption = Fitting.PRESERVE_SIZES;
            void app.activeDocument.exportFile(ExportFormat.pdfType, File("~/Desktop/myTestDocument.pdf"), false);
            // void curDoc.exportFile(ExportFormat.pdfType, File("~/Desktop/myTestDocument.pdf"), false);