FlexPrintJobScaleType doesn't work for me

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

FlexPrintJobScaleType doesn't work for me

Olaf Krueger
Hi,
I've absolutely no experience with printing in Flex.
I'm trying to fit the screen content to an A4 page (landscape) by using the "scaleType" parameter, but it seems to me that it has no effect? The content always exceeds the page size/width.
I've tried all options...

Do I miss something [1]?

Thanks,
Olaf

[1]
var printJob:FlexPrintJob = new FlexPrintJob();
//printJob.printAsBitmap = true;
printJob.start();
printJob.addObject(this, FlexPrintJobScaleType.SHOW_ALL);
printJob.send();
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FlexPrintJobScaleType doesn't work for me

Alex Harui-2
What are you printing?  Debug into addObject and watch the size
computation.

HTH,
-Alex

On 7/21/17, 7:59 AM, "Olaf Krueger" <[hidden email]> wrote:

>Hi,
>I've absolutely no experience with printing in Flex.
>I'm trying to fit the screen content to an A4 page (landscape) by using
>the
>"scaleType" parameter, but it seems to me that it has no effect? The
>content
>always exceeds the page size/width.
>I've tried all options...
>
>Do I miss something [1]?
>
>Thanks,
>Olaf
>
>[1]
>var printJob:FlexPrintJob = new FlexPrintJob();
>//printJob.printAsBitmap = true;
>printJob.start();
>printJob.addObject(this, FlexPrintJobScaleType.SHOW_ALL);
>printJob.send();
>
>
>
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-users.2333346.n4.nabble.com%2FFlexPrintJobScaleType-doesn-t-work-for-me-
>tp15482.html&data=02%7C01%7C%7C92e91e9d5ce74be820d108d4d04be99d%7Cfa7b1b5a
>7b34438794aed2c178decee1%7C0%7C0%7C636362471853348087&sdata=T4tHHmQ4UQaqu5
>aiEuBlZTqIH7tnmdOHZOgFcIMXVnU%3D&reserved=0
>Sent from the Apache Flex Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FlexPrintJobScaleType doesn't work for me

Olaf Krueger
Hi Alex,
sorry for the late response, I've overlooked your post.
It seems to me that sometimes mails from the list doesn't reach my local inbox for whatever reason.

>What are you printing?
I am trying to print a s:Group that contains several Spark components including a Timebar component that comes from Ardisialibs as an external vendor.


>Debug into addObject and watch the size computation.
I found that the print job splits the content into a multiple number of pages if it does not fit the size of the page .
I thought the print job was able to scale the content automatically by using e.g. 'FlexPrintJobScaleType.FILL_PAGE' to fit the page?
Do I have to scale it by myself before printing?

I've one more issue with transparent components.
If the alpha of a component is <1 that the print job just outputs a black area.
It seems to me that this is a known issue.
Is there a workaround for this?

Thanks,
Olaf

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FlexPrintJobScaleType doesn't work for me

Alex Harui-2
In looking at the source for FlexPrintJob, if the thing you are printing
isn't the main app, then the currently size of the thing is used to
compute how to scale to fill the page, but after that, validateNow() is
called.  If the thing you print computes to a different size that is too
large for the page then it will split the page.   So step into it again
and watch how the width/height is computed and handled and see if it
changes on the validateNow() calls.

Regarding alpha, I think if the thing you print has alpha < 0, you
actually want to print the parent of that thing.

HTH,
-Alex

On 8/11/17, 1:48 AM, "Olaf Krueger" <[hidden email]> wrote:

>Hi Alex,
>sorry for the late response, I've overlooked your post.
>It seems to me that sometimes mails from the list doesn't reach my local
>inbox for whatever reason.
>
>>What are you printing?
>I am trying to print a s:Group that contains several Spark components
>including a Timebar component that comes from Ardisialibs as an external
>vendor.
>
>
>>Debug into addObject and watch the size computation.
>I found that the print job splits the content into a multiple number of
>pages if it does not fit the size of the page .
>I thought the print job was able to scale the content automatically by
>using
>e.g. 'FlexPrintJobScaleType.FILL_PAGE' to fit the page?
>Do I have to scale it by myself before printing?
>
>I've one more issue with transparent components.
>If the alpha of a component is <1 that the print job just outputs a black
>area.
>It seems to me that this is a known issue.
>Is there a workaround for this?
>
>Thanks,
>Olaf
>
>
>
>
>
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-users.2333346.n4.nabble.com%2FFlexPrintJobScaleType-doesn-t-work-for-me-
>tp15482p15708.html&data=02%7C01%7C%7C5511785d3b644b4d03fa08d4e095ffa7%7Cfa
>7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636380382230870648&sdata=WUxoJjRw
>ZC86c%2BQPPQ1Tg7PZMKApW7cGsIpAFjaYxTk%3D&reserved=0
>Sent from the Apache Flex Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: FlexPrintJobScaleType doesn't work for me

After24
In reply to this post by Olaf Krueger
Bonjour,

En congés jusqu'au 4 septembre, je prendrais connaissance de votre message à mon retour.

