![]() |
PDF Creator innerhalb Delphi nutzen
Hallo zusammen,
ich habe mir den PDF Creator installiert und versuche nun schon längere Zeit diesen innerhalb eines Delphi-Programms zu nutzen, es will mir aber nicht gelingen. Ich habe ein Report-Programm das den Ausdruck in den PDF Creator macht aber ich möchte dann den PDF Creator innerhalb meines Delphi Programms steuern, als z.B. die vorhandenen PrintJobs als PDF speichern usw. Hat jemand von euch sowas schon mal gemacht und kann mir, am besten mit einem kleinen Delphi-Programm oder gepostetem Source, zeigen wie man PDF Creator in einem Delphi Programm nutzt? |
AW: PDF Creator innerhalb Delphi nutzen
Einfach den PDFCreator-Drucker auswählen
|
AW: PDF Creator innerhalb Delphi nutzen
Zitat:
Ich möchte den PDF Creator innerhalb Delphi nutzen....also Typbibliothek einbinden usw.... |
AW: PDF Creator innerhalb Delphi nutzen
Warum auch einfach wenn es kompliziert geht. Dann würde ich aber auf den PDFCreator verzichten ( den dieses Programm kümmert sich eigentlich nur um den Drucker) und gleich GhostScript verwenden ( welches von PDFCreator ja verwendet wird)
|
AW: PDF Creator innerhalb Delphi nutzen
Zitat:
|
AW: PDF Creator innerhalb Delphi nutzen
Die eigentlich PDF-Erzeugung wird beim PDFCreator auch von GhostScript erledigt.
|
AW: PDF Creator innerhalb Delphi nutzen
Zitat:
|
AW: PDF Creator innerhalb Delphi nutzen
|
AW: PDF Creator innerhalb Delphi nutzen
Zitat:
|
AW: PDF Creator innerhalb Delphi nutzen
Zitat:
|
AW: PDF Creator innerhalb Delphi nutzen
Die unterstützen im Moment wohl kein Delphi.
Zitat:
|
AW: PDF Creator innerhalb Delphi nutzen
Zitat:
|
AW: PDF Creator innerhalb Delphi nutzen
|
AW: PDF Creator innerhalb Delphi nutzen
Oder
![]() |
AW: PDF Creator innerhalb Delphi nutzen
Folgender im Netz gefundener Sourcecode als Beispiel für eine späte Bindung funktioniert:
Delphi-Quellcode:
Ich hätte aber gern die frühe Bindung eingesetzt (wie z.B. im PDFCreator COM Sample für C# gezeigt), leider funktioniert dieses nicht, wenn ich es in Delphi umsetze. Der Vorteil wäre, dass man dann auf Ereignisse wie OnError und OnReady reagieren könnte.
unit uPDFCreator;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ActiveX, ComObj, Mask, JvExMask, JvToolEdit; type TForm1 = class(TForm) Edit1: TEdit; ButtonExecute : TButton; procedure ButtonExecuteClick(Sender: TObject); private PDFCreator, MSWord: OleVariant; optUseAutosave, optUseAutoSaveDirectory, optAutosaveFormat, optPDFColorsColorModel: Integer; optAutosaveDirectory, optAutosaveFilename: String; // Security Options optPDFUseSecurity, optPDFHighEncryption, optPDFOwnerPass: Integer; optPDFDisallowCopy, optPDFDisallowModifyAnnotations, optPDFDisallowModifyContents, optPDFDisallowPrinting: Integer; optPDFAllowAssembly, optPDFAllowDegradedPrinting, optPDFAllowFillIn, optPDFAllowScreenReaders: Integer; optPDFOwnerPasswordString: String; procedure StorePDFOptions; procedure SetPDFOptions(const filename, ownerpass: String); procedure RestorePDFOptions; public end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.ButtonExecuteClick(Sender: TObject); const output_filename: String = 'D:\test.pdf'; owner_password: String = ''; var c, printJobCount: Integer; optPrintBackground: Boolean; begin PDFCreator := CreateOLEObject('PDFCreator.clsPDFCreator'); PDFCreator.cStart('/NoProcessingAtStartup'); StorePDFOptions; SetPDFOptions(output_filename, owner_password); MSWord := CreateOleObject('Word.Application'); try MSWord.DisplayAlerts := 0; MSword.Documents.Open(Edit1.Text); MSWord.ActiveDocument.TrackRevisions := false; optPrintBackground := MSWord.Options.PrintBackground; if not optPrintBackground then MSWord.Options.PrintBackground := True; MSWord.ActiveWindow.View.ShowRevisionsAndComments := False; MSWord.Options.WarnBeforeSavingPrintingSendingMarkup := false; printJobCount := PDFCreator.cCountOfPrintJobs; /// ------------------------------------------ /// Have PDFCreator wait for pages PDFCreator.cPrinterStop := true; MSWord.ActiveDocument.PrintoutOld; /// we don't want to continue on right after telling word to print, because it can cause problems while MSWord.BackgroundPrintingStatus <> 0 do begin Sleep(10); Application.ProcessMessages; end; /// Tell PDFCreator we're done printing pages. PDFCreator.cPrinterStop := false; /// ------------------------------------------ /// now wait for PDFCreator to finish c := PDFCreator.cCountOfPrintJobs; while c > printJobCount do begin Sleep(10); Application.ProcessMessages; c := PDFCreator.cCountOfPrintJobs; end; MSword.ActiveDocument.Close(SaveChanges := 0); finally VarClear(MSWord); end; RestorePDFOptions; PDFCreator.cClose; VarClear(PDFCreator); end; procedure TForm1.RestorePDFOptions; begin PDFCreator.cOption('UseAutosave') := optUseAutosave; PDFCreator.cOption('UseAutosaveDirectory') := optUseAutosaveDirectory; PDFCreator.cOption('AutosaveDirectory') := optAutosaveDirectory; PDFCreator.cOption('AutosaveFilename') := optAutosaveFilename; PDFCreator.cOption('AutosaveFormat') := optAutosaveFormat; PDFCreator.cOption('PDFColorsColorModel') := optPDFColorsColorModel; // security options PDFCreator.cOption('PDFUseSecurity') := optPDFUseSecurity; PDFCreator.cOption('PDFHighEncryption') := optPDFHighEncryption; PDFCreator.cOption('PDFOwnerPass') := optPDFOwnerPass; PDFCreator.cOption('PDFOwnerPasswordString') := optPDFOwnerPasswordString; PDFCreator.cOption('PDFDisallowCopy') := optPDFDisallowCopy; PDFCreator.cOption('PDFDisallowModifyAnnotations') := optPDFDisallowModifyAnnotations; PDFCreator.cOption('PDFDisallowModifyContents') := optPDFDisallowModifyContents; PDFCreator.cOption('PDFDisallowPrinting') := optPDFDisallowPrinting; PDFCreator.cOption('PDFAllowAssembly') := optPDFAllowAssembly; PDFCreator.cOption('PDFAllowDegradedPrinting') := optPDFAllowDegradedPrinting; PDFCreator.cOption('PDFAllowFillIn') := optPDFAllowFillIn; PDFCreator.cOption('PDFAllowScreenReaders') := optPDFAllowScreenReaders; PDFCreator.cSaveOptions; Sleep(100); end; procedure TForm1.SetPDFOptions(const filename, ownerpass: String); begin // set the options we want, auto-save PDF with specific filename PDFCreator.cOption('UseAutosave') := 1; PDFCreator.cOption('UseAutosaveDirectory') := 1; PDFCreator.cOption('AutosaveDirectory') := ExtractFilePath(filename); PDFCreator.cOption('AutosaveFilename') := ExtractFileName(filename); PDFCreator.cOption('AutosaveFormat') := 0; // PDF format PDFCreator.cOption('PDFColorsColorModel') := 0; // RGB format if Trim(ownerpass) <> '' then begin PDFCreator.cOption('PDFUseSecurity') := 1; PDFCreator.cOption('PDFHighEncryption') := 1; PDFCreator.cOption('PDFOwnerPass') := 1; PDFCreator.cOption('PDFOwnerPasswordString') := ownerpass; PDFCreator.cOption('PDFDisallowCopy') := 0; PDFCreator.cOption('PDFDisallowModifyAnnotations') := 1; PDFCreator.cOption('PDFDisallowModifyContents') := 1; PDFCreator.cOption('PDFDisallowPrinting') := 0; PDFCreator.cOption('PDFAllowAssembly') := 0; PDFCreator.cOption('PDFAllowDegradedPrinting') := 0; PDFCreator.cOption('PDFAllowFillIn') := 0; PDFCreator.cOption('PDFAllowScreenReaders') := 0; end; PDFCreator.cSaveOptions; end; procedure TForm1.StorePDFOptions; begin // save the current options to put back when we're finished. optUseAutosave := PDFCreator.cOption['UseAutosave']; optUseAutosaveDirectory := PDFCreator.cOption['UseAutosaveDirectory']; optAutosaveDirectory := PDFCreator.cOption['AutosaveDirectory']; optAutosaveFilename := PDFCreator.cOption['AutosaveFilename']; optAutosaveFormat := PDFCreator.cOption['AutosaveFormat']; optPDFColorsColorModel := PDFCreator.cOption['PDFColorsColorModel']; // security options optPDFUseSecurity := PDFCreator.cOption['PDFUseSecurity']; optPDFHighEncryption := PDFCreator.cOption['PDFHighEncryption']; optPDFOwnerPass := PDFCreator.cOption['PDFOwnerPass']; optPDFOwnerPasswordString := PDFCreator.cOption['PDFOwnerPasswordString']; optPDFDisallowCopy := PDFCreator.cOption['PDFDisallowCopy']; optPDFDisallowModifyAnnotations := PDFCreator.cOption['PDFDisallowModifyAnnotations']; optPDFDisallowModifyContents := PDFCreator.cOption['PDFDisallowModifyContents']; optPDFDisallowPrinting := PDFCreator.cOption['PDFDisallowPrinting']; optPDFAllowAssembly := PDFCreator.cOption['PDFAllowAssembly']; optPDFAllowDegradedPrinting := PDFCreator.cOption['PDFAllowDegradedPrinting']; optPDFAllowFillIn := PDFCreator.cOption['PDFAllowFillIn']; optPDFAllowScreenReaders := PDFCreator.cOption['PDFAllowScreenReaders']; end; end. Eins noch: Der o.a. Quellcode funktionierte bei mir erst dann, als ich den PDFCreator-Druckertreiber auf Direktdruck gestellt habe. Kenn jemand eine Möglichkeit, dies vom Programmcode aus einzustellen? |
AW: PDF Creator innerhalb Delphi nutzen
Hm, bei mir funktioniert es nicht. Ich kann noch nicht einmal programmseitig, also von Delphi aus, den Namen der pdf-Datei festlegen.... :shock:
|
AW: PDF Creator innerhalb Delphi nutzen
Vielleicht hilft etwas von
![]() |
AW: PDF Creator innerhalb Delphi nutzen
Danke erstmal für die Antwort. Ich weiß nicht, ob ich dich richtig verstanden habe, aber ich habe nur beim Arbeiten mit dem pdfCreator das Problem, dass der filename nicht vergeben werden kann. Der Codeschnipsel hat bei mir keine Auswirkungen. Der pdfcreator arbeitet an sich einwandfrei, ich kann pdfs drucken, habe auch einen ähnlichen Code wie in dem von dir beschriebenen link laufen, alles korrekt. Aber der pdfcreator hört nicht auf meine filename-Zuweisung. Ausgegeben werden immer pdf-Dateien, deren Format etwa so ausschaut. 20110728093845.pdf. Also Datum zuerst und dann ein Rest. Hat jemand vielleicht noch einen Rat?!?
|
AW: PDF Creator innerhalb Delphi nutzen
Ich hab das mal in Excel nach der folgenden Anleitung gemacht:
![]() Da stand auch was zu den Settings: ![]() OK. Ist VBA aber die Idee dahinter sollte dieselbe sein. Was den Filename angeht, kann man (wenn ich mich recht erinnere) irgendwo in den Programmeinstellungen einstellen, das der einen automatischen Namen vergeben soll und dann ist es egal, was man bei filename angibt, das wird ignoriert. Keine Ahnung, wie man das per Programmierung ausstellt, doch kann man das ja testweise auch manuell im PDFCreator selbst machen. Einmal geändert, müsste die Einstellung erhalten bleiben. |
AW: PDF Creator innerhalb Delphi nutzen
Hallo
Vielleicht hilft dir das weiter , im pdfCreator auf Autospeichern stellen und dann von Delphi aus die Pfade in die registry schreiben ==> Dann druckt er in die gewünschte Datei mfg Reinhold var reg: TRegistry; begin result := false; reg := TRegistry.create; reg.RootKey := HKEY_CURRENT_USER; if reg.OpenKey('\Software\PDFCreator\Program',false) then begin reg.LazyWrite := false; reg.WriteString('AutoSaveDirectory',extractfilepat h(Pdf_Dateiname)); reg.WriteString('AutoSaveFilename',extractfilename (Pdf_Dateiname)); reg.WriteString('UseAutosave','1'); result := true; reg.CloseKey; sleep(10); end; reg.Free; |
AW: PDF Creator innerhalb Delphi nutzen
Hallo rweinzierl,
danke für die Antwort. Ich habe es ausprobiert, aber der Code hat keine Auswirkung. Der Name wird weiterhin vom Creator festgelegt, der Pfad auch, egal was ich versuche. Hast du den Codeschnipsel ausprobiert und bei dir zum Laufen gebracht? Fände ich jetzt seeeeehr interessant ... LG Inca |
AW: PDF Creator innerhalb Delphi nutzen
hallo cogito,
ich hatte das prob mit der zuweisung eines filnames im pdf creator vor längerer zeit ebenfalls, wenn ich mich recht entsinne, habe ich zuerst das doc nach word geschrieben, vor dort aus gespeichert und konnte dann den von word erstellten filename zum erstellen des pdf doc filnamens verwenden.... vielleicht sehr umständlich, aber irgendwie funzte das, :oops: vielleicht reicht dir das ja, um ne richtung oder möglichkeit zu erkennen ... leider find ich grad das prog nicht :? , wenn doch, poste ich mal ein bisschen code.... mfg henk |
AW: PDF Creator innerhalb Delphi nutzen
Hallo,
ich muß dieses Thema mal aus dem Keller holen. Ich nutze seit Jahren eine modifizierte Variante des unter ![]() Auf diesen Rehner läuft der Befehl "CreateOLEObject('PDFCreator.clsPDFCreator')" auf einen Fehler, weil die Klasse nicht gefunden wird. PDF Creator ist aber installiert. Mir fehlt (noch) jegliche Erfahrung im Umgang mit 64 bit. Somit stehe ich auch entsprechend auf dem Schlauch. Würde mir hier jemand helfen? Schön ware es, wenn mein Programm - kompiliert als Win32 - sowohl unter 32 bit als auch unter 64 bit laufen würde. Gruß aus Köln Thomas |
AW: PDF Creator innerhalb Delphi nutzen
Der Fehler hat nichts mit 64 Bit zu tun - seit der Version 2.0 hat der PDF Creator eine neue COM-Schnittstelle eingeführt, die zu der alten nicht mehr kompatibel ist.:(
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:55 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-2025 by Thomas Breitkreuz