pagebreaks

General TRichView support forum. Please post your questions here
Post Reply
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

pagebreaks

Post by standay »

Hi Sergey,

I've been working on this for 3 days and I'm out of ideas.

I'm trying to get line numbers in the left margin of the print preview. I'm using a regular rve and rvprintpreview components (not actions).

I have it working pretty well now unless I add pagebreaks into my file, then all my drawitem top values go wonky. Longer files that make the preview break pages naturally cause no problem, it's just my "manually added" pagebreaks that throw my calcs off. When I add a manual pagebreak and step the code, there seems to be 2 pagebreaks on the page, the one I added and another one that the print preview put in (I'm just guessing here).

Oh, if I add a couple of blank lines and put the pagebreak between those, it works OK. If I put the pagebreak at the beginning of a line of text then the line numbers don't align well with the rve text (using drawtext tops).

If you have any thoughts on this I'd appreciate them. I can post the code but I don't want to bother you with it. Just some advice would help.

Thanks Sergy

Stan
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: pagebreaks

Post by standay »

I finally worked out why I was seeing 2 pagebreaks when spinning through the printable rv drawitems. If an item has enough text in it that it's wordwrapped, that results in multiple drawitems, and each one of those drawitems have the same base item no. So, when I did this:

Code: Select all

if Sender.rv.RVData.PageBreaksBeforeItems[DItem.ItemNo] then...
It could be true several times.

I got that fixed and now I have the rest of it working. What I did for the print line numbers was to add drawing some lines showing the tops and baselines for each drawitem (for debugging, I don't show those normally). That finally let me see what was actually going on and that let me see that how I thought the drawitems worked was not correct. Here's a screenshot of the (debug) print preview looks like:

drawitem guides.png
drawitem guides.png (12.82 KiB) Viewed 26924 times
Aqua lines are ditem tops, red are the baselines. The vertical silver line to the right of the line numbers is a right hand rule I put in, the dotted silver line is the left print margin. The orange line at left is the left side of the printable area. Print line numbers are drawn in the print margin.

Part of what threw me was the centerline of text is not the ditem height div 2, as the text "rests" on the baseline and the top of text is below the ditem top. Items with paragraph added top spacing (like my headers, the black background item) need special vertical space handling as do horizontal rules (rvbreaks), tables and images. Once all this is accounted for, the ditem numbers do make sense. But without my little top and baseline guides, I'd have never figured it all out.

Maybe this will help someone else in the future!

Stan
Post Reply