Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-05-2001, 03:35 PM
fdugger fdugger is offline
Junior Member
 
Join Date: Jan 2001
Posts: 5
Default Printing a PDF Form

Hi,

I have a number of forms in PDF format that I would like to print from within my program. The user would push a button and the forms associated with that selection would print without having to fire up acrobat reader and selecting print from that application. Is this possible?

Thanks
fdugger
Reply With Quote
  #2  
Old 01-05-2001, 10:40 PM
tomtom62 tomtom62 is offline
Junior Member
 
Join Date: Jan 2001
Posts: 18
Default RE: Printing a PDF Form

Try pdflib. I don't know the url at the moment, but you should find it via searchengines. AFAIK its free for private use.
Reply With Quote
  #3  
Old 01-07-2001, 02:57 AM
decumont decumont is offline
Junior Member
 
Join Date: Jan 2001
Posts: 1
Default RE: RE: Printing a PDF Form

Hello Tom,
If you find a delphi solution to bypass the acrobat Printer i am very interrested.

Actually i am printing a lot of invoice to the Acrobat Printer.

You can find a lot of info at www.planetpdf.com

I paste the code i use to set the file name
------------------------------------------------------------
unit cmb_PDFWriter;

interface

Function InitializePDF(Const ForceRefresh:Boolean=False):Boolean;
Function SetFileName(Const FileName:String;Const ViewFile:Boolean):Boolean;

implementation

Uses Windows, SysUtils, Registry, Inifiles;

Const
_PDFWriter_Initialized : Boolean = False;
_PDFWriter_Settings_Found: Boolean = False;
_PDFWriter_Use_Registry : Boolean = False;
{ Global variable to store the PDF INI files only on Win95 }
_PDFWriter_Ini_File : String = '';


//------------------------------------------------------------------------------
Function InitializePDF(Const ForceRefresh:Boolean=False):Boolean;
Var TheRegistry:TRegistry;
begin
result:=False;

if (ForceRefresh) or (not _PDFWriter_Initialized) then Begin
_PDFWriter_Initialized:=True;
_PDFWriter_Settings_Found:=False;
TheRegistry:=TRegistry.create;
try
//First Try to Find if PDF writer use the Registry or the __PDF.ini file
//by looking the the key HKEY_CURRENT_USER\Software\Adobe\Acrobat PDFWriter
TheRegistry.RootKey:=HKEY_CURRENT_USER;
_PDFWriter_Use_Registry:=TheRegistry.OpenKey('Soft ware\Adobe\Acrobat PDFWriter',false);

if _PDFWriter_Use_Registry then Begin
//OK the KEY exist so we are using the Registry !!!
_PDFWriter_Settings_Found:=True;
result:=True
end else Begin
//Try to locate the __PDF.INI files
_PDFWriter_Ini_File:='';
case Win32Platform of
VER_PLATFORM_WIN32_WINDOWS:begin
TheRegistry.RootKey:=HKEY_LOCAL_MACHINE;
TheRegistry.OpenKey('Software\Microsoft\Windows\Cu rrentVersion',false);
_PDFWriter_Ini_File:=TheRegistry.ReadString('Syste mRoot')+'\System\PDFWritr.ini';
end;
VER_PLATFORM_WIN32_NT:Begin
TheRegistry.RootKey:=HKEY_LOCAL_MACHINE;
TheRegistry.OpenKey('Software\Microsoft\Windows NT\CurrentVersion',false);
_PDFWriter_Ini_File:=TheRegistry.ReadString('Syste mRoot')+'\System32\Spool\Drivers\W32X86';
if Win32MajorVersion=5 then
_PDFWriter_Ini_File:=_PDFWriter_Ini_File+'\2\__pdf .ini'
else
if Win32MajorVersion=4 then
_PDFWriter_Ini_File:=_PDFWriter_Ini_File+'\2\__pdf .ini'
else
_PDFWriter_Ini_File:=_PDFWriter_Ini_File+'\1\__pdf .ini';
end end;

if (_PDFWriter_Ini_File<>'')and(FileExists(_PDFWriter_Ini_File)) then Begin
_PDFWriter_Settings_Found:=True;
result:=True
end end;
finally
TheRegistry.free
end end else
result:=_PDFWriter_Settings_Found

end;
{------------------------------------------------------------------------------}
Function SetFileName(Const FileName:String;Const ViewFile:Boolean):Boolean;
Var tf:TMemIniFile;
TheRegistry:TRegistry;
begin
result:=False;

If not _PDFWriter_Initialized Then
InitializePDF;

If not _PDFWriter_Settings_Found Then
Raise Exception.Create('PDF Writer does not seems to be Installed !!');

If _PDFWriter_Use_Registry Then Begin
TheRegistry:=TRegistry.create;
try TheRegistry.Access:=KEY_ALL_ACCESS;
TheRegistry.RootKey:=HKEY_CURRENT_USER;
TheRegistry.OpenKey('Software\Adobe\Acrobat PDFWriter',false);
if ViewFile Then
TheRegistry.WriteString('bExecViewer','1') else
TheRegistry.WriteString('bExecViewer','0');
TheRegistry.WriteString( 'FileNameSet','1');
TheRegistry.WriteString( 'szAuthor' ,'CommBilling');
TheRegistry.WriteString( 'PDFFileName',FileName);
//result:=False; as we use the PrintToFile of the cmb_Printers unit !!!
finally
TheRegistry.Free
end end else Begin
Assert(_PDFWriter_Ini_File<>'');
Assert(FileExists(_PDFWriter_Ini_File));
//Open Log File and write Start of import..............................
tf:=TMemIniFile.Create(_PDFWriter_Ini_File);
try tf.WriteString('Acrobat PDFWriter','FileNameSet','1');
tf.WriteString('Acrobat PDFWriter','PDFFileName',FileName);
if ViewFile Then
tf.WriteString('Acrobat PDFWriter','bExecViewer','1') else
tf.WriteString('Acrobat PDFWriter','bExecViewer','0');
tf.UpdateFile;
finally
tf.free
end end
end;

end.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 08:23 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.