Delphi: From Delphi we cannot use the PDF Printer...

This is a read only forum. It contains the most frequently asked questions about Amyuni products and licensing.
Post Reply
Dany
Amyuni Team
Posts: 113
Joined: Wed Sep 11 2002
Location: Montreal.
Contact:

Delphi: From Delphi we cannot use the PDF Printer...

Post by Dany » Fri Aug 05 2005

Printer unless it is set as the default printer on the system.

There is no need for the PDF Converter to be the default printer. We have noticed that when you switch among printers in Delphi, it keeps in memory the DEVMODE structure of the default printer and tries to use that for the other printers (whether the PDF Converter or other).

The problem under Delphi might be fixed by using the following code:
var
szDevice,
szDriver,
szPort: array[0..255] of Char;
hDeviceMode: THandle;

{ Make shure DeviceMode is 0 }
Printer.GetPrinter(szDevice, szDriver, szPort, hDeviceMode);
Printer.SetPrinter(szDevice, szDriver, szPort, 0);

Printer.BeginDoc
...

Printer.EndDoc;


This code clears the 'wrong' DEVMODE structure that Delphi is passing to the
printer and should solve the problem.

Post Reply