5 Replies Latest reply on May 7, 2010 6:07 AM by beikbeik

    How to generate transparent preview of the document?

    Tomasz Bujlow Level 1

      Hi all,

       

      I would like to generate trsansparent preview of an document in PNG file. Normal (not-transparent preview) I am doing by JavaScript like it is described below:

       

      var myDocument = app.open(File(app.scriptArgs.getValue("documentPath")));
      myDocument.exportFile(ExportFormat.jpg, File(app.scriptArgs.getValue("thumbnailPath")), PDFExportPreset.acrobatCompatibility);
      myDocument.close(SaveOptions.no);

       

      The result is normal JPG file. But I would like to get a transparent image. How can I do this?

       

      Thank you for all information!

        • 1. Re: How to generate transparent preview of the document?
          [Jongware] Most Valuable Participant

          ExportFormat also has a PNG variant (ExportFormat.PNG_FORMAT), but if you want to know if it contains alpha transparency, you'll have to try it. There are no further parameters you can set.

           

          (..several minutes later..)

          And I just tried it myself. No: you cannot use it on "myDocument" (an entire document) -- only on "single" objects (a group is a single object).

          But, Yes: the background is transparent.

          1 person found this helpful
          • 2. Re: How to generate transparent preview of the document?
            Tomasz Bujlow Level 1

            Hmm could you give any example of code? According to the scripting reference there is nothing like "ExportFormat.PNG_FORMAT" - I cannot even find this in Google. On official Adobe webpage in the scripting reference I can find:

             

            Name Description Value
            TAGGED_TEXTExports to a tagged text file with a TXT extension.1416066168  =                 'Tgtx'
            PDF_TYPEExports to PDF format.1952403524  =                 't_PD'
            EPS_TYPEExports to EPS format.1952400720  =                 't_EP'
            RTFExports to rich text format (RTF).1381254688  =                 'RTF '
            SVGExports to SVG format.1398163232  =                 'SVG '
            SVG_COMPRESSEDExports to SVGZ format.1398163267  =                 'SVGC'
            TEXT_TYPEExports to text (TXT) format.1952412773  =                 't_te'
            XMLExports the document's tagged content to XML.1481460768  =                 'XML '
            JPGExports to JPEG format.1246775072  =                 'JPG '
            INDESIGN_INTERCHANGEExports to InDesign Interchange (INX) format.1229871136  =                 'INX '
            INDESIGN_SNIPPETExports to InDesign Snippet (INDS) format.1936617588  =                 'snpt'
            INCOPY_CS_DOCUMENTExports to InCopy CS document (INCD) format.1702126436  =                 'etcd'
            INCOPY_DOCUMENTExports to InCopy document (INCX) format.1702126456  =                 'etcx'

             

            and this is all (http://www.indesignscriptingreference.com/CS3/JavaScript/ExportFormat-enum.htm). When I am trying to use the code on a group of objects, it is failing. The code:

             

            var myDocument = app.documents.add();
            myDocument.pages.item(0).place(File(app.scriptArgs.getValue("snippetPath")));

            g = myDocument.pages.item(0).groups.add (myDocument.pages.item(0).allPageItems);
            g.exportFile(ExportFormat.PNG_FORMAT, File(app.scriptArgs.getValue("pngThumbnailPath")), PDFExportPreset.acrobatCompatibility);

            myDocument.close(SaveOptions.no);

             

            And the error:

             

            Error Number: 55
            Error String: Object does not support the property or method 'PNG_FORMAT'
            Line: 6
            Source: g.exportFile(ExportFormat.PNG_FORMAT, File(app.scriptArgs.getValue("pngThumbnailPath")), PDFExportPreset.acrobatCompatibility);

            • 3. Re: How to generate transparent preview of the document?
              [Jongware] Most Valuable Participant

              That's what you get for not mentioning your InDesign version ... PNG_FORMAT has been added in CS4.

               

              Oh, and thanks by the way for reminding me of that site.

               

              On official Adobe webpage...

               

              Don't make me laugh. "That's funny -- it looks suspicously much like the HTML I bloody generated a while ago from the provided Help files" is what I said when I first saw it.

               

              A full Javascript reference for both CS3 and CS4 scriptable objects can be found on http://www.jongware.com/idjshelp.html -- and those are the original results of my own hard work, not some pirated and unacknowledged and heavy-advertising piece of theft.

              • 4. Re: How to generate transparent preview of the document?
                Tomasz Bujlow Level 1

                Thank you for the information!

                • 5. Re: How to generate transparent preview of the document?
                  beikbeik

                  Hey Jongware, do you know if there was any changes in the export format for PNG in the CS5?

                   

                  Im trying to make a "export selection to png" script, but I dont know why the quality of the PNG generated in CS4 is so poor...