Skip to main content
November 19, 2010
Question

Printing the next page of a Datagrid in flash\air

  • November 19, 2010
  • 1 reply
  • 1664 views

Hi, I can only print the first page of my datagrid but not the next pages?? Any help with my code will

be appreciated very much!

function printProducts(evt:MouseEvent):void
{
Dg_prods.rowCount = Dg_prods_Rowcount;
Dg_prods.visible = false;

sheets=Dg_prods.numChildren;
printContainer=new Sprite();
addChild(printContainer);

printJob=new PrintJob();
PrintOptions=new PrintJobOptions();
PrintOptions.printAsBitmap=false;
  
if(printJob.start()){try{addContentSheet();}
catch(error:Error){trace("error");}printJob.send();removeContentAndSprite();}else{removeChild(printContainer);}


function addContentSheet():void
{
for (var i:int=0;i < sheets;i++)
{
printContainer.addChild(Dg_prods.getChildAt(0));
printContainer.scaleX  = .30;
printContainer.scaleY  = .30;
printContainer.width = printJob.pageWidth;
}
printJob.addPage(printContainer,null,PrintOptions);
}
 
function removeContentAndSprite():void
{
if(Dg_prods_Rowcount > 26) {Dg_prods.height = 560;}
Dg_prods.visible = true;
for (var i:int=0;i < sheets;i++){Dg_prods.addChild(printContainer.getChildAt(0));}removeChild(printContainer);
}
}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
November 19, 2010

datagrid's don't have pages.  do you mean when you scroll your datagrid and then add it to your printjob you fail to see the scrolled content?

November 19, 2010

Thanx for your response kglad.

My problem is it only prints one page eg. it adds my datagrid to the page but everything after page one is "discarded".

If I trace "sheet" it gives me the total pages which is 6, but only adds\prints one(first page).

What I've done is "Dg_prods.rowCount = Dp.length" so the DG doesn't have to be scrolled and the full lenth is "visible" to the print job.

Everything is perfect execept I don't know how to get it to print past page one\add the remaining data to the next page and so forth...??

kglad
Community Expert
Community Expert
November 19, 2010

where are you adding more than 1 page to your printjob?