Search code examples
apache-flexprintingflex4.5

Prevent Clipping while printing multi-page TextFlow using FlexPrintJob


I have a RichEditiableText component in a Flex 4.5 project and I want to print its contents. The problem I'm having is that component is holding a TextFlow and the copy is being clipped at the beginning/ending of pages. I can't seem to get it to respect the page breaks consistently.

I have this piece of code that adjusts the scroll position of the the RichEditableText component in a loop. Is there a better/smarter way to do this so that I ensure the text breaks to a new page appropriately?

 if(richEditTextComponent.contentHeight <= printJob.pageHeight) {                        
                printJob.addObject(richEditTextComponent, FlexPrintJobScaleType.NONE);
            } else {
                var max:Number = richEditTextComponent.contentHeight;
                var i:Number = 0;
                while(i<max) {
                    printJob.addObject(richEditTextComponent, FlexPrintJobScaleType.NONE);
                    richEditTextComponent.verticalScrollPosition += printJob.pageHeight;
                    i+=printJob.pageHeight;
                }
            }

Solution

  • Just for anyone else that has this problem...I ended up simply passing the copy to Javascript to handle printing. Turns out TLF is pretty cumbersome for type of thing.