Recent

Author Topic: Printing on HP Smart Tank  (Read 405 times)

JerryHudson

  • Newbie
  • Posts: 3
Printing on HP Smart Tank
« on: July 11, 2026, 01:23:59 am »
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
 

jamie

  • Hero Member
  • *****
  • Posts: 7891
Re: Printing on HP Smart Tank
« Reply #1 on: July 11, 2026, 01:55:25 am »
Just throwing it out there, did you try using the "BeginPage", print your stuff and then "EndPage"?

This can be done after the BeginDoc and you should be able to set your fonts etc before BeginPage.

also, when you change your selection in the Printer dialog, make sure you use the "Refresh" property in the TPrinter class.

Something to try.

Btw, where did you get that version of FPC ? 3.7.x

Jamie


The only true wisdom is knowing you know nothing

JerryHudson

  • Newbie
  • Posts: 3
Re: Printing on HP Smart Tank
« Reply #2 on: July 11, 2026, 10:22:12 pm »
Jamie -
I see you've contributed hugely to the forum - you've helped me while helping other folks.
I tried the BeginPage just after the font stuff, and put an EndPage at the
end. There was a number associated with the error message:
hp3/d185 which appeared on the print queue. Am guessing that's only
the print job number.
I had some other issues with the Smart Tank earlier today, trying to
print something off the web. I might call the Geek Squad (I have a
contract). Anyhow, thanks for the suggestion! - Jerry
P.S. I think the driver is up to date.

JerryHudson

  • Newbie
  • Posts: 3
Re: Printing on HP Smart Tank
« Reply #3 on: July 13, 2026, 12:34:35 am »
Looks like the matter has been resolved. Thanks considerably to Duck AI. The issue appears to be with the driver. Uninstalling the HP and re-installing it seems to have cleared the problem. Not sure how to call the issue resolved on this blog, but I consider it closed. Many thanks, particularly to Jamie.
- Jerry

Thaddy

  • Hero Member
  • *****
  • Posts: 19607
  • Glad to be alive.
Re: Printing on HP Smart Tank
« Reply #4 on: July 13, 2026, 07:10:37 am »
You can edit the header from the first entry. We normal people can't.
Any "programmer" that knows only one programming language is not a programmer

 

TinyPortal © 2005-2018