3 Replies Latest reply on Nov 30, 2012 7:27 AM by sinious

    PrintJob Margin is AS2

    jencarter

      I am creating a print job to print a large mc inside a scrollpane that will need to be broken up into multiple pages when printed.  I can break the pages, but I want to add margins to the printed pages.  Here is what I have so far:

       

      function print_page()

      {

          var printableHeight = 750;

          var objHeight = update_mc._height;

          var objWidth = update_mc._width;

          var numberOfPages = Math.ceil(objHeight / printableHeight);

          scrollPane.content.setMask(null);

         

          var myPrint:PrintJob = new PrintJob();

          {

              myPrint.start();       

              for (i = 0; i < numberOfPages; i++)

              {

                  yStart = i * printableHeight;

                  yEnd = ((i + 1) * printableHeight) - 1;

                  printArea = {xMin:0, xMax:objWidth, yMin:yStart, yMax:yEnd};

                  myPrint.addPage(update_mc, printArea);

              }

          };

          myPrint.send();

          delete myPrint;

          scrollPane.content.setMask(scrollPane.mask_mc);

      }

       

      Any thoughts?

        • 1. Re: PrintJob Margin is AS2
          sinious Most Valuable Participant

          You have the right general idea. My approach would be to directly use the ScrollPanes content. I'd grab the portion I need by drawing it into a new display object that I've tested to print properly. Then iterate over the rest of the image similar to how you update your yStart, continuing to print until done.

           

          I'm not sure where "update_mc" is coming from, I don't see it instantiated or assigned in that code. Is that a snapshot?

          • 2. Re: PrintJob Margin is AS2
            jencarter Level 1

            update_mc is the movie clip in the scrollpane that I am wanting to print. Thanks for the reply, I will try that.

             

            jen

            • 3. Re: PrintJob Margin is AS2
              sinious Most Valuable Participant

              If you create a BitmapData object you can draw() a portion of another DisplayObject (Sprite, MovieClip, Bitmap, etc) into it. You can use that data to print. It's a common technique for saving memory called blitting and it's very fast.

               

              Let me know if you get it to work, run into trouble or need an example let me know.