Cordialement,

Vincent/AFTER24



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FlexPrintJobScaleType doesn't work for me

Olaf Krueger
In reply to this post by Alex Harui-2
Thanks Alex, I'll take a look at it soon!

>Regarding alpha, I think if the thing you print has alpha < 0, you
>actually want to print the parent of that thing.

Mhhh... there's a transparent rectangle on top which has an alpha <1.
I just would like to print exactly the same that is on the screen.
But this transparent rectangle is printed as a black rectangle so the underlying content is hidden [1].

Thanks,
Olaf

[1] https://snag.gy/OryeiA.jpg
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FlexPrintJobScaleType doesn't work for me

Alex Harui-2
Did you try playing with the printAsBitmap options?

-Alex

On 8/11/17, 1:51 PM, "Olaf Krueger" <[hidden email]> wrote:

>Thanks Alex, I'll take a look at it soon!
>
>>Regarding alpha, I think if the thing you print has alpha < 0, you
>>actually want to print the parent of that thing.
>
>Mhhh... there's a transparent rectangle on top which has an alpha <1.
>I just would like to print exactly the same that is on the screen.
>But this transparent rectangle is printed as a black rectangle so the
>underlying content is hidden [1].
>
>Thanks,
>Olaf
>
>[1]
><a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsnag.gy%2">https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsnag.gy%2
>FOryeiA.jpg&data=02%7C01%7C%7Cd7d246ae8c594eb858b708d4e0fae420%7Cfa7b1b5a7
>b34438794aed2c178decee1%7C0%7C0%7C636380815559561986&sdata=51iyja3%2B5t19S
>%2BESAazER4hTHFGRYR%2F3%2F%2FlBj1uCOQg%3D&reserved=0
>
>
>
>--
>View this message in context:
>https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-fle
>x-users.2333346.n4.nabble.com%2FFlexPrintJobScaleType-doesn-t-work-for-me-
>tp15482p15718.html&data=02%7C01%7C%7Cd7d246ae8c594eb858b708d4e0fae420%7Cfa
>7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636380815559561986&sdata=Mryzi5dH
>FCjAdN2LasldixCeoJX7R9nF0a2PxMI0ssg%3D&reserved=0
>Sent from the Apache Flex Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: FlexPrintJobScaleType doesn't work for me

After24
In reply to this post by Olaf Krueger
Bonjour,

En congés jusqu'au 4 septembre, je prendrais connaissance de votre message à mon retour.

Cordialement,

Vincent/AFTER24



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FlexPrintJobScaleType doesn't work for me

doug777
In reply to this post by Olaf Krueger
We have tried to use FlexPrintJob in the past with or without printAsBitmap set. But we found the final print usually has odd artefacts included just as you are seeing. Unless you have a fairly simple document and you know it will never be more than one page long, I would suggest these alternatives.

** And of course this is the great beauty of Flex - it's fle-e-ex-ible!

Option 1 : Wrap up your document in the simplest DataGrid you can devise and then use PrintDataGrid. This works well but you may need to paginate manually and put the pages in different rows otherwise single lines of text can get split through the middle.

Option 2 (which is my current preference) : When user clicks Print, send the doc to a pdf creator on the server and return the url of the saved pdf. On receipt of url, spawn Adobe Reader so that the user can print with the superb print interface in Adobe Reader.

At first sight this appears a 'clunky' solution, but users quickly appreciate the sheer power of the Adobe Printer and the output is always perfect no matter what you throw at it.

Hope this helps,
Doug
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: FlexPrintJobScaleType doesn't work for me

After24
In reply to this post by Olaf Krueger
Bonjour,

En congés jusqu'au 4 septembre, je prendrais connaissance de votre message à mon retour.

Cordialement,

Vincent/AFTER24



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FlexPrintJobScaleType doesn't work for me

Olaf Krueger
In reply to this post by Alex Harui-2
>Did you try playing with the printAsBitmap options?

Yes, with no success... but maybe I miss something.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Re: FlexPrintJobScaleType doesn't work for me

Olaf Krueger
In reply to this post by After24
Hi Doug,
good to know that I'm not alone ;-)

>send the doc to a pdf creator on the server
That's a good idea. What do you mean with 'doc'?
Do you send an image representation of the Flex component to the server?
If so, how do you create this?

Thanks,
Olaf
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FlexPrintJobScaleType doesn't work for me

Olaf Krueger
In reply to this post by doug777
I did it as you suggested and create a PDF on the server side instead of using FlexPrintJob now.

To achieve this I've introduced a new endpoint to my server side API that expects an image and some metadata. The services scale the image, create a PDF and returns an url to the created PDF.
Maybe it makes more sense to scale the image at client side...

To be able to pass the image within some meta data via JSON I've encoded the image as base64.
(This means that the payload increases at approximately 30%, but this no issue here).

I've created a gist [1], maybe it is helpful for others.

Thanks for the help!

Olaf

[1] https://gist.github.com/ok-at-github/17eaa04e7025f2b34ca23774119e4e39



Loading...