5 Replies Latest reply on Jun 9, 2017 7:33 AM by moluapple

    Printing in a PDF with Filename - Folder and Filename are ignored

    AndyWizz Level 1

      With a script for Illustrator I try to make the printing-process for our staff easier. They need to specify different Folders for A4 and A3 PDFs.


      First thoughts: I have Illustrator-Files with different Artboard-sizes and Page Orientations. Our RIP does not recognize the document-pages being A4 or A3. So I have to split the File in at least two PDFs, one is A4, one is A3. All of them must be in Portrait-Mode so that A4 and A3 is used completely. Printing in a PDF (Windows workflow) works with PrintOrientation set to AUTOROTATE.

      Rotating the artboards with all Objects and save as PDF would be great but I figured out it's pretty complicated. So I would like to go on with printing in a PDF and using the Autorotate feature.


      Where I am stuck: The filename and the printJobOptions seem to be ignored. I need to specify the path of the filename and the Media-Size but the PDF-Settings of the virtual PDF-Printer I am using as standard seem to be used first and all the properties in the Script are overwritten. This is the Standard-Setting of the PDF:


      This is the script so far:

      #target Illustrator
      #targetengine main
      var originalInteractionLevel = userInteractionLevel;
      userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
      var docRef = app.activeDocument;
      var options = new PrintOptions();
      /* printJobOptions.printPreset = 'Netzfeld-test'; */
      // Printer
      options.printerName = 'Adobe PDF';
      options.PPDName = 'Adobe PDF';
      // Fonts
      var fontOpts = new PrintFontOptions();
      fontOpts.downloadFonts = PrintFontDownloadMode.DOWNLOADCOMPLETE;
      fontOpts.fontSubstitution = FontSubstitutionPolicy.SUBSTITUTETINT;
      options.fontOptions = fontOpts;
      // Color
      var colorOptions = new PrintColorManagementOptions();
      colorOptions.intent = PrintColorIntent.RELATIVECOLORIMETRIC;
      colorOptions.colorProfileMode = PrintColorProfile.CUSTOMPROFILE;
      colorOptions.name = "Coated FOGRA39 (ISO 12647-2:2004)";
      options.colorManagementOptions = colorOptions;
      // Seperation
      var sepOptions = new PrintColorSeparationOptions();
      sepOptions.convertSpotColors = true;
      sepOptions.overPrintBlack = true;
      sepOptions.colorSeparationMode = PrintColorSeparationMode.COMPOSITE;
      sepOptions.colorProfileMode = PrintColorProfile.SOURCEPROFILE;
      options.colorSeparationOptions = sepOptions;
      // Print Coordinates
      var coordinateOptions = new PrintCoordinateOptions();
      coordinateOptions.emulsion = false; // reverse from right to left
      coordinateOptions.fitToPage = false; // fit artwork to page size
      coordinateOptions.position = PrintPosition.TRANSLATECENTER;
      coordinateOptions.orientation = PrintOrientation.AUTOROTATE;
      options.coordinateOptions = coordinateOptions;
      // Filename and Artboards are ignored
      var printJobOptions = new PrintJobOptions();
      options.printJobOptions = printJobOptions;
      // Filename
      var docPath = new File('C://_temp//bla.pdf');
      printJobOptions.file = docPath;
      // Artboards
      printJobOptions.designation = PrintArtworkDesignation.VISIBLEPRINTABLELAYERS;
      printJobOptions.printArea = PrintingBounds.ARTBOARDBOUNDS;
      printJobOptions.collate = true;
      printJobOptions.printAllArtboards = false;
      printJobOptions.artboardRange = '1';
      // Print
      userInteractionLevel = originalInteractionLevel;

      What's wrong with it? What's missing?
      The example in the Scripting Manual of Illustrator on page 176 doesn't seem to work either when I print to PDF: http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/illustrator/sdk/CC2017/Illustrator_ JavaScript_Scripting_Reference.pdf

        • 1. Re: Printing in a PDF with Filename - Folder and Filename are ignored
          Silly-V Adobe Community Professional

          var docPath = new File('C://_temp//bla.pdf'); <-- can you try with just one single slash last? 'C://_temp/bla.pdf'

          • 2. Re: Printing in a PDF with Filename - Folder and Filename are ignored
            AndyWizz Level 1

            Thanks for your prompt answer,
            I really appreciate this.
            I tried this before but it didn't change anything. The complete Filename and Artboards seem to be ignored and the setting from the PDF-Joboption overwrites everything although I haven't set it in the Script.

            • 3. Re: Printing in a PDF with Filename - Folder and Filename are ignored
              moluapple Level 4

              How about set the file path in the "Adobe PDF Setting" to "Documents/*.pdf", print it and then copy and rename the file to desired folder?

              • 4. Re: Printing in a PDF with Filename - Folder and Filename are ignored
                AndyWizz Level 1

                The Script is only a part of a bigger one and about 50 Designers will use it in a corporate environment to distribute their print-outs on different printers. Renaming and putting the PDF to the Printing Hotfolder would take too long in order to the manual printing in PDF-workflow and it's neccecary to generate at least two PDF-Files (A4 and A3). The Files of the Designers consist of different Artboards with A4 and A3-Pages and different Page-Orientations. The PDFs are about to be saved in different Folders. The Folder-Path and name consists of the printer and the Pagesize.

                The RIP does only work with Pages of A4 or A3 and in Portrait-Mode, the small side first.
                Therefor I have to rotate the pages.

                I made up my mind and consider the second possiblity now:
                Export to PDF
                The Problem is the rotation of the artboards. I have an idea for a workaround but that's beyond my scripting abilities.

                Here is what I've done so far and a better explanation:

                Starting with a small script it's now a little project I cannot complete myself, I think.

                • 5. Re: Printing in a PDF with Filename - Folder and Filename are ignored
                  moluapple Level 4

                  Hi, you can test this:

                  Make mask > rotate mask group > rotate artboard > save pdf.

                  #target illustrator  
                  var docRef = app.activeDocument;  
                  var artboardRef = docRef.artboards;
                  app.executeMenuCommand ('unlockAll');
                  var a4 = [], a3 = [];
                  for(var i=0;i<artboardRef.length;i++){  
                      var top=artboardRef[i].artboardRect[1] ;  
                      var left=artboardRef[i].artboardRect[0];  
                      var width=artboardRef[i].artboardRect[2]-artboardRef[i].artboardRect[0];  
                      var height=artboardRef[i].artboardRect[1]-artboardRef[i].artboardRect[3];  
                      app.selection = null;
                      if (width > height) {
                          var rect = docRef.pathItems.rectangle (top, left, width, height);  
                          app.executeMenuCommand ('selectallinartboard');
                          app.executeMenuCommand ('makeMask');
                      if (width > 1000 || height > 1000) {
                      } else {
                  savePDF('_A3', a3.join(','));
                  savePDF('_A4', a4.join(','));
                  // Save the artboards to PDF.
                  function savePDF(size, range) {
                      var ordner = '~/desktop/'; 
                      var dateiNameExt = activeDocument.name.split( "." ); 
                      var dateiName = dateiNameExt[dateiNameExt.length-2];
                      var destFile = new File (ordner + dateiName + size + ".pdf");
                      var pdfSaveOptions = new PDFSaveOptions();
                      pdfSaveOptions.generateThumbnails = false; //keine Thumbnails
                      pdfSaveOptions.preserveEditability = false; //keine Edierbarkeit, also keine AI-Daten
                      // pdfSaveOptions.printerResolution = 300.0; //Optional. Flattening printer resolution. Default: 800.0
                      pdfSaveOptions.viewAfterSaving = false; //Ansicht nach der PDF-Erstellung
                      pdfSaveOptions.artboardRange = range;
                      docRef.saveAs (destFile,  pdfSaveOptions);