This Question is Answered

15 "helpful" answers available (3 pts)
3 Replies Last post: Apr 24, 2008 12:42 AM by tiju

need help with printing

Apr 21, 2008 10:53 PM

Click to view tiju's profile Level 6 tiju 102 posts since
Oct 17, 2007

I am having a situation at hand and wanted to know if anyone has encountered the same situation before.

I want to print a complex graphical hierarchy to pdf/document. The creation of the graphics is heavy and takes much time, say, about 5 sec. But, the image printed does not have all the components in the graphical hierarchy. Some of the components just do not get printed.

At the same time, if I popup the same graphical hierarchy just before printing, I get to see all the components of the hierarchy and so does all the components get printed.

Am I overlooking anything in particular?

Click to view Duke's profile Curl Duke 154 posts since
Oct 17, 2007
1. Re: need help with printing Apr 21, 2008 11:13 PM
I have not heard of anything like this before, but maybe someone else will have an idea of the cause. Is there anything in common about the components that do not get printed? Is it possible that those components are in more than one place in the graphical hierarchy that you are printing? What is the appearance of the area that they are missing from? Is it blank? Is it the size you would have expected but nothing is there?
Click to view Kamal's profile Curl Kamal 139 posts since
Oct 17, 2007
2. Re: need help with printing Apr 22, 2008 5:28 AM

When you start a print job, the Graphic you want to print is added to a PrintRootFrame. When the Layout of your Graphical object is complete the Graphical object is printed. Not knowing about you particular Graphic hierarchy I cannot say much. It could be what Duke wrote is true. Or your layout is happening in cycles. For example, you have a code that makes the layout invalid after it was valid - E.g. you may have a code that computes some stuff and then has "after 0s do" and in it you are invalidatiing the layout - so another layout cycle kicks in. When you print, the PrintRootFrame does not know that the Graphical object it is printing is going to invalidate the layout soon and so should wait. It will just prints after the first layout cycle completes. If possible, could you send your code so that I may have a better answer and possibly a solution.

Thanks,

-Kamal

PS. I do not think that this applies to your case. But anyway I will mention it here. If you are printing a Graphic whoes draw method ends up drawing differntly every time it is called, you may notice that what you print is not what you see. The point again is that Print is like a "snapshot". Once the first layout cycle is complete after the Graphic is added to the PrintRootFrame, the first draw that will be called during printing is what you will see as being printed. If there are futher layouts and draw changes, they will not be reflected.

Click to view tiju's profile Level 6 tiju 102 posts since
Oct 17, 2007
3. Re: need help with printing Apr 24, 2008 12:42 AM
in response to: Kamal

Thanks Kamal. This helped. {after 0s do} was the culprit.

Even though I had tried giving substantial amount of time before the print job, I was not able to print specific components. Hence a drill down into the creation of those components lead to the {after 0s do} code and the {set-size} of graphics both of which gets called anonymously. I had to re-write the code without the {after 0s do} for UI creation and this helped me get my print correctly.