I've written this for another project where I needed a print preview and some advances features for creating documents (and later print them or save them to pdf) like automatic page breaks, headers, footers etc.
Main features:
- creating a document once and later output it to CanvasGadet, Window, Image, printer, pdf or svg
- text and image cells with custom border, filling, text alignment, font etc.
- horizontal, vertical and free lines
- rectangles, curves, ellipses and ellipse segments
- auto-invoked headers and footers, for the whole document or for a single page
- auto page breaks
- avoiding page breaks within connected element blocks
- auto page numbers with free start value, excluding of pages from numbering, total number of pages etc.
- possibility to display the document as single pages or as a list of pages (for print preview, see example code)
example: https://raw.githubusercontent.com/hgzh/ ... preview.pb