Skip navigation
Currently Being Moderated

PrintJob Margin is AS2

Nov 29, 2012 1:57 PM

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);



    var myPrint:PrintJob = new PrintJob();



        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);




    delete myPrint;




Any thoughts?

  • Currently Being Moderated
    Nov 30, 2012 6:42 AM   in reply to jencarter

    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?

    Mark as:
  • Currently Being Moderated
    Nov 30, 2012 7:27 AM   in reply to jencarter

    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.

    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points