3 Replies Latest reply on Apr 6, 2008 8:14 PM by (sunilkumarrajup)

    JPEG single page export from multipage document

      Hello Experts: I have a function to create a JPEG file given a page number from a multipage document. The problem is that InDesign Server will actually create JPEG files for all the pages -despite the given page range (I just want to create one). It appends the page number starting on page 2 (and will create the JPEG's desired file name for the first page in the document, and so on)

      Here is my sample code:

      Somewhere I will initialize the document to use it globally:
      currentDocument = app.documents[0];

      Here is my current function:

      function ExportAsQualityJPG(inSaveAsDocumentPath, inPageNumber)
      app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.maximum;
      app.jpegExportPreferences.resolution = 300;

      pageName = currentDocument.pages.item(inPageNumber-1).name;
      app.pdfExportPreferences.pageRange = pageName;
      // app.jpegExportPreferences.pageString = pageName; --> Does not work

      currentDocument.exportFile(ExportFormat.jpg, File(inSaveDocumentPath), app.pdfExportPresets.item("[High Quality Print]"));

      I will do something like later:

      ExportAsQualityJPG("//Documents/InDesign/Page2.jpg", 2);

      As I mentioned above, it will actually create images for all pages in the document. For example, if the INDD doc has 3 pages, it will create these images:
      Page2.jpg (actual page 1)
      Page22.jpg (actual page 2)
      Page23.jpg (actual page 3)

      Any help or tip would be really appreciated.


        • 1. Re: JPEG single page export from multipage document
          The problem is that you are trying to use the pdfExportPreferences to set the page range. You should instead use the jpegExportPreferences to do this. Here is an example:

          app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_RANGE;
          app.jpegExportPreferences.pageString = "3";

          FYI, to export multiple pages:
          app.jpegExportPreferences.pageString = "1-3, 5, 7";

          or to do all pages:
          app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_ALL;

          JPEGExportPreference.pageString represents the page(s) to export, specified as a page number or an array of page numbers. Note: Valid only when JPEG export range is EXPORT_RANGE.

          • 3. Re: JPEG single page export from multipage document
            Level 1
            hi every one,my problem is,iwant to merge all records in one page,actually iam merging .csv data with multiple records,with .indd and then iam conveting this .indd to pdf,but iam getting 6 pages pdf,but i want to merge all records in one pfd page.can anyone help me to do this..please it urgent for me..my script is below please go throught that..and help me..waiting for your replies..please...this my whole script please help me ...its urgent

            //An InDesign CS3 JavaScript
            //Performs a data merge given an InDesign template
            //file and a data file.
            function main()
            //You'll have to fill in valid files names on your system
            //for the data file and the InDesign template file.
            var myDocument = app.open(File("/d/inpage1/template.indd"));
            var myDataSource = File("/d/inpage1/datasheet.csv");
            //If you do not provide a file name, InDesign displays the Save dialog box.
            app.documents.item(0).save(new File("/c/myTestDocument.indd"));

            //Close the document.

            //to a selected destination folder.
            //An InDesign CS3 JavaScript

            var mySourceFolder =Folder("/c/");
            //var mySourceFolder = Folder.selectDialog("Choose a sourceFolder");
            //if(mySourceFolder != null){
            var myDestinationFolder = Folder("/c/");
            // var myDestinationFolder = Folder.selectDialog("Choose a destination folder");
            // if(mySourceFolder !=null){
            myDisplayDialog(myDestinationFolder, mySourceFolder);

            function stripExt (f) {
            return f.substring(0,f.length-4);
            function myDisplayDialog(myDestinationFolder, mySourceFolder){
            var myPDFPresetList = new Array;
            myPDFPresetList.push("Current PDF Export Settings");
            for(var myCounter = 0; myCounter < app.pdfExportPresets.length; myCounter ++){

            var myPDFExportPreset = myPDFPresetList[0];
            myExportFiles(myDestinationFolder, mySourceFolder, myPDFExportPreset);

            function myExportFiles(myDestinationFolder, mySourceFolder, myPDFExportPreset){
            //Assumes that your InDesign files have the file extension .indd.
            var myDocuments = mySourceFolder.getFiles("*.indd");
            if(myDocuments.length > 0){
            //Turn off user interaction to avoid missing font/link/plug-in warning dialogs.

            for(myCounter = 0;myCounter < myDocuments.length; myCounter ++){
            var myDocument = app.open(myDocuments[myCounter]);
            var myPDFFile = new File(myDestinationFolder +"/" + stripExt(myDocument.name)+"pdf");
            //Export the document using the current PDF export settings.
            if(myPDFExportPreset == "Current PDF Export Settings"){
            myDocument.exportFile(ExportFormat.pdfType, myPDFFile);
            myDocument.exportFile(ExportFormat.pdfType, myPDFFile, myPDFExportPreset);