Skip to main content
Participating Frequently
December 17, 2009
Question

printing multiple pages?

  • December 17, 2009
  • 1 reply
  • 1137 views

Hi--

I've been killing myself for weeks on this issue and still can't figure it out.

I'm importing a large text file and trying to print it with a footer. My method for all of this is very simple. I'm dynamically creating a sprite container that is fed to the the printjob() class. Inside that I'm creating a dynamic text field and scaling it to the right page height/width (408x574) and adding a footer below that.

Using a loop, I'm scrolling the text field to the top of the next page and adding the page number to the footer and adding the page to the job. Mostly, this works fine, but I'm noticing some lines from the text field are not printing. This happens at the page breaks and is not consistent across different printers I use.

Essentially, this is the code I use to print:

if (pj.start()) {

        rect1 = new Rectangle(-60,-66,540,720);

        for (i=0;i<10;i++) {

            pj.addPage(container,rect1);

            tf.scrollV+=56;

            container.footer.pageNum.htmlText="- "+Number(i+1)+" -";

        }

        pj.send();

        pj=null;

    }

This whole project has been more than a little frustrating because I'm getting so many conflicting pieces of data. For example, using textLineMetrics, I learned each and every line of my text field is 14 pixels high. That's why I'm using the 574px height. That equates to 41 lines of text, but viewing it onscreen, it's more than that.

Please...please! If anyone can offer some insight or a fix for this, I'll be very grateful.

Thank you!

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
December 17, 2009

assign text to each textfield character-by-character while checking the sprite's height with the footer already added.  when the height exceeds your printjob's pageHeight minus the footer's height, back up the text to the previous logical (eg, space) break.  add that page to the printjob and proceed with the next page.

Participating Frequently
December 17, 2009

Thank you for the reply!

I've considered doing this, but the problem is my incoming text contains html tags (<u></u>, etc) so the values I'd get back would be inaccurate since those tags disappear when creating the output. My first solution to that was to apply the text to another textfield and select/copy what would fit, but then I ran into the problem of how to move the selected HTML text to another field while maintaining the formatting.

What baffles me most of all is why can I add text to a text field on the stage, scroll it X number of lines and see it working every single time, but when I try to capture that area with printJob() it fails?

kglad
Community Expert
Community Expert
December 17, 2009

it's going to be more complex to deal with with html text.

and, as you already know, know you see on-screen is not exactly what you see on a printed page.