How to Create a New PDF Document
Knowledge Base :: PDF Creator Pilot 4 Knowledge Base

See Also
Collapse All

First add PDF Creator Pilot library to you project.

For Delphi:

Select "Project" -> "Import Type Library" command as shown below:

The import dialog will appear. Find and select PDF Creator Pilot in the libraries list and press "Install..." button:

Delphi will suggest you to install PDF Creator Pilot into the user component package and the Install dialog will appear:

Press OK and confirm it by pressing Yes. Delphi will recompile user components package and PDF Creator Pilot will be installed on the "ActiveX" components page.

Now you may use PDF Creator Pilot like any other component.

For Microsoft Visual Studio (C++):

Just add these lines to your code:

#import "PDFCreatorPilot.dll"
using namespace PDFCreatorPilotLib;

Now you may use PDF Creator Pilot like any other ActiveX conponent.

For Microsoft Visual Studio (.NET):

Add a reference to PDF Creator Pilot to be able to use pdf library in .NET projects. Select "Project" in main menu and click "Add Reference":

Switch to "COM" tab and find PDF Creator Pilot in the list of available COM objects:

Visual Studio will create Interop wrappers needed for PDF Creator Pilot could be used in your code.

Each session with PDF documents contains the following steps:

1. Your programming language must initialize the PDF Creator Pilot run-time library, as follows.

Delphi :

Just drag a component TPDFDocument4 from your ActiveX panel to a form.
Or manualy create a variable and initialize it:

{ Select menu Project -> Import Type Library
  Find "PDFCreatorPilot Type Library (Version 1.0)".
  Import this type library.
  Add PDFCreatorPilotLib_TLB in the "uses" section.
  Add line:
    PDF: TPDFDocument4;
  in the "var" section.
}

uses
  PDFCreatorPilotLib_TLB, ...

{...}

var
  PDF: TPDFDocument4;
{...}

procedure TForm1.Button1Click(Sender: TObject);
begin
  PDF := TPDFDocument4.Create(nil);
  {...}
end;

Visual Basic or Visual Basic Script :

Set PDF = CreateObject("PDFCreatorPilot.PDFDocument4")

C/C++ :

IPDFDocument4* PDF = NULL;
CLSID clsid;

HRESULT hr = CLSIDFromProgID(OLESTR("PDFCreatorPilot.PDFDocument4"), &clsid);
if(hr != S_OK)
{
    // can't load. no such COM installed.
    return;
}

hr = CoCreateInstance(clsid, 0, CLSCTX_ALL, __uuidof(IPDFDocument4), (LPVOID *)&PDF);
if(hr != S_OK)
{
    // can't load. no such COM installed.
    return;
}

C# :

/*
PDFCreatorPilot must be added to project as reference
(in the COM tab page).
*/

PDFCreatorPilotLib.PDFDocument4Class PDF = new PDFCreatorPilotLib.PDFDocument4Class();

/* Starting from .Net v. 4.0 you can't use interop classes
   so use interface PDFCreatorPilotLib.PDFDocument4 instead of class PDFCreatorPilotLib.PDFDocument4Class:

PDFCreatorPilotLib.PDFDocument4 PDF = new PDFCreatorPilotLib.PDFDocument4();
*/

This step makes the run-time library active and creates a new object: PDF document.

2. You must start the PDF engine using the SetLicenseData method and optional correct license parameters, if you have one.

Delphi :

PDF.SetLicenseData('demo@demo', 'demo');

Visual Basic or Visual Basic Script :

PDF.SetLicenseData "demo@demo", "demo"

C/C++ :

PDF->SetLicenseData("demo@demo", "demo");

C# :

PDF.SetLicenseData("demo@demo", "demo");

3. The next step is to set up PDF document parameters, like title, and so forth.

Delphi :

PDF.SetTitle('PDF Creator Pilot Demo', fcANSI);
PDF.ProducePDFA := false;
PDF.Compression := coFlate;

Visual Basic or Visual Basic Script :

PDF.SetTitle "PDF Creator Pilot Demo", 1 'FontCharset.fcANSI
PDF.ProducePDFA = False
PDF.Compression = 1 'coFlate

C/C++ :

PDF->SetTitle("PDF Creator Pilot Demo", fcANSI);
PDF->ProducePDFA = false;
PDF->Compression = coFlate;

C# :

PDF.SetTitle("PDF Creator Pilot Demo", FontCharset.fcANSI);
PDF.ProducePDFA = false;
PDF.Compression = CompressionType.coFlate;

See descriptions of the following "document-dependent" methods: TitleComphression, ProducePDFA.

4. Complete the action you want in the PDF workplace: write text, draw objects, create new pages. See all method groups for a full description of IPDFDocument4.

5. Finalize your work with SaveToFile or GetBuffer methods.

Delphi :

PDF.SaveToFile('test.pdf', dfalse);

Visual Basic or Visual Basic Script :

PDF.SaveToFile "test.pdf", false

C/C++ :

PDF->SaveToFile("test.pdf", false);

C# :

PDF.SaveToFile("test.pdf", false);

See Also

Reference