5 Replies Latest reply on May 7, 2009 5:56 AM by AdobeScripts

    [JS] Testing whether PageItem will printing anything

    pfd20090428

      There are a slew of attributes that determine whether a PageItem will actually result in something being printed on a page.  For example, the PageItem could be non-printing, or transparent, or have 0 thickness strokes, or no stroke or fill color, etc.  It may or may not have a drop shadow, halo, etc.

       

      Testing all of these attributes seems excessive.  Is there any reasonable way to determine whether a PageItem will actually result in any output if, for example, exportFile() is called on the page?

       

      I'm trying to output EPS files, but only if there are objects that will cause marks to be drawn on the page.  Otherwise, I get EPS files that fail in Distiller and report that no PDF was output because the EPS was empty.

       

      Any suggestions?

       

      Thanks!

      -pd

        • 1. Re: [JS] Testing whether PageItem will printing anything
          [Jongware] Most Valuable Participant

          A reasonable way? Like a boolean value? No -- ID doesn't check if you are actually printing something (the one exception being that blasted "Include blank pages" that's OFF by default!).

           

          Unfortunately, there are tons of reasons any given object will print, and you have to check them all before deciding it does not.

           

          non-printing, or transparent, or have 0 thickness strokes, or no stroke or fill color

           

          Each and every one of those 'or's should be and; each single one on its own can leave a mark on the page. (Not that entire list, but you know what I mean.)

           

          From your list, I'm missing at least the following:

          • Is the layer it is on visible? (If not, you are done!)
          • Is the layer set to 'Nonprinting'? (Ditto.)
          • Does the object contain text? Have to check its attributes -- fill, stroke. If it contains footnotes, anchored objects, tables: if the 'main' text is invisible, check all of these.
          • Does it contain any other objects? Have to check their attributes as well -- recursively! Fortunately, the very first positive "Does print" hit is definitive for all objects higher up in the chain. Check allPageItems -- this superclass should cover all possibilites, except (I think) Buttons.

           

          How bad do you consider the Distiller error? It might be easier to handle that gracefully instead.

          Another way would be to cheat, and put something paper coloured on every page

          1 person found this helpful
          • 2. Re: [JS] Testing whether PageItem will printing anything
            pfd20090428 Level 1

            Thanks very much, Jongware.  I wasn't expecting something as straightforward as a single boolean, but as you confirmed, it's pretty haywire now, with dozens of things that need to be checked.  I wonder if there's an easier way at the plugin SDK level.

             

            Basically, for a certain workflow, I'm trying to separate documents into image and non-image items.  The image items will use the original source JPEG, TIFF, etc., while the non-image items will get output to EPS.  So, if I encounter a PageItem that just contains a single Graphic, then the PageItem itself may or may not add anything to the Graphic in terms of printing results ... border, drop shadow, etc.  Unfortunately, this workflows fails if one of the EPS files produces no output in Distiller.

             

            Thanks!

            -pd

            • 3. Re: [JS] Testing whether PageItem will printing anything
              Harbs. Level 6

              >

              Any suggestions?

               

              Doing all that recursive checking is very very difficult!

               

              What about putting a rectangle filled with on the bottom layer 

              of every page? That should insure that the EPS files will not be empty.

               

              Harbs

              http://www.in-tools.com

              1 person found this helpful
              • 4. Re: [JS] Testing whether PageItem will print anything
                pfd20090428 Level 1

                Thanks.  Putting a "Paper" rectangle on the back of the page is a possibility, though certainly not the most efficient.  I may wind up doing that in the short term, but for the long haul, I'd like to completely eliminate any EPS that doesn't actually contain anything, for efficiency.

                 

                I guess another approach would be to scan the EPS file after it's written to see if it actually draws anything.  Using the DSC comments, this shouldn't be too difficult.

                 

                Thanks!

                 

                -pd

                • 5. Re: [JS] Testing whether PageItem will printing anything
                  AdobeScripts Level 3

                  hi

                   

                  1) move your item(s) to new empty document

                   

                  2) set FALSE to:

                   

                  Property PrintBlankPages As Boolean
                      Member of InDesign.PrinterPreset
                      Whether to print blank pages

                   

                  3) try to print - you should get error if nothing will be printed - catch it

                   

                  you will get error when object is non-printing, no fill and no stroke, but 0% of opacity still will print it - you need to check all other posibilities

                   

                  if you are working in CS4 - I think you can play with Preflight options and presets ...

                   

                  robin

                   

                  www.adobescripts.co.uk