www.gnostice.com 

Frequently Asked Questions

Top  Previous  Next

 

 

1.How do I generate a minimal blank document with multiple pages in it?
 
2.What important document properties would I set before starting to render?
 
3.How do I render a single line of text?
 
4.How do I insert a paragraph of text with a single method call and get the text to justify?
 
5.How do I insert a table or grid with text in it?
 
6.How do I insert images to the document I'm creating?
 
7.How do I insert shapes to the document I'm creating?
 
8.How do I render a metafile to PDF?
 
9.How do I insert a watermark?
 
10.How do I use stamping feature?
 
11.How do I set Header/Footer content?
 
12.What do I need to do for eDocEngine to show all messages in my language/How do I localize?
 
13.How do I include form elements to the PDF document I'm creating?
 
14.How do I build a Table of Contents page when creating an HTML document?
 
15.How do I add bookmarks when creating a PDF document?
 
16.How do I place values in specific cells and set the format when creating an Excel document?
 
17.How do I export reports from the reporting tools Preview window?
 
18.How do I export reports programmatically?
 
19.How do I create a PDF document with different page sizes and orientations?
 
20.How do I export RTF file to PDF/HTML and other formats?
 
21.How do I export more than one report to a single document?
 
22.How do I email the generated document?
 
23.How do I export from TMS Grid to different formats?

 

24.  How do I export from DevExpress to different formats?

 

25.  How do I enable multiple export formats to show in the Report Preview?

 

26.  How do I save the PDF I export, to a database?

 

27.  How do I save my ReportBuilder report as .raf file and export it using eDocEngine?

 

28.  How do I use TRichEdit98 in combination with eDocEngine?

 

29.  How do I implement CCITT 3/ CCITT 4 compression techniques on images when creating a PDF?

 

30.  How do I insert custom metadata when creating HTML files from eDocEngine?

 

31.  How do I insert HTML formatted data?

 

32.  Does eDocEngine support right to left languages?

 

33.  How can I scale a metafile to a desired rectangular size?

 

34.  Does eDocEngine support Chinese characters?

 

35.  How do I export WPRichText to PDF/HTML and other formats?

 

36.  How do I export RTF file to PDF/HTML and other formats without using other components?

 

37.  How do I move projects built with Gnostice QuickReport Export to Gnostice eDocEngine?

 

38.  How do I encode different Header/Footer for each page of the document?

 

 

1) How do I generate a minimal blank document with multiple pages in it?

 

The following example uses a TgtPDFEngine component to create a blank PDF document. You can use any other engine component to  achieve the same for another document format.

 

Delphi:

 

procedure TForm1.Button1Click(Sender: TObject);

begin

with gtPDFEngine1 do

begin

   FileName := 'C:\BlankDoc.pdf';

   Page.PaperSize := A4;

   //... Set any other document properties as required

   BeginDoc;

   // 1st Page: Render text, image and other items here

 

   NewPage;

   // 2nd Page: Render text, image and other items here

 

   // Similarly, insert any number of pages by calling the NewPage method

   EndDoc;

end;

end;

 

C++Builder:

 

void __fastcall TForm1::Button1Click(TObject *Sender)

{

gtPDFEngine1->FileName = "C:\\BlankDoc.pdf";

gtPDFEngine1->Page->PaperSize = A4;

//... set any other document properties as required

gtPDFEngine1->BeginDoc();

// 1st Page: Render text, image and other items here

gtPDFEngine1->NewPage();

// 2nd Page: Render text, image and other items here

// Similarly, insert any number of pages by calling the NewPage method

gtPDFEngine1->EndDoc();

}

 

Top

 

2) What important document properties would I set before starting to render?

 

FileName - specifies the document filename

MeasurementUnit - specifies the unit of measurement for subsequent properties and rendering (default is Inches)

Page.PaperSize - size of the paper like A3, A4, or even Custom

Preferences.ShowSetupDialog - Specifies whether the standard or user provided custom Setup dialog be shown for run-time end-user configuration.

       

Top

 

3) How do I render a single line of text?

 

Delphi:

 

procedure TForm1.Button1Click(Sender: TObject);

begin

with gtPDFEngine1 do

