Rodrigo, Thank you. It works OK on a windows PC, regardless the error about too big a size. But on the MAC it prints complete black pages. If I print to PDF it works but sometimes it fails because of running script time...
I switch to AlivePDF now, but if anyone is interested in my PrinterOutput class, here it is: If someone detects where I am going wrong, don't hesitate to tell me :-) ----------------------- BEGIN CODE /* The Rectangle object's dimensions (width and height) are set in pixels. The printer, however, uses points as measuring units instead of pixels. Points have a fixed physical size - 1/72 of an inch, while a pixel on the screen depends on the resolution of that screen. The transformation multiplier between pixels and points depends on the printer's settings and the Sprite object's scale. A non-scaled Sprite object that has a width of 72 pixels will be printed with 1 inch in width. One point will equal one pixel, no matter what the screen resolution is. Here are some of the relations that might come in handy: 1 point = 20 tweeps = 1/72 inches 1 inch = 72 points = 1440 tweeps 1 cm = 567 tweeps Beeldscherm 72 pixels/inch: 8,268 x 11,693 inch = 21 x 29,7 cm = 595 x 842 pixels Printer 300 pixels/inch: 8,268 x 11,693 inch = 21 x 29,7 cm = 2480 x 3508 pixels If you need to change the scale of your Sprite object that you're going to print, do it before you call the addPage() method on it. Note that printArea property and the Sprite object's scale are not connected. So, if you set your print area to 100 x 100 pixels, it is going to print 10000 pixels total. If you re-scale your Sprite object, it will print the same 10000 pixels, but the Sprite object is printed in its rescaled appearance. */ package { import flash.printing.*; import flash.display.*; import flash.text.*; import flash.geom.*; public class PrinterOutput extends Sprite { private var aPages:Array; private var amount:uint=1; public function PrinterOutput(psdAPages:Array) { trace(psdAPages[0]); aPages=[]; aPages=psdAPages; amount=aPages.length; //test(); //FOR TESTING -> WORKS OK printOnePerPage(); //printTwoPerPage(); //printTopHalf(); } private function test():void { for (var i:uint = 0; i < amount; ++i) { var sheet:Sprite = new Sprite(); createSheet(sheet, "Er was eens een...", { x:10, y:50, width:80, height:130 } ); } } private function createSheet(sheet:Sprite, str:String, imgValue:Object):void { sheet.graphics.beginFill(0xEEEEEE); sheet.graphics.lineStyle(1, 0x000000); sheet.graphics.drawRect(0, 0, 100, 200); sheet.graphics.endFill(); var fmt:TextFormat = new TextFormat(); fmt.font="Tahoma"; fmt.size = 2; var txt:TextField = new TextField(); txt.defaultTextFormat=fmt; txt.height=200; txt.width=100; txt.wordWrap=true; txt.text=str; if (imgValue!=null) { var img:Sprite = new Sprite(); img.graphics.beginFill(0xFFFFFF); img.graphics.drawRect(imgValue.x, imgValue.y, imgValue.width, imgValue.height); img.graphics.endFill(); sheet.addChild(img); } sheet.addChild(txt); aPages=[]; aPages.push(sheet); } private function printOnePerPage():void { var pj:PrintJob = new PrintJob(); var pagesToPrint:uint=0; if (pj.start()) { if (pj.orientation==PrintJobOrientation.LANDSCAPE) { throw new Error("Without embedding fonts you must print one sheet per page with an orientation of portrait."); } for (var i:uint = 0; i < amount; ++i) { aPages[i].height=pj.pageHeight; aPages[i].width=pj.pageWidth; try { pj.addPage(aPages[i]); pagesToPrint++; } catch (e:Error) { // do nothing } } trace(">> pj.orientation: " + pj.orientation, ">> pj.pageWidth: " + pj.pageWidth, ">> pj.pageHeight: " + pj.pageHeight); if (pagesToPrint>0) { pj.send(); } } } private function printTwoPerPage():void { var pj:PrintJob = new PrintJob(); var pagesToPrint:uint=0; if (pj.start()) { if (pj.orientation==PrintJobOrientation.PORTRAIT) { throw new Error("Without embedding fonts you must print two sheets per page with an orientation of landscape."); } for (var i:uint = 0; i < amount; ++i) { aPages[i].height=pj.pageHeight; aPages[i].width=pj.pageWidth/2; if (i%2==0) { var sheets:Sprite = new Sprite(); sheets.addChild(aPages[i]); if (aPages[i+1]) { sheets.addChild(aPages[i+1]); sheets.getChildAt(1).x=sheets.getChildAt(0).width; } try { pj.addPage(aPages[i]); pagesToPrint++; } catch (e:Error) { // do nothing } } } if (pagesToPrint>0) { pj.send(); } } } private function printTopHalf():void { var pj:PrintJob = new PrintJob(); var pagesToPrint:uint=0; if (pj.start()) { if (pj.orientation==PrintJobOrientation.PORTRAIT) { throw new Error("Without embedding fonts you must print the top half with an orientation of landscape."); } for (var i:uint = 0; i < amount; ++i) { aPages[i].height=pj.pageHeight; aPages[i].width=pj.pageWidth/2; if (i%2==0) { var sheets:Sprite = new Sprite(); sheets.addChild(aPages[i]); if (aPages[i+1]) { sheets.addChild(aPages[i+1]); sheets.getChildAt(1).x=sheets.getChildAt(0).width; } try { pj.addPage(sheets, new Rectangle(0, 0, sheets.width, sheets.height/2)); pagesToPrint++; } catch (e:Error) { // do nothing } } } if (pagesToPrint>0) { pj.send(); } } } }//end class }//en package ----------------------- END CODE Best regards, Cor -----Original Message----- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Rodrigo Augusto Guerra Sent: vrijdag 28 oktober 2011 17:42 To: Flash Coders List Subject: Re: [Flashcoders] swf 2 pdf on the fly hi guys... thanks for all the answers. I'll give a try on alivePDF and purePDF. Willem could you send a link for the class u created? Cor here is what i'm using to print, works ok on windows... never needed to test on MAc but will do it... var my_pj:PrintJob = new PrintJob(); //mostra caixa impressao if (my_pj.start()) { var myFlag1:Boolean = my_pj.addPage(_root.mcPrintExamCand) } ----- Original Message ----- From: "Geografiek" <geograf...@geografiek.nl> To: "Flash Coders List" <flashcoders@chattyfig.figleaf.com> Sent: Friday, October 28, 2011 10:18 AM Subject: Re: [Flashcoders] swf 2 pdf on the fly > Hi Cor and Rodrigo, > I use AlivePdf a lot. I managed to get high resolution pdf's from swf's > through a little custom class, I'm glad to share if you wish. > > I recognise the problems you describe Cor but afaik they do not affect the > quality of my prints on both platforms. > I googled "Warning: Filter will not render. The DisplayObject's filtered > dimensions" which should give you some clues. > HTH > Willem van den Goorbergh > > On 28 okt 2011, at 14:22, Cor wrote: > >> Hi, >> >> Look at AlivePDF. >> I am figuring out how this works with Flash (just started) >> >> I have issues printing from flash. >> It errors that the size is too big and of that filters can't be printed. >> However, I don't use filters and the size of my MC is 595x842 which is >> the >> exact size of PrintJob.pageSize >> On Windows it prints OK, but on MAC systems it gives total black prints. >> >> Can you tell me how you do your printing? >> >> >> Best regards, >> Cor van Dooren >> >> -----Original Message----- >> From: flashcoders-boun...@chattyfig.figleaf.com >> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Rodrigo >> Augusto Guerra >> Sent: vrijdag 28 oktober 2011 14:56 >> To: Flash Coders List >> Subject: [Flashcoders] swf 2 pdf on the fly >> >> hi all, >> >> I have a flash swf that generates a report inside a mc then print it. ok. >> now my client wants a button 'save to pdf.' not just print... >> >> The more automated the better, I wonder if someone has any hint on this, >> some tool that I can install on th server and it does that for me ... >> >> thanks, >> rodrigo >> _______________________________________________ >> Flashcoders mailing list >> Flashcoders@chattyfig.figleaf.com >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders >> >> _______________________________________________ >> Flashcoders mailing list >> Flashcoders@chattyfig.figleaf.com >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= > Geografiek is a Dutch, Utrecht-based map and chart design company. > Willem van den Goorbergh can be contacted by telephone: (+31)30-2719512 or > cell phone: (+31)6-26372378 > snail mail: Hooghiemstraplein 89 3514 AX UTRECHT > Visit our website at: www.geografiek.nl > twitter: @wvdgoorbergh > =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= > > > > > > _______________________________________________ > Flashcoders mailing list > Flashcoders@chattyfig.figleaf.com > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders