www.gnostice.com 

 

FAQ

Top  Previous 

Frequently Asked Questions

 

Find answers to frequently asked technical questions about eDocEngine ActiveX/.NET:

 

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

 

2.How do I render a single line of text?

 

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

 

4.How do I insert a table with text in it?

 

5.How do I insert images to the document I'm creating?

 

6.How do I insert shapes to the document I'm creating?

 

7.How do I render a metafile to the documents?

 

8.How do I insert WaterMark to the documents?

 

9.How do I set Header/Footer content?

 

10.How do I add form elements to the documents I'm creating?

 

11.How do I build a Table of Contents page when creating an HTML document?

 

12.How do I add bookmarks when creating a PDF document?

 

13.How do I place values in specific cells and set the format when creating an Excel document?

 

14.How do I create a document with different page sizes and orientations?

 

15.How do I export RTF files to PDF and other formats?

 

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

 

 

 

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

 

 

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

 

 

 

[VB]

With gtEngineX1

.FileName = ".\BlankDoc"

.PagePaperSize = 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 render any number of pages using NewPage method

.EndDoc

End With

 

 

 

[VC++]

m_Engine.SetFileName("BlankDoc");

m_Engine.SetPagePaperSize(A4);

/*Set any other document properties as required */

m_Engine.BeginDoc();

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

m_Engine.NewPage();

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

/*Similarly render any number of pages using NewPage method*/

m_Engine.EndDoc();

 