begin

   FileName := 'C:\BlankDoc.pdf';

   Page.PaperSize := A4;

   //... Set any other document properties as required

   BeginDoc;

   //... Set any text properties as required

   TextOut(3, 4, 'This is a sample line of text');

   //... Change settings if necessary

   TextOut(3, 6, 'This is another sample');

   EndDoc;

end;

end;

 

C++Builder:

 

void __fastcall TForm1::Button1Click(TObject *Sender)

{

//... set any text properties as required

gtPDFEngine1->BeginDoc();

gtPDFEngine1->TextOut(3, 4, "This is a sample line of text");

 

//... change settings if necessary

 

gtPDFEngine1->TextOut(3, 6, "This is another sample");

gtPDFEngine1->EndDoc();

}

 

Top

 

4) How do I insert a paragraph of text with a single method call and get the text to justify?

 

Delphi:

 

procedure TForm1.Button1Click(Sender: TObject);

begin

with gtPDFEngine1 do

begin

   FileName := 'C:\Paragraph.pdf';

   Page.PaperSize := A4;

   //... Set any other document properties as required

   BeginDoc;

   TextFormatting.BeforeSpace := 1.5;

   TextFormatting.LeftIndent := 3.5;

   TextFormatting.Alignment := haJustify;

   //... Set left indent, right indent and any other text formatting properties

   BeginPara;

   TextOut('This is a paragraph of text rendered using the advanced' +

     ' paragraph rendering feature of Gnostice eDocEngine. You can get the text' +

     ' in the paragraph to align any way you want just by setting the' +

     ' TextFormatting.Alignment property. This paragraph is justified.');

   EndPara;

   EndDoc;

end;

end;

 

 

C++Builder:

 

void __fastcall TForm1::Button1Click(TObject *Sender)

{

gtPDFEngine1->TextFormatting->BeforeSpace = 1.5;

gtPDFEngine1->BeginDoc();

gtPDFEngine1->TextFormatting->Alignment = haJustify;

//... set left indent, right indent and any other text formatting properties

 

gtPDFEngine1->BeginPara();

gtPDFEngine1->TextOut("This is a paragraph of text is rendered using the advanced paragraph rendering feature of Gnostice eDocEngine. You can get the text in the paragraph to align any way you want just by setting the TextFormatting. Alignment property. This paragraph is justified.");

 

gtPDFEngine1->EndPara();

gtPDFEngine1->EndDoc();

}

 

Top

 

5) How do I insert a table or grid with text in it?

 

Delphi:

 

procedure TForm1.Button1Click(Sender: TObject);

var

List1: TList;

I, J: Integer;

begin

with gtPDFEngine1 do

begin

   FileName := 'C:\Table.pdf';

   Page.PaperSize := A4;

   //... Set any other document properties as required

   BeginDoc;

   // Set attributes of the table being drawn using the TableSettings property

   // Drawing a table of 5 columns at x=2, y=2 units

   List1 := BeginTable(2, 2, 5);

   // Returns a list of TgtColumns to which

   //you can set specific column properties

   for J:=0 to 3 do //4 Rows in the table

   begin

     NewRow; // Height of the row can also be specified as parameter.

     for I:=0 to 4 do

     begin

       TextOut(I, DBGrid.Fields[I].AsString);

     end;

   end;

   EndTable;

   EndDoc;

end;

end;

 

C++Builder:

 

TList *List1;

 

// Set attributes of the table being drawn using the TableSettings property

gtPDFEngine->TableSettings->RowHeight = 0.5;

gtPDFEngine->TableSettings->ColumnWidth = 1;

 

// Drawing a table of 5 columns at x=2, y=2 units

List1 = gtPDFEngine->BeginTable(2, 2, 5);     

//Returns a list of TgtColumns to which you can set specific column properties

 

DBGrid1->DataSource->DataSet->First();

for(int J=0; J<=3; J++)            //4 Rows in the table

{

gtPDFEngine->NewRow();    //Height of the row can also be specified as parameter.

for(int I=0; I<=3; I++)

{

gtPDFEngine->TextOut(I, DBGrid1->Fields[I]->AsString);

}

DBGrid1->DataSource->DataSet->Next();

}

gtPDFEngine->EndTable();

 

Top

 

6) How do I insert images to the document I'm creating?

 

Delphi:

 

procedure TForm1.Button1Click(Sender: TObject);

begin

