I was working on a project some time ago and had problems with bad quality.
I dont have it on my computer here but I remember that I scaled all objects
up before printing to get a better resolution in the pdf or printout.
What I did maybe a poor solution but it worked okay for me.
Something like this:
           function
addDisplayObjectToPdfWith300DPIResolution(displayObj:DisplayObject,
pdfTarget:PDF):void{
                        var scaleFactor:Number=Math.round(300/72);
var matrix:Matrix=new Matrix(scaleFactor,0,0,scaleFactor);
var data:BitmapData = new BitmapData(displayObj.width*scaleFactor,
displayObj.height*scaleFactor, false);
data.draw(displayObj,matrix,null,null,null,false);
var encodedImage: ByteArray =data.encode(data.rect, new
PNGEncoderOptions());
pdfTarget.addImageStream(encodedImage,ColorSpace.DEVICE_RGB,pdfResize);
                     }

But I'm not too sure about it.


2014-02-03 Alex Harui <aha...@adobe.com>:

>
>
> On 2/2/14 2:07 PM, "jude" <flexcapaci...@gmail.com> wrote:
>
> >So you're saying if I get a page size that is more than 72x8.5 by 72x11
> >then I could be printing at a higher DPI?
>
> Yes, that's my understanding, but I could certainly be wrong.
>
> >And you're saying the page size
> >that's returned may not exactly be 72x8.5 or 300x8.5?
> >I'm guessing that
> >would be because of the margins and options the user chosen in the print
> >dialog. I'll have to check.
> That would be my guess as well.
>
>
> >
> >But that means by the time the user finally presses the print button on
> >the
> >OS print dialog the DPI is set in stone.
> That's my understanding as well, because I think you get to choose the DPI
> in the print dialog via some sort of combination of page setup and printer
> settings in the OS.
>
> >That's when we get to add and
> >scale the display objects we want to print. It sounds like then if I scale
> >the display object after getting the page size information it won't change
> >the DPI of the actual printout but will give me enough information to know
> >what it is.
> >
> >The way I've been testing this is by choosing the Open as PDF option in
> >the
> >print dialog but I think I'll have to do some print outs.
> What are you seeing for page sizes when PDF printing?  Also, it may matter
> if you are doing printAsBitmap or not.  If you don't choose printAsBitmap,
> then I think the player will try to re-draw everything at the print
> driver's DPI.
> >
> >Do you know why certain things like Button would not look correctly in the
> >printout? It looks like the button was vectorized (actual graphics data or
> >commands were used) but not all of them. for example, the button has a
> >thicker border than normal and it's label is text selectable but the
> >button background is missing. in the PDF the button scales up as a vector
> >would. does ui component bitmap capture highlight have anything to do with
> >it?
> On a printout the label is text selectable?  Or in a PDF?  Maybe the
> player doesn't know how to print gradients in a way that PDF can
> understand.  I think border thickness can be affected by destination DPI
> and how antialiasing and other colors gets computed.  I thought we did see
> artifacts like that on screen when cacheAsBitmap is on.
>
> -Alex
> >
> >On Wednesday, January 29, 2014, Alex Harui <aha...@adobe.com> wrote:
> >
> >> I'm definitely not the expert on printing, but in my limited experience,
> >> after the call to flexprintjob.start() you now know the page size.
> >>IIRC,
> >> the page size often has an unexpected size.  Like if you think you've
> >>used
> >> the PrintDialog to set up a 300 dpi print on an 8.5x11 inch page, you
> >>don't
> >> get a page size of (300x8.5 by 300x11). But I could be wrong about that.
> >>  But I don't think it is 72*8.5 by 72x11.  Or is it?
> >>
> >> IIRC, the next step is to generate a display object to pass to
> >> flexprintjob.  If you generate a display object that is larger than the
> >> page size, it will get clipped or print on multiple pages.  If you scale
> >> the children being put in this display object, then it should print with
> >> the scaled child.  What I don't know is if that scaling will do the
> >>right
> >> thing for a bitmap.
> >>
> >> -Alex
> >>
> >>
> >>
> >> From: jude <flexcapaci...@gmail.com <javascript:;><mailto:
> >> flexcapaci...@gmail.com <javascript:;>>>
> >> Reply-To: "users@flex.apache.org <javascript:;><mailto:
> >> users@flex.apache.org <javascript:;>>"
> >><users@flex.apache.org<javascript:;>
> >> <mailto:users@flex.apache.org <javascript:;>>>
> >> Date: Wednesday, January 29, 2014 12:58 PM
> >> To: "users@flex.apache.org
> >><javascript:;><mailto:users@flex.apache.org<javascript:;>>"
> >> <users@flex.apache.org
> >><javascript:;><mailto:users@flex.apache.org<javascript:;>
> >> >>
> >> Subject: Re: Printing at a set DPI
> >>
> >> It does but I'm not sure how that would help. Also, it sends it after
> >>you
> >> send the job to the printer. The whole thing is somewhat confusing. In
> >> Photoshop you can specify the width, height and DPI of a document before
> >> you even start. Then later when you are ready to print the print dialog
> >> shows the width and height and DPI. If you change the scale or width or
> >> height in the print dialog the DPI also changes. For example, it scaled
> >>a
> >> large image to fit the page and it went from 72DPI to 176DPI.
> >>
> >> Then in the OS print dialog, nestled 3 layers deep in the menus, there's
> >> an option to change the print quality (DPI). There's fast draft, fast
> >> normal, normal, automatic, best and maximum DPI. If you dig deeper you
> >>can
> >> check the printer settings and it will show a DPI value for the preset.
> >>
> >> [Inline image 3]
> >>
> >>
> >> Here's the code I'm using:
> >>
> >> var printableObject:IUIComponent;
> >> var flexPrintJob:FlexPrintJob = new FlexPrintJob();
> >> var printJobStarted:Boolean = flexPrintJob.start();
> >> // after call to start you can get the pageWidth and pageHeight
> >> // log.info<http://log.info>("Print width and height: " +
> >> flexPrintJob.pageWidth + "x" + flexPrintJob.pageHeight);
> >> flexPrintJob.addObject(printableObject,
> >>FlexPrintJobScaleType.MATCH_WIDTH);
> >> flexPrintJob.send();
> >>
> >> What I want to know is if somewhere along the line I can say I'd prefer
> >>to
> >> print this at 300 dpi vs 72dpi (screen)? If I supply it with an object
> >>that
> >> is twice as large as the page size does that double the DPI? Sorry for
> >>the
> >> plethora of questions.
> >>
> >> On Tue, Jan 28, 2014 at 4:59 PM, Alex Harui
> >><aha...@adobe.com<javascript:;>
> >> <mailto:aha...@adobe.com <javascript:;>>> wrote:
> >> I thought PrintJob returned information about page width/height.  And I
> >> thought that was controlled by the print settings in the print dialog.
> >>
> >> -Alex
> >>
> >> On 1/28/14 10:42 AM, "jude" <flexcapaci...@gmail.com <javascript:;>
> >> <mailto:flexcapaci...@gmail.com <javascript:;>>> wrote:
> >>
> >> >Is there a way to print something at a certain DPI with the PrintJob or
> >> >FlexPrintJob classes? From what I've read so far it will print at the
> >> >resolution of the screen. Also, when I print in vector (not
> >>printAsBitmap)
> >> >certain display objects lose their backgrounds. For example, if there
> >>is a
> >> >Spark Button, the gradient doesn't show up.
> >>
> >>
> >>
>
>

Reply via email to