Using Lazarus on Win 11 FPC v 3.7.2.
I'm using Printer4Lazarus 0.5
I'm new to Laz Pas, and to this forum. Please bear with me.
I've developed an ap which is working fine, and creates nice graphics.
Problem: I can't print the graphic on my HP Smart Tank 5100- I get an error
which isn't described by the HP software.
I tried the following code, taken from an example I researched:
procedure T_ATLAS_._PrintClick(Sender: TObject);
const
kLeftmargin = 100;
kHeadline = 'I Printed My Very First Text On ';
var
YPos, LineHeight, TopMargin: Integer;
SuccessString: String;
begin
if PrintDialog1.execute then begin //SIGSEGV fix- 1 of 2 lines
with Printer do
try
//Prepare the "paper"...
BeginDoc;
Canvas.Font.Name := 'Courier New';
Canvas.Font.Size := 10;
Canvas.Font.Color := clBlack;
LineHeight := Round(1.2 * Abs(Canvas.TextHeight('I')));
TopMargin := 4 * LineHeight;
//Put writing on it...
YPos := TopMargin;
SuccessString := kHeadline + DateTimeToStr(Now);
Canvas.TextOut(kLeftmargin, YPos, SuccessString);
finally //If all of the above completed okay,
//"EndDoc" will trigger the actual printing...
EndDoc;
end; //of "try... finally..."
end; //SIGSEGV fix- 2 of 2 lines
end; [code/pascal]
The print job dies with an error I can only clear by going to the
Settings / ... / Printers, opening the print queue, and cancelling.
HOWEVER
If I send the job to a PDF file, then run Acrobat to view it,
it prints perfectly!!!
My original code is more complicated - I copy a bitmap to the print
canvas. In both cases, the PDF file works fine, but not direct to the
Smart Tank.
Many thanks for any clues as to what I'm doing wrong.
- JerryHudson