2009-08-15

PDF Generation [SNEAK PEEK]

I'm playing with the PDFSharp library which provides PDF generation capabilities for C# with a liberal license and can be used with ASP.NET handily enough. The library nicely supports using the same rendering primitives to output via GDI+ or PDF, so I can actually just convert the site's entire rendering stack onto PDFSharp (which looks a lot like System.Drawing anyway) and then simply pass it either a bitmap or a PDF into which to render.

After a couple of hours of playing, here's sample output from the Poster API:

http://www.travellermap.com/tmp/spinward_demo.pdf

Warning: don't blithely hit "print" - I'm not doing anything clever with units yet, so I don't know how many pages it will try and span. Examine the print options carefully. :)

This is not live yet - there are several things not working yet and I'm concerned about performance when suddenly have the main map site running through this code. But so far, it looks promising.

When it is live, you'll be able to use the Tile, Poster and JumpMap APIs to generate PDFs by specifying either a Content-Type HTTP header or a query string parameter in the URI (since we can't always control header generation). Ω

3 comments:

BeRKA said...

I like it a lot! :-)

Vile said...

I like it a lot more than BeRKA does! ;-)

donm61873 said...

It's gorgeous.

1. Can I shove my own data at this API and get back a PDF?
2. Can I credit you as my artist :)
3. Shouldn't Flammarion be an Imperial world?