I am using TAdvPDFViewer, version 1.0.2.1, with Delphi 10.4 to display existing PDF documents. This works fine.
When I want to print a PDF that is currently being displayed, I call advPDF.Print(FILENAME).
If Foxit Reader is installed on the PC, the PDF document is printed as expected.
Even if another document is open in Foxit Reader, this does not affect the behavior of AdvPDF.
That's great!
However, if Acrobat Reader is installed on the PC, Acrobat opens, takes control, and prevents the PDF document from being printed directly. Ideally, Acrobat shouldn't open at all.
How can I prevent Acrobat Reader from taking control?
Delphi is printing on the active printer. If Acrobat Reader is installed, it could be possible that it takes over the default printer. You can manipulate which printer is active. There are several ways to do this, one being a TPrinterDialog component executed before printing. If you don't want user interaction, you might need to programmatically force another default printer.
uses
Vcl.Printers;
procedure TForm1.SelectPrinterByName(const AName: string);
var
I: Integer;
begin
for I := 0 to Printer.Printers.Count - 1 do
if SameText(Printer.Printers[I], AName) then
begin
Printer.PrinterIndex := I;
Exit;
end;
raise Exception.CreateFmt('Printer "%s" not found.', [AName]);
end;