Thanks for helping to solve the print header/footer problem.
In our extended version of RichView (15.1.2), an error occurred in two-sided printing (duplex) for multiple copies.
The error appears in the module SRVPrint.pas
The TSRVPrint.PrintPages procedure does not use the TDeviceMode.dmDuplex value.
Therefore, when print 2 pages report, with two-sided pages, with 2 copies, with turned off collate parameter, the indexPage variable is not correctly calculated.
indexPage changes 1,1; 2,2
But should be 1,2; 1,2.
Code: Select all
procedure TSRVPrint.PrintPages(firstPgNo, lastPgNo: Integer; Title: String;
Copies: Integer; Collate: Boolean);
var
Step, indexPage, indexCopys, indexCopys2, PrintCopies, OldPrintCopies,
CountPageAtPaper, j, EP: Integer;
OldOrientation: TPrinterOrientation;
StartPrint: Boolean;
begin
if Printer.Printers.Count = 0 then
exit;
SRVPrtInfo.UpdateCurPrinterData;
Printer.Title := Title;
firstPgNo := Max(Min(firstPgNo, FSRichViewEdit.PageCount), 1);
lastPgNo := Max(Min(lastPgNo, FSRichViewEdit.PageCount), 1);
OldPrintCopies := Printer.Copies;
if Collate then
begin
Printer.Copies := 1;
PrintCopies := Copies;
end
else
begin
Printer.Copies := 1;
PrintCopies := 1;
end;
if PrintMode = srvpTiles then
CountPageAtPaper := Max((Floor(PageWidthPix) div Floor(TotalFrameWPix)), 1)
* Max((Floor(PageHeightPix) div Floor(TotalFrameHPix)), 1)
else
CountPageAtPaper := 1;
lastPgNo := Min(SRichViewEdit.LastPageNo, lastPgNo);
BeginUpdate;
StartPrint := True;
OldOrientation := Orientation;
Printer.Orientation := Orientation;
Printer.BeginDoc;
if Assigned(FOnSendingToPrinter) then
FOnSendingToPrinter(SRichViewEdit, 0, 0, rvpsStarting);
for indexCopys := 1 to PrintCopies do
begin
if (FPrintMode = srvpGrid) then
Step := PageColCount * PageColCount
else
Step := CountPageAtPaper;
indexPage := Max(SRichViewEdit.FirstPageNo, firstPgNo);
while (indexPage <= lastPgNo) do
begin
if not Collate then
for indexCopys2 := 1 to Copies do
begin
if not StartPrint then
Printer.NewPage;
StartPrint := False;
EP := Min(indexPage + CountPageAtPaper - 1, lastPgNo) - 1;
EP := (EP div CountPageAtPaper) * CountPageAtPaper +
(EP mod CountPageAtPaper) + 1;
for j := indexPage to EP do
PrintFramesEx(j);
end
else
begin
if not StartPrint then
Printer.NewPage;
StartPrint := False;
EP := Min(indexPage + CountPageAtPaper - 1, lastPgNo) - 1;
EP := (EP div CountPageAtPaper) * CountPageAtPaper +
(EP mod CountPageAtPaper) + 1;
for j := indexPage to EP do
PrintFramesEx(j);
end;
indexPage := (((indexPage - 1 + Step) div CountPageAtPaper) *
CountPageAtPaper) + 1;
end;
end;
Printer.EndDoc;
Printer.Orientation := OldOrientation;
if Assigned(FOnSendingToPrinter) then
FOnSendingToPrinter(SRichViewEdit, 0, 0, rvpsFinished);
EndUpdate;
Printer.Copies := OldPrintCopies;
end;
Alexander.