Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi PDF ausdrucken (https://www.delphipraxis.net/125501-pdf-ausdrucken.html)

API 7. Dez 2008 15:46


PDF ausdrucken
 
Hi!

So drucke ich eine PDF Datei aus:

Delphi-Quellcode:
ShellExecute_AndWait('print', Path + '\' + SearchRec.Name, '','', SW_HIDE, True)
Problem: Adobe öffnet sich aber beendet sich nach dem Drucken nicht selber. Wie geht das ?

Delphi-Quellcode:
function ShellExecute_AndWait(Operation, FileName, Parameter, Directory: string;
  Show: Word; bWait: Boolean): Longint;
var
  bOK: Boolean;
  Info: TShellExecuteInfo;
begin
  FillChar(Info, SizeOf(Info), Chr(0));
  Info.cbSize := SizeOf(Info);
  Info.fMask := SEE_MASK_NOCLOSEPROCESS;
  Info.lpVerb := PChar(Operation);
  Info.lpFile := PChar(FileName);
  Info.lpParameters := PChar(Parameter);
  Info.lpDirectory := PChar(Directory);
  Info.nShow := Show;
  bOK := Boolean(ShellExecuteEx(@Info));
  if bOK then
  begin
    if bWait then
    begin
      while
        WaitForSingleObject(Info.hProcess, 100) = WAIT_TIMEOUT
        do Application.ProcessMessages;
      bOK := GetExitCodeProcess(Info.hProcess, DWORD(Result));
    end
    else
      Result := 0;
  end;
  if not bOK then Result := -1;
end;

Klaus01 7. Dez 2008 16:13

Re: PDF ausdrucken
 
Hallo,

kanst Du dem AdobeReader Fenster nicht eine WM_CLOSE Nachricht schicken?
Delphi-Quellcode:
PostMessage(Handle, WM_CLOSE, 0, 0); { Close the app }
Grüße und noch einen schönen 2. Advent
Klaus

API 7. Dez 2008 17:24

Re: PDF ausdrucken
 
Zitat:

Zitat von Klaus01
kanst Du dem AdobeReader Fenster nicht eine WM_CLOSE Nachricht schicken?
Delphi-Quellcode:
PostMessage(Handle, WM_CLOSE, 0, 0); { Close the app }
Klaus

Können schon, doch wie kann ich wissen wenn der Druckbefehl abgearbeitet worden ist?
Gibt es evtl. einen Startparameter beim Acrobat Reader?

Klaus01 7. Dez 2008 19:04

Re: PDF ausdrucken
 
Guten Abend,

mit welchen Parametern startest Du denn Deinen Arcobat Reader?

Im Web habe ich folgendes gefunden:

Zitat:

Zitat von http://www.robvanderwoude.com/printfiles.html
So, to automatically close the Adobe/Acrobat Reader window after printing, the following requirements must all be met:

1. A single file name must be specified on the command line (wildcards are still allowed, just as long as they "translate" into a single file name)
2. The batch file's /M switch must not be used
3. No other instance of Adobe/Acrobat Reader must be active

Grüße
Klaus

API 8. Dez 2008 04:36

Re: PDF ausdrucken
 
Zitat:

Zitat von Klaus01
Guten Abend,

mit welchen Parametern startest Du denn Deinen Arcobat Reader?

Hallo Klaus, genau so wie oben gezeigt. Also ohne Parameter.

Werde mal das probieren:

PathToAcrobat.exe /t Filename Printer PrintDriver PrinterPort

Wobei /t = prints the document and is supposed to terminate.


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:07 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz