Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Printing Framework

Chris Luft wrote:
I need help.

I am writing some functionality that will allow the user to print a report that contains various data. I have used the uDig printing tutorial as a guideline and am able to generate a nice preview. The problem is that when I go to print the preview I only get the first page. That is, I have my whole preview being displayed on a really long page. I need to be able to print multiple pages and have been unable to figure out how I can go about this?

The printing code (some kind of print action?) just does not know about your extra long page thing. You will need to go into that code and make it into a for loop and print out each "page" one at a time. I think you may need to tell your print job (there is a class called print job in Java) that you have several pages of content rather than just one.

If possible can you adjust the drawing of the GEF Page (ie the preview) to indicate line breaks?
Also, I would like to be able to save this preview as a PDF.... any suggestions on this? I have seen in the Wiki a deprecated idea about a PDF extension; however, there is a note saying that this idea was not persued becasue the problem was addressed through the current printing extension. Unfortunately, I am not able to see, or find any method of doing this.
The ability to generate PDF directly has been added on trunk; that is why the work shown on the wiki has been dropped. If you are working on trunk you can find this functionality in three places: 1. Print - now directly lets you choose a template and go (it will go straight to paper) 2. New Page - will do the traditional choose a template and watch the page editor get opened functionality
3. PDF - directly choose a template and generate a PDF file

Also form a Page Editor:
1. Print - prints the page to the printer
2. PDF - prints the page to a PDF file

The two direct routes actually create a page object using the template; use it to print or pdf; and then throw it away after.

Because of the code reuse here it was viewed as a much better idea then encouraging the use of the "export to PDF" functionality that had been added to the image export wizard. I hope you agree?

The two useful bits of code (PrintAction and PDFAction I think) are pretty simple at their core; they both are concerned with grabbing a Graphics2D object and printing each box; the MapBox takes care of working through the Map model and printing out the layers in order. Brock did some interesting things to try and recognize raster layers and print them out into memory first; since since asking for full resolution when making a PDF exhausted memory is many cases.
Any help form anybody would be greatly appreciated.
Do you have a check out of trunk you can run? If not one of your co-workers should be able to show you this stuff on trunk.
Best reagrds,
C.Luft
All the best;
Jody


Back to the top