with gtPDFEngine1 do

begin

   FileName := 'C:\Image.pdf';

   Page.PaperSize := A4;

   //... Set any other document properties as required

   BeginDoc;

   //... Set any image properties through ImageSettings property

 

   // Insert image at x=1, y=2 units

   DrawImage(1, 2, Image1.Picture.Graphic);

 

   // Insert image within a specified rectangle

   DrawImage(gtRect(0.5, 0.5, 4, 4), Image2.Picture.Graphic);

   EndDoc;

end;

end;

 

C++Builder:

 

void __fastcall TForm1::Button1Click(TObject *Sender)

{

gtPDFEngine1->BeginDoc();

 

//... set any image properties through ImageSettings property

// Insert image at x=1, y=2 units

gtPDFEngine1->DrawImage(1, 2, Image1->Picture->Graphic);

 

//Insert image within a specified rectangle

gtPDFEngine1->DrawImage(gtRect(0.5, 0.5, 4, 4), Image2->Picture->Graphic);

gtPDFEngine1->EndDoc();

}

 

Images that appear more than once in a document can be inserted as resources and reused to minimize output file size and creation time.

 

Delphi:

 

procedure TForm1.Button1Click(Sender: TObject);

var

I:Integer;

begin

with gtPDFEngine1 do

begin

   FileName := 'C:\ImageResource.pdf';

   Page.PaperSize := A4;

   //... Set any other document properties as required

   BeginDoc;

     I := AddImageAsResource(Image1.Picture.Graphic);

     //... Set any image properties as required

     // Draw image once

     DrawImage(gtRect(0.5, 0.5, 4, 4), I);

     NewPage;

     // Draw image again

     DrawImage(gtRect(2, 2, 6, 6), I);

   EndDoc;

end;

end;

 

C++Builder:

 

void __fastcall TForm1::Button1Click(TObject *Sender)

{

gtPDFEngine1->BeginDoc();

int I = 0;

I = gtPDFEngine1->AddImageAsResource(Image1->Picture->Graphic);

//... set any image properties as required

//Draw image once

gtPDFEngine1->DrawImage(gtRect(0.5, 0.5, 4, 4), I);

gtPDFEngine1->NewPage();

//Draw image again

gtPDFEngine1->DrawImage(gtRect(2, 2, 6, 6), I);

 

gtPDFEngine1->EndDoc();

}

 

Top

 

7) How do I insert shapes to the document I'm creating?

 

Delphi:

 

procedure TForm1.Button1Click(Sender: TObject);

var

LI: Integer;

gtPoints1, gtPoints2, gtPoints3: TgtPoints;

begin

with gtPDFEngine1 do

begin

   FileName := 'C:\Shapes';

   Page.PaperSize := A4;

   Page.LeftMargin := 0.5;

   Page.RightMargin := 0.5;

   Page.BottomMargin := 0.5;

   Page.TopMargin := 0.5;

 

   //... Set any other document properties as required

   BeginDoc;

  Pen.Color := clBlue;

   Brush.Color := clLtGray;

   //... Set/Change Pen and Brush at any point.

   //Last parameter specifies if the shape needs to be filled with

   //the current brush

   Ellipse(1.5, 2.5, 4, 3.5, False);

   Pen.Style := psDashDot;

   Brush.Style := bsFDiagonal;

   Brush.Color := clGreen;

   RoundRect(6.3, 5.6, 7.3, 7.5, 0.25, 0.15, True);

   Arc(4.2, 2.2, 6, 2.6, 4.5, 6, 4, 4);

   Chord(0.2, 4, 3, 5, 2.3, 3, 4.3, 5, True);

   Pie(4.2, 4, 5, 5, 3, 3, 4.5, 5.2, False);

   Pen.Color := clBlue;

   Brush.Color := clLtGray;

   Line(0.5, 5.5, 1.75, 7.7);

   Rectangle(2, 5.5, 6, 7.8, True);

   //gtPoints1, gtPoints2, gtPoints3 are array of TgtPoint

   Polygon([gtPoint(100, 300), gtPoint(200, 600), gtPoint(400, 200), gtPoint(300, 100)], True);

   PolyLine([gtPoint(100, 300), gtPoint(200, 600), gtPoint(400, 200), gtPoint(300, 100)]);

   PolyBezier([gtPoint(100, 300), gtPoint(200, 600), gtPoint(400, 200), gtPoint(300, 100)]);

   EndDoc

