# Delphi 5 Printing

## Recommended Posts

Is anybody aware if Win 10 has changed its API in regard to printing?  My flagship program has been running for 20yrs but suddenly 2 customers who have purchased new HP printers have found they cannot print from it.  Then yesterday another custome found they could not print to an older Canon printer despite loading the newest drivers and also despite other programs being able to print.  Has everybody moved over to GDI printing? and if so is there a Delphi 5 solution?

Well, how are you printing at the moment, if not using GDI? And GDI printing must be like 30 years old now.

• 1

TPrinter/TCanvas is GDI printing.

It's likely that there are bugs in TPrinter in Delphi 5 that has since been fixed. I seem to recall that there were quite a lot of them. Buffer overflows and whatnot.

What has happened is probably that your application has been using GDI in a way that was invalid but was worked around by Windows and now they've stopped working around it.

• 1

Thanks for those inputs.  From what you have said, and since the program is working quite happily on many other computers including the development machine, I have a suspicion that it may be the drivers and not Windows after all.

What about the printer name? Isn't it just quite long?

ShellExecute(Application.Handle, PChar('print'), PChar('A:\Path\to\a\file\to\print.pdf'), PChar(''), nil, SW_HIDE);

you can let windows handle everything with that.

this would open whatever programm is associated to print that file.

//edit

if you want full control, customized-printing-in-delphi, here you find everything you need.

Edited by KodeZwerg

Had the same problem, solved it by selecting a different printer, that appeared in my printers list, when I installed my new HP-deskjet printer. Printer name is "HP Smart Printing". I selected that printer as default.

A few years back Microsoft released an update that broke printing on Epson Dot Matrix printers. Fortunately it was quickly fixed with a follow-up update as so many financials still work on Dot Matrix printers. We had a busy week that week.

There are other similar cases. One being;

Anything new on this? I am having the same problem with HP and Canon wireless printers under both Delphi 11 and Delphi 6. All printing from my Delphi programs fails on these printers, whether drawing to the printer canvas or using AssignPrn and writing text to the device.

My customers can dump to pdf and print from there, but I was hoping there was a fix, or at least a better work-around, since for some of them, switching printers is not an option.

6 hours ago, Thuddeus said:

Anything new on this? I am having the same problem with HP and Canon wireless printers under both Delphi 11 and Delphi 6. All printing from my Delphi programs fails on these printers, whether drawing to the printer canvas or using AssignPrn and writing text to the device.

My customers can dump to pdf and print from there, but I was hoping there was a fix, or at least a better work-around, since for some of them, switching printers is not an option.

it is very funny that blaming Delphi for bugs on printer driver (usually this is the source of trouble) will solve this problem.
the most reliable way to solve this problem is to communicate with printer driver author.
explain your problem and send them your most simple program that show where the problem is.

however reaching the author is not as easy at all.

This may or may not be relevant, but this thread reminded me of a fix I made a while back, adding the following line to my printing code

Printer.Title := ProgName + ' calcs ';   // 11.11.18 latest Win10 update falls over without this

• 1