Printing with Python
Andy Robinson, Robinson Analytics Ltd.
O'Reilly Python Conference, Monterey, 24th August 1999
Background to the project:
London-based consultant and corporate developer
want to do neat Python stuff in the daytime
working for many years on financial modelling
this is one of 6 modules in that system
quickest to deliver, offers very wide benefits
25% of architecture done, but already very useful
Release early, release often!
Goal:
A Reporting Package on the Next Curve...
Report on objects, not databases
Scalable to million page runs
Light enough to embed in any application
Allow reuse of graphical objects across reports
Open and extensible on several levels
Publication quality
Support all the world's languages - one day
Portable Document Format
The New PostScript
Free readers on all platforms
Better than paper - view it, email it, print it
'Final Form' for documents
High end solution - no limits to quality
...but you can't learn it in Notepad!
PDFgen and PIDDLE
Layer One - PDFgen
makes PDF documents from pure Python
wraps up PDF document structure
exposes nice effects - page transitions, outline trees (RSN!)
low level graphics promitives (postscript imaging model)
Fine control of text placement
Supports Asian text
Supports coordinate transformations and clipping
...a foundation for other apps to build on
PDFgen Image Support
Python Imaging Library and zlib do all the work - many formats.
Images cached (like .pyc files) - very fast builds possible.
Layer Two: PIDDLE
Plug In Drawing, Does Little Else
Easy Graphics Library
Abstract Canvas Interface
Pluggable Back Ends
Same code can do viewing and printing
Standard set of test patterns
Uses Python Imaging Library
Back ends includeTkinter, wxPython, Mac, Pythonwin, PDF, PostScript,
OpenGL, Adobe Illustrator and PIL. Really easy to add a new one!
Layer Three: PLATYPUS
"Page Layout And Typography Using Scripts"
Trying to work out the API now. Key Concepts:
Drawable objects - can 'wrap to fit'
Frames on page
Frame consumes from a list of drawables until full
Document Models e.g. SimpleFlowDocument
XSL Flow Object model may be a good target
Drawable Objects
Next layer of PIDDLE extensibility.
Each draws in its own coodinate system
paragraph, image, table
chart libraries
diagrams
Open Source - let people contribute new ones.
Anything you could have in a view can be a new
drawable type.
Style Sheet Driven
Styles use instance inheritance
Paragraph Styles - Style Sheet Compulsory!
Text Styles within a paragraph
Table and Table Cell Styles
Vision
XML to PDF in one step
Publish to web and print from same source
Financial and Scientific reporting tool
Embedded reporting engine
Volume reporting tool for business
PythonPoint
How I made this presentation...