[C#]

       gtEngineX1.FileName = @".\BlankDoc";

       gtEngineX1.PagePaperSize = eDocEngineX.TxgtPaperSize.A4;

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

       gtEngineX1.BeginDoc();

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

       gtEngineX1.NewPage();

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

       //Similarly render any number of pages using NewPage method

       gtEngineX1.EndDoc();

 

 

 

top of the page hyperlink

 

 

 

 

2.  How do I render a single line of text?

 

[VB]

With gtEngineX1

.BeginDoc

'... Set any text properties as required

.TextOutXY 3, 4, "This is a sample line of text"

'... Change settings if necessary

.TextOutXY 0, 0, "This is another sample"

.EndDoc

End With

 

 

 

[VC++]

m_Engine.BeginDoc();

/*... Set any text properties as required*//

m_Engine.TextOutXY(3, 4, "This is a sample line of text");

/*... Change settings if necessary*/

m_Engine.TextOutXY 0, 0, "This is another sample"

m_Engine.EndDoc();

 

[C#]

 

       gtEngineX1.FileName = @".\BlankDoc";

       gtEngineX1.BeginDoc();

       //... Set any text properties as required

       gtEngineX1.TextOutXY( 3, 4, "This is a sample line of text");

       //... Change settings if necessary

       gtEngineX1.TextOutXY( 0, 0, "This is another sample");

       gtEngineX1.EndDoc();

 

 

top of the page hyperlink

 

 

 

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

 

 

 

[VB]

Dim str As String

str  = "Gnostice eDocEngine is a comprehensive, generic, electronic" _

& "document creation component suite for Borland® Delphi™" _

& " and Borland® C++Builder™. eDocEngine enables developers to deliver" _

& " information straight from the applications they develop in over 20" _

& " popular electronic document formats, including PDF, HTML, RTF, TIFF," _

& "XML graphics and many more."

With gtEngineX1

.BeginDoc

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

.TextFormatting.BeforeSpace = 1.5

.TextFormatting.Alignment = haJustify

.BeginPara

.TextOut (str)

.EndPara

.EndDoc

End With

 

 

 

[VC++]

  CString str = "Gnostice eDocEngine is a comprehensive, generic, electronic";

str += "document creation component suite for Borland® Delphi";

str += " and Borland® C++Builder. eDocEngine enables developers to deliver";

str += " information straight from the applications they develop in over 20";

str += " popular electronic document formats, including PDF, HTML, RTF, TIFF,";

str += "XML graphics and many more.";

m_Engine.BeginDoc();   

CgtTextFormattingX txtFormat;

txtFormat = m_Engine.GetTextFormatting();

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

txtFormat.SetAlignment(haCenter);

txtFormat.SetBeforeSpace(1.5);

m_Engine.BeginPara();

  m_Engine.TextOut(str);

m_Engine.EndPara();

m_Engine.EndDoc();

 

[C#]

       string str;

       str  = "Gnostice eDocEngine is a comprehensive, generic, electronic" +

                       "document creation component suite for Borland® Delphi™" +

                       " and Borland® C++Builder™. eDocEngine enables developers to deliver" +

                       " information straight from the applications they develop in over 20" +

                       " popular electronic document formats, including PDF, HTML, RTF, TIFF," +

                       "XML graphics and many more.";

       gtEngineX1.BeginDoc();

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

       gtEngineX1.TextFormatting.BeforeSpace = 1.5;

       gtEngineX1.TextFormatting.Alignment = eDocEngineX.TxgtHAlignment.haJustify;

       gtEngineX1.BeginPara();

       gtEngineX1.TextOut (str);

       gtEngineX1.EndPara();

       gtEngineX1.EndDoc();

 

 

top of the page hyperlink

 

 

 

4.  How do I insert a table with text in it?

 

 

 

[VB]

Dim LColumns As gtColumListX

With gtEngineX1

.BeginDoc

'Settings For Image to be inserted into the table               

.ImageSettings.Transparent = True

.PenStyle = psSolid

.PenWidth = 2

.PenColor = RGB(0, 0, 255)

.BrushColor = RGB(0, 255, 255)

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

With .TableSettings

.RowHeight = 0.75

.AutoAdjustColumnWidth = False

.ColumnWidth = 1.5

.EnableTitle = True

.TitleHeight = 0.5

.SetInternalMargin 0.1, 0.1, 0.1, 0.1

End With

.Font.Bold = True

.Font.Size = 10

'Drawing a table of 5 columns at x=0.25, y=1 units

Set LColumns = .BeginTable(0.25, 1, 5) 'Returns a list of gtColumnListX to which you can set specific column properties          

LColumns.Columns(0).Title = "First Column"

LColumns.Columns(1).Title = "Second Column"

LColumns.Columns(2).Title = "Third Column"

LColumns.Columns(3).Title = "Fourth Column"

LColumns.Columns(4).Title = "Fifth Column"

.Font.Bold = False

.Font.Size = 8

For j = 0 To 2

.NewRow

For i = 0 To 4

If (i = 1) Then

'Inserting Image in the second Row of the table

.DrawImageC i, 130, 70, Image1.Picture.Handle, itBMP

Else

.TextColor = RGB(0, 0, 0)

.TextOutC i, "Row No. " & (j + 1) & Chr(10) & Chr(13) & " " + "Column No. " & (i + 1)

End If

Next

Next

.EndTable

.EndDoc

End With

 

 

 

[VC++]

CgtImageSettingsX imgSettings = m_Engine.GetImageSettings();

CString str1;

COleFont f = m_Engine.GetFont();                

CY fontSize = m_Engine.GetFont().GetSize();                

CgtTableSettingsX tblSettings;

tblSettings = m_Engine.GetTableSettings();

tblSettings.SetColumnWidth(1.5);

tblSettings.SetRowHeight(0.75);

tblSettings.SetEnableTitle(true);

tblSettings.SetTitleHeight(0.5);

tblSettings.SetInternalMargin(0.1,0.1,0.1,0.1);

m_Engine.BeginDoc();

m_Engine.BeginPara();

m_Engine.TextOut("Table Support");

m_Engine.EndPara();

imgSettings.SetTransparent(true);

m_Engine.SetPenStyle(psSolid);

m_Engine.SetPenWidth(2);

m_Engine.SetPenColor(RGB(0, 0, 255));

m_Engine.SetBrushColor(RGB(255, 255, 255));

f.SetBold(true);

fontSize.int64 = 100000;

f.SetSize(fontSize);

             /*Drawing a table of 5 columns at x=0.25, y=1 units*/

               CgtColumnListX columns;

               columns = m_Engine.BeginTable(0.25,1,5);

               m_Engine.SetTextColor(RGB(0,0,0));

               columns.GetColumns(0).SetTitle("First Column");

               columns.GetColumns(1).SetTitle("Second Column");

               columns.GetColumns(2).SetTitle("Third Column");

               columns.GetColumns(3).SetTitle("Fourth Column");

               columns.GetColumns(4).SetTitle("Fifth Column");

               f.SetBold(false);

               fontSize.int64 = 80000;

               f.SetSize(fontSize);

               for (int j = 0; j<=2 ; j++)

               {

                       m_Engine.NewRow();

                       

                       for (int i=0; i<=4; i++)

                       {

                        /* Inserting Image in the second Row of the table */

                        /* m_CImage is of Microsoft Forms 2.0 Image Type */

                           if (i == 1)

                    m_Engine.DrawImageC(i, 130, 70, m_CImage.GetPicture().GetHandle(),itBMP);

                       str1 = "RowNo ";

                       str1.Insert(str1.GetLength(), (j+49));

                       str1.Insert(str1.GetLength(), " ColumnNo ");

                       str1.Insert(str1.GetLength(), (i+49));

                       m_Engine.TextOutC(i,str1);

                       }

               }                

               m_Engine.EndTable();

               m_Engine.EndDoc();

 

[C#]

 

       gtEngineX1.FileName = "Sample";

gtEngineX1.BeginDoc();

// Set the pen width and color. 

gtEngineX1.PenWidth = 1; 

gtEngineX1.PenColor = System.Drawing.Color.Red;

// Modify table settings 

gtEngineX1.TableSettings.RowHeight = 0.5 ;

gtEngineX1.TableSettings.AutoAdjustColumnWidth = false;

gtEngineX1.TableSettings.ColumnWidth = 1; 

gtEngineX1.TableSettings.EnableTitle = true ;

gtEngineX1.TableSettings.TitleHeight = 0.2 ;

gtEngineX1.TableSettings.SetInternalMargin( 0.05, 0.05, 0, 0 );

// Begin table creation process 

eDocEngineX.gtColumnListX  LColumns;

LColumns = gtEngineX1.BeginTable(1, 1, 5);

// Array of column titles 

string[] sColTitles;

sColTitles = new string[5];

sColTitles[0] = "First" ;

sColTitles[1] = "Second"; 

sColTitles[2] = "Third" ; 

sColTitles[3] = "Fourth" ;

sColTitles[4] = "Fifth"  ;

// Set each columns title and alignment 

eDocEngineX.gtColumnX  Col;

for(int K = 0 ; K < LColumns.Count - 1 ; K++)

{

       Col = LColumns.get_Columns(K); 

       Col.Title = sColTitles[K]; 

       Col.Alignment = eDocEngineX.TxgtHAlignment.haCenter; 

}

// Create rows and insert text and graphics into the table. 

gtEngineX1.TextColor = System.Drawing.Color.Red;

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

{

       gtEngineX1.NewRow(); 

       for(int i = 0;i < 4; i++)

       {

               if (i == 1)

               {

                       Bitmap bm= new Bitmap(pictureBox1.Image); 

                       gtEngineX1.DrawImageC ( i, 3, 1.3,bm.GetHbitmap().ToInt32() ,eDocEngineX.TxgtImageType.itBMP );                        

               }

               else

                       gtEngineX1.TextOutC( i, "(" + (J + 1) + "," + (i + 1) + ")" );

       }

}

gtEngineX1.EndTable(); 

gtEngineX1.EndDoc(); 

 

 

 

top of the page hyperlink

 

 

 

 

5. How do I insert images to the document I'm creating?

 

 

 

[VB]

With gtEngineX1

   //... Set Any image properties through ImageSettings Property

   .BeginDoc

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

  .DrawImageXY 1, 2, Image1.Picture.Handle, itBMP

  //Insert image within a specified rectangle

  .DrawImageR 2, 2, 6, 3, Image1.Picture.Handle, itBMP

  .EndDoc

End With

 

 

 

AddImageAsResource

 

 

 

Dim I As Long

With gtEngineX1

   .BeginDoc

   I = .AddImageAsResource(Image1.Picture.Handle, itBMP)

   //... Set Any image properties As required

   //Draw image once

   .DrawImageRI 1, 1, 4, 4, I

   .NewPage

   //Draw image again

   .DrawImageRI 1, 1, 4, 4, I

   .EndDoc

End With

 

 

 

[VC++]

m_Engine.BeginDoc();

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

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

m_Engine.DrawImageXY(1, 2, m_Cimage1.GetPicture().GetHandle(), itBMP);

//Insert image within a specified rectangle

m_Engine.DrawImageR(2.52.555, m_CImage2.GetPicture().GetHandle(),

                        itBMP);

m_Engine.EndDoc();

 

 

 

AddImageAsResource

 

 

 

Long I;

m_Engine.BeginDoc();

I = m_Engine.AddImageAsResource(m_Cimage1.GetPicture().GetHandle(), itBMP);

//... set any image properties as required

//Draw image once

m_Engine.DrawImageRI(2, 2, 6, 3,I);

m_Engine.NewPage();

//Draw image again

m_Engine.DrawImageRI(2, 2, 6, 3,I);

m_Engine.EndDoc();

 

 

        [C#]

 

//... Set Any image properties through ImageSettings Property 

gtEngineX1.BeginDoc();  

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

Bitmap bm= new Bitmap(pictureBox1.Image);

gtEngineX1.DrawImageXY(1,2,bm.GetHbitmap().ToInt32(),eDocEngineX.TxgtImageType.itBMP );

 

//Insert image within a specified rectangle

gtEngineX1.DrawImageR( 2, 2, 6, 3, bm.GetHbitmap().ToInt32(),eDocEngineX.TxgtImageType.itBMP );

gtEngineX1.EndDoc();

 

AddImageAsResource

 

int I;

gtEngineX1.BeginDoc();

Bitmap bm= new Bitmap(pictureBox1.Image);

I = gtEngineX1.AddImageAsResource(bm.GetHbitmap().ToInt32() , eDocEngineX.TxgtImageType.itBMP);

 

//... Set Any image properties As required 

 

//Draw image once 

gtEngineX1.DrawImageRI( 1, 1, 4, 4, I );

gtEngineX1.NewPage(); 

//Draw image again 

gtEngineX1.DrawImageRI( 1, 1, 4, 4, I ); 

gtEngineX1.EndDoc(); 

 

 

 

top of the page hyperlink

 

 

 

 

6.  How do I insert shapes to the document I'm creating?

 

[VB]

With gtEngineX1

         .FileName = "C:\Shapes"

         .MeasurementUnit = muInches

         .PagePaperSize = A4

         .PageLeftMargin = 0.5

         .PageRightMargin = 0.5

         .PageBottomMargin = 0.5

         .PageTopMargin = 0.5

         '... Set any other document properties as required

         .BeginDoc

         .PenColor = RGB(0, 0, 0)

         .BrushColor = RGB(180, 180, 180)

         '... 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

         .PenStyle = psDashDot

         .BrushStyle = bsFDiagonal

         .BrushColor = RGB(0, 255, 0)

         .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

         .PenColor = RGB(0, 0, 255)

         .BrushColor = RGB(180, 180, 180)

         .LineA 0.5, 5.5, 1.75, 7.7

         .Rectangle 2, 5.5, 6, 7.8, True

         .EndDoc

 

End With

 

 

 

[VC++]

m_Engine.SetFileName("C:\\Shapes");

m_Engine.SetMeasurementUnit(muInches);

m_Engine.SetPagePaperSize(A4);

m_Engine.SetPageLeftMargin(0.5);

m_Engine.SetPageRightMargin(0.5);

m_Engine.SetPageBottomMargin(0.5);

m_Engine.SetPageTopMargin(0.5);

/*Set any other property as per the requirements*/

m_Engine.BeginDoc();

m_Engine.SetPenColor(RGB(0, 0, 0));

m_Engine.SetBrushColor(RGB(180, 180, 180));

m_Engine.Ellipse(1.5, 2.5, 4, 3.5, false);

m_Engine.SetPenStyle(psDashDot);

m_Engine.SetBrushStyle(bsFDiagonal);

m_Engine.SetBrushColor(RGB(0, 255, 0));

m_Engine.RoundRect(6.3, 5.6, 7.3, 7.5, 0.25, 0.15, true);

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

m_Engine.Chord(0.2, 4, 3, 5, 2.3, 3, 4.3, 5, true);

m_Engine.Pie(4.2, 4, 5, 5, 3, 3, 4.5, 5.2, false);

m_Engine.SetPenColor(RGB(0, 0, 255));

m_Engine.SetBrushColor(RGB(180, 180, 180));

m_Engine.LineA(0.5, 5.5, 1.75, 7.7);

m_Engine.Rectangle(2, 5.5, 6, 7.8, true);

m_Engines.EndDoc();

 

 

[C#]

 

       gtEngineX1.FileName = @"C:\Shapes";

       gtEngineX1.MeasurementUnit = eDocEngineX.TxgtUnitType.muInches;

       gtEngineX1.PagePaperSize = eDocEngineX.TxgtPaperSize.A4;

       gtEngineX1.PageLeftMargin = 0.5;

       gtEngineX1.PageRightMargin = 0.5;

       gtEngineX1.PageBottomMargin = 0.5;

       gtEngineX1.PageTopMargin = 0.5;

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

       gtEngineX1.BeginDoc();

       gtEngineX1.PenColor = System.Drawing.Color.Red ;

       gtEngineX1.BrushColor = System.Drawing.Color.Purple;

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

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

       //the current brush

       gtEngineX1.Ellipse( 1.5, 2.5, 4, 3.5, false);

       gtEngineX1.PenStyle = eDocEngineX.TxgtPenStyle.psDashDot;

       gtEngineX1.BrushStyle = eDocEngineX.TxgtBrushStyle.bsFDiagonal;

       gtEngineX1.BrushColor = System.Drawing.Color.Pink;

       gtEngineX1.RoundRect( 6.3, 5.6, 7.3, 7.5, 0.25, 0.15, true );

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

       gtEngineX1.Chord( 0.2, 4, 3, 5, 2.3, 3, 4.3, 5, true );

       gtEngineX1.Pie( 4.2, 4, 5, 5, 3, 3, 4.5, 5.2, false );

       gtEngineX1.PenColor = System.Drawing.Color.Red ; 

       gtEngineX1.BrushColor = System.Drawing.Color.Blue ; 

       gtEngineX1.LineA( 0.5, 5.5, 1.75, 7.7 );

       gtEngineX1.Rectangle( 2, 5.5, 6, 7.8, true );

       gtEngineX1.EndDoc();

 

 

top of the page hyperlink

 

 

 

7.  How do I render a metafile to the documents?

 

[VB]

With gtEngineX1

.FileName = "C:\\Metafile"

.BeginDoc

.PlayMetafile Image1.Picture.Handle

.EndDoc               

End With

 

 

 

[VC++]

m_Engine.SetFileName("C:\\Metafile");

m_Engine.BeginDoc();

m_Engine.PlayMetafile(m_CImage1.GetPicture().GetHandle());

m_Engine.EndDoc();

 

 

[C#]

gtEngineX1.FileName = "C:\\Metafile";

gtEngineX1.BeginDoc(); 

FileStream filStream = new FileStream("..\\..\\Metafile.emf", System.IO.FileMode.Open);

filStream.Position = 0;

int BufSize = (int)filStream.Length;

byte[] imgBuffer = new byte[BufSize];

filStream.Read(imgBuffer, 0, BufSize);

long BufAddr = Marshal.UnsafeAddrOfPinnedArrayElement(imgBuffer, 0).ToInt64();

gtEngineX1.PlayMetafileMem((int)BufAddr , BufSize);

gtEngineX1.EndDoc();                 

 

 

top of the page hyperlink

 

 

 

8.  How do I insert WaterMark to the documents?

 

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