Neevia Technology Sites:   www.neevia.com  |  docuPub.com  |  www.neeviaPDF.com
:: Home :: Products :: Technical Support :: About Us :: Contact Us
Technical support > Neevia docuPrinter SDK code samples
Example 1: How to create a simple PDF file from Delphi  Print Example 

procedure TForm1.Button1Click(Sender: TObject);
var
  I : Integer;
  DPSDK   : Variant;
  RVal : Integer;
  OldIndex : Integer;
  printerIndex : Integer;
begin

   DPSDK:=CreateOleObject('docuPrinter.SDK');

   OldIndex:=Printer.PrinterIndex;
   printerIndex:=-1;
   Printer.Refresh;
   for I:=0 to Printer.Printers.Count-1 do
   begin
     if CompareText(Printer.Printers.Strings[i],'docuPrinter')=0 then
     begin
       printerIndex:=I;
       Printer.PrinterIndex:=printerIndex;
       break;
     end;
   end;

   If printerIndex=-1 Then
   begin
     ShowMessage('Printer not found!!!');
     Exit;
   end
   else Printer.PrinterIndex:=printerIndex;

   DPSDK.DocumentOutputFormat:= 'PDF';
   DPSDK.DocumentOutputName:= 'demoDelphi';
   DPSDK.DocumentOutputFolder:= 'c:\';

   DPSDK.HideSaveAsWindow:= true;
   DPSDK.DefaultAction:=1;
   DPSDK.ApplySettings;

   Printer.Title:='Hello !';
   Printer.BeginDoc;
   Printer.Canvas.Font.Name:= 'Times New Roman';
   Printer.Canvas.Font.Size:= 48;
   Printer.Canvas.TextOut(0,0,'Hello from Borland Delphi!!!');
   Printer.EndDoc;

   RVal:= DPSDK.Create; // Create output document
   If (RVal <> 0) Then
      ShowMessage('Error while creating document!!!')
   else
      ShowMessage('Done !!!');

   Printer.PrinterIndex:=OldIndex;

   DPSDK:= Unassigned;
end;



Copyright © 1999-2016 Neevia Technology. All Rights Reserved. Home | Products | Technical Support | About Us | Contact Us