Open GoogleCodeExporter opened 9 years ago
In your example code MaxVertical is calculated for the HtmlViewer's default
size of 150px width. Of course this is smaller than paper size A4 and is
smaller than the default width of the application, resulting in a heigher
header.
Currently the page header is placed bottom aligned above the PrintMarginTop
into the printable area and the page footer is placed top aligned below the
PrintMarginBottom into the remaining printable area.
If I understand you right, you'd like to place the page header top aligned
below the PrintMarginTop and start the document area at the bottom of the page
header. Same with page footer accordingly.
Sounds acceptable as long as page header and page footer are smaller than 1
page.
Variable height headers and footers should be optional to preserve existing
layouts.
Original comment by OrphanCat
on 14 May 2012 at 8:53
Yes, that's about it.
Advanced.
Could you make when using PrintScale <> 1 of the main document would be able to
optionally specify the coefficient PrintScale for the Header/Footer???
Something like the picture.
Original comment by SchwarzK...@yandex.ru
on 14 May 2012 at 9:17
Attachments:
Yeah, that's reasonable.
Original comment by OrphanCat
on 14 May 2012 at 9:20
Thanks, it was-would be good for some purposes. :)
Original comment by SchwarzK...@yandex.ru
on 14 May 2012 at 9:30
I corrected the situation with the wrong calculation MaxVertical.
If desired, it can be made to the source.
htmlview.pas
...
function CreateHeaderFooter: THtmlViewer;
{!!!} procedure UpdateWidthHeaderFooter(HFHtmlViewer: THtmlViewer; Width:
Integer);
function GetBase: ThtString;
...
...
{!!!}procedure THtmlViewer.UpdateWidthHeaderFooter(HFHtmlViewer: THtmlViewer;
Width: Integer);
begin
if HFHtmlViewer <> nil then
HFHtmlViewer.Width := Width;
end;
{$ifndef NoMetafile}
procedure THtmlViewer.Print(FromPage, ToPage: Integer; Prn: TvwPrinter);
...
...
{.$Region 'HeaderFooter'}
SelectClipRgn(DC, 0);
if (FPage <= ToPage) then {print header and footer}
begin
Prn.Canvas.Pen.Assign(savedPen);
Align := SetTextAlign(DC, TA_Top or TA_Left or TA_NOUPDATECP);
SelectClipRgn(DC, hrgnClip2);
{!!!} UpdateWidthHeaderFooter(HeadViewer, ScaledPgWid);
UpdateWidthHeaderFooter(FootViewer, ScaledPgWid);
if Assigned(OnPrintHeader) then
begin
SetWindowOrgEx(DC, XOrigin, 0, nil);
OnPrintHeader(Self, Prn.Canvas, FPage, ScaledPgWid, TopPixels, Done);
end;
...
Original comment by SchwarzK...@yandex.ru
on 29 Jan 2013 at 2:48
I'm very sorry, but I cannot see, what was going wrong before the fix and what
is going to become well after the fix. Which print/preview calculation takes
into account the HeadViewer.Width resp. FootViewer.Width?
Actually DoHTMLHeaderFooter() uses W, the scaled pageWidth without margins (==
width of used paper area) to prepare the layout (HFCopyList.DoLogic()).
The out-commented code in TForm1.ViewerPrintHTMLHeader() in your example unit
HFUnit.pas tries to save space for a larger header using Viewer.MaxVertical,
but it is not a figure for the calculated length of the printed/previewed page.
Furthermore HtmlViewer renders the header after the main page and thus you
cannot know and use the actual header height of this page to determine the
height of the main page.
Since r352 (committed today) after calling THtmlViewer.Print() (or
PrintPreview() or NumPrinterPages()) property PrintedSize:TPoint gives you the
size of the entire document in pixels. So HeadViewer.PrintedSize.Y is the
header height in pixels. But still it is not available before the main page is
rendered.
Original comment by OrphanCat
on 29 Jan 2013 at 8:18
Original issue reported on code.google.com by
SchwarzK...@yandex.ru
on 14 May 2012 at 5:34Attachments: