Printing: Difference between revisions

From OpenPetra Wiki
Jump to navigation Jump to search
Tag: Replaced
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
The idea is that form letters and other reports should be easily adjustable.
The idea is that form letters and other reports should be easily adjustable.


To achieve this goal, we had to write our own HTML printer, which sounds strange at first, but there seems to be no other option to print HTML with .net System.Drawing.
To achieve this goal, we are now using [https://wkhtmltopdf.org/ wkhtmltopdf].
 
== Testing project ==
Please see the testing project Tests.Common.Printing in solution Testing.sln; this project comes with a sample HTML file, and an editor for the HTML file, and the preview screen for the print result, with comparison to display in an HTML browser.
 
Another way for testing is with the [http://sourceforge.net/projects/pdfcreator/ PDFCreator] (it saves a lot of paper...). But be careful: sometimes a real printer requires a wider margin.
One other hint: sometimes PDFCreator behaves weird after a long sequence of testing; after you print, the job disappears from the printing queue, without asking you where to save the PDF. The solution that works for me is to stop the PDFCreator.exe task in task manager. Beware: all the disappeared jobs will end up in your PDFCreator printing queue again...
 
== Features ==
Obviously, not all features of HTML could be implemented.
 
Generally, we limit ourselves to XHTML, which makes it easier to parse the document.
 
We support:
*tables: table, th, tr, td, tbody, colgroup, col width.
** Tables are automatically split across pages, and the line with th elements is repeated each time.
** td: align with values right or left or center
** td: nowrap="nowrap" avoids wrapping of lines
*special div with class PageHeader: this is repeated for each page
** #PAGENR and #PAGETOTAL in the HTML text will be replaced automatically with appropriate numbers
*font size: change the relative size
*b: bold text
*page margins:
** currently only supported: <body style="margin-left:0px, margin-right:0px"
** without this, a default margin for normal letters is used (approx 2cm margin?)

Latest revision as of 21:02, 11 Mayıs 2022

Printing from HTML template

The idea is that form letters and other reports should be easily adjustable.

To achieve this goal, we are now using wkhtmltopdf.