To print "only" to a canvas when no FileName is set, I added the "else" in the following code of the DoPrint procedure.
Is that correct?
procedure TTMSFMXCustomGrid.DoPrint(ASelection: TCellRange; APages: array of Integer; AFileName: String = '';
ACanvas: TCanvas = nil; AResetPosition: Boolean = False; AWidth: Integer = -1; AHeight: Integer = -1);
if CanPrintPage(APageIndex) then
begin
if AFileName = '' then
begin
if ACanvas <> nil then
ACanvas.DrawBitmap(bmp, RectF(0, 0, bmp.Width, bmp.Height), RectF(0, 0, bmp.Width, bmp.Height), 1)
else // <-- Added else here
begin
Printer.Canvas.DrawBitmap(bmp, RectF(0, 0, bmp.Width, bmp.Height), RectF(0, 0, bmp.Width, bmp.Height), 1);
DoPrintEndPage(APageIndex, Printer);
end;
end
else
bmp.SaveToFile(AFileName);
end;
Hi,
You can already print to an image with
TMSFMXGrid1.PrintPageToImage
Kind Regards,
Pieter
I'm doing a PrintSelection of a cell range to my own bitmap object. Your code draws to both my bitmap's canvas and the printer's canvas. Why? The structure of the code lends itself to a ELSE being there at one time and was accidentally removed. Who puts a begin and end around standalone code?
You're correct, the "else" statement seems to have gotten lost. We've fixed this.