8 Replies Latest reply on May 23, 2016 11:45 AM by jeremy0013

    return to unrasterized state

    jeremy0013

      Still in the process of writing a script to use variable data to save out print files and have come across having to rasterize one of the variable text fields.  Without using the obvious undo(); cause that doesn't work within a loop,  is there a way to return to an un-rasterized state? Any ideas are welcome.

        • 1. Re: return to unrasterized state
          Silly-V Adobe Community Professional

          Can you elaborate more on the exact scenario where rasterizing is required?

          Are you open to instead use the Rasterize Effect, which provides benefits of rasterizing while also retaining your base art?

          • 2. Re: return to unrasterized state
            jeremy0013 Level 1

            As the variable changes the text, each text area needs to be rasterized due to complicated fills (Camo, Carbon Fill etc).  Then un-rasterize to change to the next variable in line.  Make sense? I am using this with the last script you had helped me with.  Which I still owe you for. Thanks again.

            • 3. Re: return to unrasterized state
              moluapple Level 4

              Why not duplicate the text item and delete it when finish?

              • 4. Re: return to unrasterized state
                jeremy0013 Level 1

                Duplicating will only make the file larger.  I would rather keep the original element intact.

                • 5. Re: return to unrasterized state
                  moluapple Level 4

                  How can that make file larger if you delete it when finished?

                  Any way, you sure can use undo() within you for loop, simply add one line: app.redraw(), then app.undo(). Try this:

                  var t = activeDocument.textFrames.add();
                  
                  
                  t.contents = "welcome back!"
                  app.redraw();
                  
                  
                  for (var i = 1; i < 6; i++) {
                      t.contents = "Hello, here comes " + i;
                      app.redraw();
                      alert(t.contents);
                      app.undo();
                      alert(t.contents);
                  };
                  
                  
                  app.undo();
                  
                  • 6. Re: return to unrasterized state
                    jeremy0013 Level 1

                    The text already has a repetitive fill in it, then to duplicate and rasterize another on top of it would make it a much larger file.  Make sense.

                     

                    Anyhoo. i will try the above to see if I can get the desired result.  Thanks for the help M.

                    • 7. Re: return to unrasterized state
                      williamadowling Level 4

                      If i understand correctly, moluapple is suggesting that you delete the duplicate when you're done, ergo, the file size does not change.

                       

                      if you have:

                       

                      var art = (the vector art you want to rasterize)

                      var artCopy = art.duplicate();

                      artCopy.rasterize() // this is not the right syntax. i don't use rasterization in my workflow so i haven't learned it yet, but you get the point.

                      doFunctionOnRasterizedArt(param1,param2)

                      artCopy.remove();

                       

                      This way you can do whatever function you need to do on the rasterized art, then delete it when you're finished and there's no need to unrasterize.

                      • 8. Re: return to unrasterized state
                        jeremy0013 Level 1

                        SUCCESS!!  Redraw(); worked perfectly rasterizing then un-rasterizing as needed.  Below is a snippet of the code for reference.

                         

                             app.redraw();

                             for(var a=0;a<myLayer.pageItems.length;a++){

                                var currentItem = myLayer.pageItems[a];

                                    currentItem.selected = true; 

                                    idoc.rasterize( currentItem ,currentItem.visibleBounds, newoptions);

                             } 

                            docRef.saveAs(File("my.pdf"), myOpts);

                            app.undo();

                         

                        Thank You!!