end;

end;

C++Builder:

 

gtPDFEngine1->FileName = "C:\\Shapes";

gtPDFEngine1->Page->PaperSize = A4;

gtPDFEngine1->Page->LeftMargin = 0.5;

gtPDFEngine1->Page->RightMargin = 0.5;

gtPDFEngine1->Page->BottomMargin = 0.5;

gtPDFEngine1->Page->TopMatgin = 0.5;

 

//... Set any other document properties as required

gtPDFEngine1->BeginDoc();

gtPDFEngine1->Pen->Color = clBlue;

gtPDFEngine1->Brush->Color = clLtGray;

//... Set/Change Pen and Brush at any point.

//Last parameter specifies if the shape needs to be filled with

//the current brush

gtPDFEngine1->Ellipse(1.5, 2.5, 4, 3.5, False);

gtPDFEngine1->Pen->Style = psDashDot;

gtPDFEngine1->Brush->Style = bsFDiagonal;

gtPDFEngine1->Brush->Color = clGreen;

gtPDFEngine1->RoundRect(0.2, 2.2, 1.3, 4, 0.25, 0.15, True);

gtPDFEngine1->Arc(4.2, 2.2, 6, 2.6, 4.5, 6, 4, 4);

gtPDFEngine1->Chord(0.2, 4, 3, 5, 2.3, 3, 4.3, 5, True);

gtPDFEngine1->Pie(4.2, 4, 5, 5, 3, 3, 4.5, 5.2, False);

gtPDFEngine1->Line(0.5, 5.5, 1.75, 7.7);

gtPDFEngine1->Rectangle(2, 5.5, 6, 7.8, True);

//gtPoints1, gtPoints2, gtPoints3 are array of TgtPoint

gtPDFEngine1->Polygon(gtPoints1, 2, True);

gtPDFEngine1->PolyLine(gtPoints2,2);

gtPDFEngine1->PolyBezier(gtPoints3,2);

gtPDFEngine1->EndDoc();

 

Top

 

8) How do I render a metafile to PDF?

 

Delphi:

 

procedure TForm1.Button1Click(Sender: TObject);

var

LMetafile: TMetafile;

begin

with gtPDFEngine1 do

begin

   FileName := 'C:\Metafile';

   BeginDoc;

   if (gtPDFEngine1.EngineStatus <> esStarted) then Exit;

     LMetafile := TMetafile.Create;

   LMetafile.Assign(Image1.Picture.Graphic);

   PlayMetafile(LMetafile);

   EndDoc;

end;

end;

 

C++Builder:

 

void __fastcall TForm1::Button1Click(TObject *Sender)

{

gtPDFEngine1->FileName = "C:\\Metafile";

gtPDFEngine1->BeginDoc();

if (gtPDFEngine1->EngineStatus == esStarted)

{

   TMetafile *LMetafile = new TMetafile();

   LMetafile->Assign(Image1->Picture->Graphic);

   gtPDFEngine1->PlayMetafile(LMetafile);

   gtPDFEngine1->EndDoc();

   delete LMetafile;

}

}

Top

 

9) How do I insert a watermark?

 

With the following code a watermark is inserted into every page of the created document:

 

Delphi:

 

procedure TForm1.Button1Click(Sender: TObject);

begin

with gtPDFEngine1 do

begin

   FileName := 'Watermark';

   BeginDoc;

   if (gtPDFEngine1.EngineStatus <> esStarted) then Exit;

   BeginWaterMark;

   with Font do

   begin

     Name := 'Verdana';

     Size := 12;

     Color := clBlue;

   end;

   TextFormatting.Alignment := haCenter;

   TextFormatting.BeforeSpace := 2;

   BeginPara;

     TextOut('Gnostice Information Technologies Private Limited');

   EndPara;

   ImageSettings.Stretch := True;

   ImageSettings.KeepAspectRatio := True;

   DrawImage(2.5, 2.5, Image1.Picture.Graphic);

   NewPage;

   NewPage;

   EndWaterMark;

   EndDoc;

end;

end;

 

C++Builder:

 

void __fastcall TForm1::Button1Click(TObject *Sender)

