[pedevel] Printing

  • From: "François Revol" <revol@xxxxxxx>
  • To: pedevel@xxxxxxxxxxxxx
  • Date: Wed, 09 Apr 2008 16:27:41 +0200 CEST

Hi there.
I started adding printing to Pe.
While it's not really needed in most cases it can still be handy to 
have correctly printed code. Also, one thing I had in mind was to be 
able to generate a nicely indexed PDF file from source code, using the 
function list as bookmarks.

Currently the PDF Writer driver generates bookmarks based on font face 
and size matching on the text sent to it. while it might be working for 
word processing documents it's no use for us since we use a single 
font, and doesn't give enough control.

I plan on extending the driver to accept a list of bookmarks instead.
I started adding code to generate it in Pe, but it will need some more 
work to calculate the pages from the line number, but since we need to 
first iterate over all pages to count them before starting printing it 
should still be possible to have the bookmarks available at the time we 
last call SetSettings() with the settings message, and use it to pass 
them around.

I also fiddled with other meta-data (author, keywords..), but the 
current driver in zeta doesn't accept what I pass to it (though it puts 
its own back at the same place. It seems our driver should be saner 
there, need to test.

Anyway the first thing to do should still be printing correctly.

The code in svn works but the result doesn't look good at all.
I fixed some things but I'm not happy with it and I don't know enough 
of the drawing internals to avoid messing things up, and it's not yet 
working.
Plus I noticed missing redraws I didn't see before, so I probably 
already screwed it up.
The patch here is what I did so far:
http://revolf.free.fr/beos/patches/pe_printing_wip.001.diff.txt
* factored out the split drawing in Draw(), but it doesn't look much 
better.
* Use different values when printing (disregard splitting). I think 
maybe that code should be moved to a DrawSplit() or something.
* Used black and white instead of the default bg/fg colors when 
printing. This doesn't work fully, it seems the first page is 
parasitized with calls to RedrawDirtyLines or some other code, as 
(under Zeta where the document bg is not set to white) it still draws 
brawn lines in the text:
http://revolf.free.fr/beos/test_pe.pdf

Still, a lot of things should not be accounted for when printing. 
Wrapping should be used to avoid cutting text. There should also be 
some scalling probably, maybe via a preference panel...
Selection bg color is still printed too. Invisibles should stay 
invisible probably...
Either those values should be forced before printing and restored 
afterward (it's done synchronously anyway), or a different code path 
should be taken from Draw(), maybe DrawPrinting().

Comments ?

François.

Other related posts: