|
Using eDocEngine components - Delphi |
Top Previous Next |
|
Here we create an application using eDocEngine component. By using the component's methods, properties and events various supported document output formats can be generated for applications.
In this application we create a PDF document using PDF engine component. This application creates a PDF file named 'Output.pdf'. It set the page size to A4 by using the 'PaperSize' property. In the first page of the PDF document we create the text as 'Welcome to Gnostice eDocEngine' and uses 'NewPage' method to create another blank page.
Follow these steps to create an application:
Step 1. Creating new projects Step 2. Adding eDocEngine component (PDF, RTF etc.) to form Step 3. Add a Button to the form Step 4. Working with eDocEngine component Step 5. Executing the Program Step 6. Viewing Output
Step 1. Creating a new project:
To quickly create a new project, 1. Start Delphi 2. Select File | New | Application from the Delphi menu. This will create a new project and a blank form.
Step 2. Adding the eDocEngine component:
Step 3. Adding the button to the form:
Select 'Standard' tab of the Delphi component palette and add a button to the form. Set button properties as follows:
Name btnName Caption Create PDF Document
Step 4. Working with eDocEngine component:
Place the following code in the Button's 'Click' event for Delphi. This code creates a PDF file named 'Output.pdf'. In the first page of the PDF document we create the text as 'Welcome to Gnostice eDocEngine' and uses 'NewPage' method to create another blank page.
procedure TForm1.Button1Click(Sender: TObject); begin with gtPDFEngine1 do begin FileName := 'Output.pdf'; Page.PaperSize := A4; //... Set any other document properties as required BeginDoc; // 1st Page: Render text, image and other items here // Write 'Welcome to Gnostice eDocEngine' in the output at position(1,1) TextOut(1,1,'Welcome to Gnostice eDocEngine'); NewPage; // 2nd Page: Render text, image and other items here // Similarly, insert any number of pages by calling the NewPage method EndDoc; end; end;
After copying the code in the button's click procedure, execute the program.
Step 5. Executing the Program Run the program. This will display the form with the 'Create PDF Document' button. Click 'Create PDF Document' button to open the PDF Setup Dialog. Set the properties as desired and click 'OK'.
Step 6. Viewing Output This will launch Acrobat Reader and open 'Output.pdf' file.
Similarly, from the component palette drag other eDocEngine components to the form and follow the steps in the tutorial to generate their output formats.
|