{

gtPDFEngine1->FileName = "Watermark";

gtPDFEngine1->BeginDoc();

if (gtPDFEngine1->EngineStatus == esStarted)

{

   gtPDFEngine1->BeginWaterMark();

   gtPDFEngine1->Font->Name = "Verdana";

   gtPDFEngine1->Font->Size = 6;

   gtPDFEngine1->Pen->Width = 2;

   gtPDFEngine1->TextFormatting->Alignment = haCenter;

   gtPDFEngine1->TextFormatting->BeforeSpace = 2;

   gtPDFEngine1->BeginPara();

   gtPDFEngine1->TextOut("Gnostice Information Technologies Private Limited");

   gtPDFEngine1->EndPara();

   gtPDFEngine1->ImageSettings->Stretch = True;

   gtPDFEngine1->ImageSettings->KeepAspectRatio = True;

   gtPDFEngine1->DrawImage(2.5, 2.5, Image1->Picture->Graphic);

   gtPDFEngine1->EndWaterMark();

   gtPDFEngine1->EndDoc();

}

}

 

Top

 

10) How do I use stamping feature?

 

With the following code usage of stamping feature is demonstrated.

 

Delphi:

 

procedure TForm1.Button1Click(Sender: TObject);

begin

with gtPDFEngine1 do

begin

   FileName := 'Stamping';

   BeginDoc;

   if (gtPDFEngine1.EngineStatus <> esStarted) then Exit;

     BeginStamp;

   with Font do

   begin

     Name := 'Verdana';

     Size := 12;

     Color := clBlue;

   end;

   TextFormatting.Alignment := haCenter;

   TextFormatting.BeforeSpace := 2;

   BeginPara;

   TextOut('Gnostice Information Technologies Private Limited');

   EndPara;

   ImageSettings.Stretch := True;

   ImageSettings.KeepAspectRatio := True;

   DrawImage(2.5, 2.5, Image1.Picture.Graphic);

   EndStamp;

   EndDoc;

end;

end;

 

C++Builder:

 

void __fastcall TForm1::Button1Click(TObject *Sender)

{

gtPDFEngine1->FileName = "Stamping";

gtPDFEngine1->BeginDoc();

if (gtPDFEngine1->EngineStatus == esStarted)

{

   gtPDFEngine1->BeginStamp();

   gtPDFEngine1->Font->Name = "Verdana";

   gtPDFEngine1->Font->Size = 6;

   gtPDFEngine1->Pen->Width = 2;

   gtPDFEngine1->TextFormatting->Alignment = haCenter;

   gtPDFEngine1->TextFormatting->BeforeSpace = 2;

   gtPDFEngine1->BeginPara();

   gtPDFEngine1->TextOut("Gnostice Information Technologies Private Limited");

   gtPDFEngine1->EndPara();

   gtPDFEngine1->ImageSettings->Stretch = True;

   gtPDFEngine1->ImageSettings->KeepAspectRatio = True;

   gtPDFEngine1->DrawImage(2.5, 2.5, Image1->Picture->Graphic);

   gtPDFEngine1->EndStamp();

   gtPDFEngine1->EndDoc();

}

}

 

Top

 

 

11) How do I set Header/Footer content?

 

Delphi:

 

procedure TForm1.Button1Click(Sender: TObject);

begin

with gtPDFEngine1 do

begin

   FileName := 'C:\HeaderFooter';

   Page.BottomMargin := 1;

   Page.HeaderHeight := 1;

   Page.FooterHeight := 1;

   BeginDoc;

   BeginHeader;

   with Font do

   begin

     Name := 'Courier New';

     Size := 10;

     Color := clBlue;

   end;

   TextFormatting.Alignment := haRight;

   BeginPara;

     TextOut('Document Header');

   EndPara;

   ImageSettings.Stretch := True;

   ImageSettings.KeepAspectRatio := True;

   DrawImage(gtRect(0.3, 0.9, 2, 2), Image1.Picture.Graphic);

   EndHeader;

   BeginFooter;

   with Font do

   begin

     Name := 'Verdana';

     Size := 10;

     Color := clRed;

   end;

   TextOut(0.3, 0.9, 'Gnostice Information Technologies Private Limited');

   TextOut(6, 0.9, 'www.gnostice.com'