The reserved "Cells" identifier can be used to access each cell’s or Row attributes. The Cell is acObjectTypeCell and the Row is acObjectTypeRow.
To access the attributes of cell(Row, Col) of a document or a table, one can use the "Cells[Row, Col]" reference.
To access the attributes from the row, one can use the "Cells[Row]" reference.
Note that cell indices start at 1 and the index 0 is invalid.
Example: To set the background color of cell(3, 2) to red, we can use:
PDF1.ObjectAttribute["Cells[3,2] ", "BackColor"] = 0x00FF0000;
Note that the document itself can be in the form of a table(Excel style spreadsheet), in this case we can access each cell’s attributes through ObjectAttribute. If a table object named Table1 is added to a document, and we want to access the attributes of Table1, we should use:
PDF1.ObjectAttribute["Table1.Cells[3,2] ", "BackColor"] = 0x00FF0000;
Additional to the Common Attributes, these objects have the following attributes:
Attribute Name |
Description |
Type |
Values |
Default Value |
|||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
xPos *Read only |
Horizontal position in Twips. |
Integer |
>= 0 |
0 |
|||||||||||||
Width |
Width of cell in Twips. Changing this property changes the width of the column where the cell is located. |
Integer |
>= 0 |
2248 |
|||||||||||||
Text |
Multiline text contained in cell. |
String |
|
NULL |
|||||||||||||
Font |
Font used to draw cell’s content. |
Font |
If empty, default document font is used |
NULL |
|||||||||||||
TextColor |
Color used to draw text. |
Color |
COLORREF (bbggrr) 000000 to FFFFFF COLORREF (aabbggrr) 00000000 to FFFFFFFF |
000000 (Solid black) |
|||||||||||||
HorzAlign |
Horizontal text alignment. |
enum acHorzAlign |
1: acHorzAlignLeft 2: acHorzAlignCenter 3: acHorzAlignRight 4: acHorzJustify |
1: acHorzAlignLeft |
|||||||||||||
VertAlign |
Vertical text alignment. |
enum acVertAlign |
1: acVertAlignTop 2: acVertAlignCenter 3: acVertAlignBottom |
3: acVertAlignBottom |
|||||||||||||
TextGap |
Gap between text and borders. |
Integer Units are in points or 12th of an inch. |
0: None 1: Thin 2: Medium 3: Thick |
1: Thin |
|||||||||||||
DataType |
Type of data expected in the field object. |
enum acDataType |
0: acDataTypeUnknown 1: acDataTypeText 2: acDataTypeNumerical 3: acDataTypeDate |
0: acDataTypeUnknown |
|||||||||||||
Format |
Mask used to format the data contained in the field. |
Text |
The formats for each DataType are similar to what is provided by Microsoft Excel®. |
NULL |
|||||||||||||
TitleColor |
Color for cell title. |
Color |
COLORREF (bbggrr) 000000 to FFFFFF COLORREF (aabbggrr) 00000000 to FFFFFFFF |
000000 (Solid black) |
|||||||||||||
TitleText |
Cell title. |
String |
|
NULL |
|||||||||||||
TitleFont |
Cell title font. |
Font |
If empty, default document value is used |
NULL |
|||||||||||||
TitlePosition |
Position of cell’s title. |
enum acTitlePosition |
1: acTopLeft 2: acTopCenter 3: acTopRight 4: acBottomLeft 5 : acBottomCenter 6: acBottomRight |
1: acTopLeft |
|||||||||||||
TitleVertical |
Draw cell’s title vertically. |
Boolean |
True/ False |
False |
|||||||||||||
HorzBorders |
Top and bottom cell borders. |
enum acHorzBorders |
0: acHorzBordersNone 1: acHorzBordersTop 2: acHorzBordersBottom 3: acHorzBordersTopBottom |
0: acHorzBordersNone |
|||||||||||||
VertBorders |
Left and right cell borders. |
enum acVertBorders |
0: acVertBordersNone 1: acVertBordersLeft 2: acVertBordersRight 3: acVertBordersLeftRight |
0: acVertBordersNone |
|||||||||||||
BorderColor |
Color for drawing text border. |
Color |
COLORREF (bbggrr) 000000 to FFFFFF COLORREF (aabbggrr) 00000000 to FFFFFFFF |
000000 (Solid black) |
|||||||||||||
BorderWidth |
Width of border around cell. |
Integer. Units are in points or 12th of an inch. |
0: acBorderWidthNone 1: acBorderWidthSimple 2: acBorderWidthDouble 3: acBorderWidthTriple 4: acBorderWidthQuadruple |
0: acBorderWidth None |
|||||||||||||
BackColor |
Background color. |
Color |
COLORREF (bbggrr) 000000 to FFFFFF COLORREF (aabbggrr) 00000000 to FFFFFFFF |
FFFFFFFF (Transparent) |
|||||||||||||
CharSpacing |
Spacing between characters. |
Integer |
10th of a Twip |
0 |
|||||||||||||
WordSpacing |
Spacing between words. |
Integer |
10th of a Twip |
0 |
|||||||||||||
Editable |
Standard PDF attribute that makes the object editable or not in any viewer. |
Boolean |
True / False |
False |
|||||||||||||
Vertical |
Vertical text. |
Boolean |
True / False |
False |
|||||||||||||
xMain |
When multiple cells are grouped together, xMain and yMain contain the main cell of the group. |
Integer |
|
0 |
|||||||||||||
yMain |
When multiple cells are grouped together, xMain and yMain contain the main cell of the group. |
Integer |
|
0 |
|||||||||||||
xSpan |
When multiple cells are grouped together,Xspan contains the number of cells covered by the group. |
Integer |
|
1 |
|||||||||||||
ySpan |
When multiple cells are grouped together,ySpan contains the number of cells covered by the group. |
Integer |
|
1 |
|||||||||||||
MergeOption |
When the cell is grouped with other cells, specifies in which direction the cell is grouped(right, left, top, bottom). |
Integer |
|
0 |
|||||||||||||
Value |
Result of compiling the formula contained in the Text property. |
String |
|
NULL
|
|||||||||||||
Result |
It is the final value that the user sees after applying any formatting. |
String |
|
NULL
|
|||||||||||||
FormattedText |
It is the string contents of the cell that includes formatting information such as Bold or Italic. |
String |
|
NULL |
|||||||||||||
The Formatted Text property allows the user to specify the text that has some sections formatted with a given format style such as: font size, color, bold, italics, underlined, strike-through, etc. The notations mentioned below are used to specify the needed formats:
The text section should be enclosed with tags to specify the formatting. For example: <b>Hello World</b> will make the text "Hello World" to be bold. If a style has an attribute like in the case of font size and font color, we add a colon to the opening tag and append the attribute after it, for example: <fs:1200>Hello World</fs> will set the text "Hello World" to a font size of 12.
|
Attribute Name |
Description |
Type |
Values |
Default Value |
---|---|---|---|---|
CellArray |
Array of cells contained in this row |
Array |
acObjectTypeCell |
NULL |
Height |
Height of row in Twips. |
Integer |
>= 0 |
1584 |
Page *Read only |
Page number on which the row is located. |
Integer |
>= 0 |
|
yPos *Read only |
Vertical position of the row in the page in Twips. |
Integer |
>= 0 |
0 |
Each cell of a table can contain an expression that is evaluated when the document is compiled. An expression always starts with the equal sign =.
The following operators are supported by the PDF Creator interpreter:
Operator |
Description |
---|---|
+ |
Addition. |
- |
Subtraction or unary minus. |
/ |
Division. |
* |
Multiplication. |
& |
String concatenation. |
And |
Logical AND (French speakers can also use Et). |
Or |
Logical OR (French speakers can also use Ou). |
Not |
Logical NOT. |
<> |
Not equal to. |
< |
Less than. |
<= |
Less or equal. |
> |
Greater. |
>= |
Greater or equal. |
The following rules apply when evaluating expressions:
Expressions can contain parentheses to change the order of evaluation
The decimal point can be either represented as "." or ",", 3.4 is the same as 3,4
Strings are surrounded with double-quotes
When DataType is Text: No predefine formatting is applicable.
When Data Type is Numerical, for example, formats for the following input number: 1264341.56234.
Format String |
Output |
---|---|
# |
1264341.56234 |
#,###.00 |
1,264,341.56 |
#,###.0000 |
1,264,341.5623 |
When Data Type is Date:
Symbol |
Meaning |
---|---|
dddd |
Day in Text format (Monday, Tuesday, etc). |
ddd |
Day in short text format (Mon, Tues, Wed, etc). |
dd |
Day in two digit format (08, 09, 10, 11, etc). |
d |
Day in minimum digit format (8, 9, 10, etc). |
mmmm |
Month in Text format (January, February, etc). |
mmm |
Month in short text format (Jan, Feb, etc). |
mm |
Month in two digit format (08, 09, 10, 11, etc). |
m |
Month in minimum digit format (8, 9, 10, etc). |
yyyy |
Year (2007, 2008, etc). |
yy |
Year in short format (07, 08, etc). |
Examples:
Formats for the following input date/time: 03/18/2008 04:39:23 PM
Format String |
Output |
---|---|
ddd mmmm dd yy |
Tuesday March 18 08 |
HH:MM:SS T |
16:39:23 PM |
dddd/mmm/yyyy HH:MM:SS T |
Tuesday/Mar/2008 16:39:23 PM |
Sub Sample() ' Constants for Activation codes Const strLicenseTo As String = "Amyuni PDF Creator Evaluation" Const strActivationCode As String = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC" ' Initializing PDFCreativeX Object Dim pdf As ACPDFCREACTIVEX.PDFCreactiveX = New ACPDFCREACTIVEX.PDFCreactiveX() ' Set license key pdf.SetLicenseKey(strLicenseTo, strActivationCode) ' Set CurrentPage pdf.CurrentPage = 1 ' Create a Table in the current Page pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeTable, "Table1") Dim oTable As ACPDFCREACTIVEX.IacObject = pdf.GetObjectByName("Table1") ' Configuration Table oTable("Left") = 1000 oTable("Top") = 200 oTable("Right") = pdf.ObjectAttribute("Pages[1]", "Width") - 1000 oTable("Bottom") = pdf.ObjectAttribute("Pages[1]", "Length") - 200 oTable("BorderWidth") = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthSimple ' Create rows And columns oTable("Rows") = 10 oTable("Columns") = 5 ' Creates Cell and Row Objects Dim cell As ACPDFCREACTIVEX.IacObject Dim cellsRow As ACPDFCREACTIVEX.IacObject For row = 1 To oTable("Rows") ' selecting the row to give configure the height cellsRow = pdf.GetObjectByName("Table1.Cells[" + row.ToString() + "]") ' This example divides the rows into the size Bottom value Dim intRowHeight As Integer = (oTable("Bottom") - oTable("Top")) / oTable("Rows") cellsRow("Height") = intRowHeight For column = 1 To oTable("Columns") ' Access to the cell objects cell = pdf.GetObjectByName("Table1.Cells[" + row.ToString + "," + column.ToString + "]") cell("Text") = "AT[" + row.ToString + "," + column.ToString + "]" cell("HorzAlign") = ACPDFCREACTIVEX.acHorzAlign.acHorzAlignCenter cell("VertAlign") = ACPDFCREACTIVEX.acVertAlign.acVertAlignCenter cell("BorderColor") = &HFF00FF cell("BorderWidth") = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthTriple cell("DataType") = ACPDFCREACTIVEX.acDataType.acDataTypeText ' Width of cell in TWIPS. Changing this property changes the width of the column where the cell Is located. Dim intColWidth As Integer = (oTable("Right") - oTable("Left")) / oTable("Columns") cell("Width") = intColWidth Next Next ' Save PDF pdf.Save("c:\temp\CreatePDFDocument_resulting.pdf", ACPDFCREACTIVEX.FileSaveOptionConstants.acFileSaveView) End Sub
static void Sample() { // Constants for Activation codes const string strLicenseTo = "Amyuni PDF Creator Evaluation"; const string strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC"; // Initializing PDFCreativeX Object ACPDFCREACTIVEX.PDFCreactiveX pdf = new ACPDFCREACTIVEX.PDFCreactiveX(); // Set license key pdf.SetLicenseKey(strLicenseTo, strActivationCode); // Set CurrentPage pdf.CurrentPage = 1; // Create a Table in the current Page pdf.CreateObject(ACPDFCREACTIVEX.ObjectTypeConstants.acObjectTypeTable, "Table1"); ACPDFCREACTIVEX.IacObject oTable = pdf.GetObjectByName("Table1"); // Configuration Table oTable["Left"] = 1000; oTable["Top"] = 200; oTable["Right"] = pdf.ObjectAttribute["Pages[1]", "Width"] - 1000; oTable["Bottom"] = pdf.ObjectAttribute["Pages[1]", "Length"] - 200; oTable["BorderWidth"] = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthSimple; // Create rows and columns oTable["Rows"] = 10; oTable["Columns"] = 5; // Creates Cell and Row Objects ACPDFCREACTIVEX.IacObject cell; ACPDFCREACTIVEX.IacObject cellsRow; for (int row = 1; row <= (int)oTable["Rows"]; row++) { // selecting the row to give configure the height cellsRow = pdf.GetObjectByName("Table1.Cells[" + row.ToString() + "]"); // This example divides the rows into the size Bottom value int intRowHeight = ((int)(oTable["Bottom"]) - (int)(oTable["Top"])) / (int)oTable["Rows"]; cellsRow["Height"] = intRowHeight; for (int column = 1; column <= (int)oTable["Columns"]; column++) { // Access to the cell objects cell = pdf.GetObjectByName("Table1.Cells[" + row.ToString() + "," + column.ToString() + "]"); cell["Text"] = "AT[" + row.ToString() + "," + column.ToString() + "]"; cell["HorzAlign"] = ACPDFCREACTIVEX.acHorzAlign.acHorzAlignCenter; cell["VertAlign"] = ACPDFCREACTIVEX.acVertAlign.acVertAlignCenter; cell["BorderColor"] = 0xFF00FF; cell["BorderWidth"] = ACPDFCREACTIVEX.acBorderWidth.acBorderWidthDouble; cell["DataType"] = ACPDFCREACTIVEX.acDataType.acDataTypeText; // Width of cell in TWIPS. Changing this property changes the width of the column where the cell is located. int intColWidth = ((int)(oTable["Right"]) - (int)(oTable["Left"])) / (int)oTable["Columns"]; cell["Width"] = intColWidth; } } // Save PDF pdf.Save(@"c:\temp\CreatePDFDocument_resulting.pdf", ACPDFCREACTIVEX.FileSaveOptionConstants.acFileSaveView); }
#include "windows.h" #include "comutil.h" #include <assert.h> #include <iostream> #import "c:\users\amyuni\pdfcreactivex.dll" no_namespace using namespace std; int main() { // Constants for Activation codes bstr_t strLicenseTo = "Amyuni PDF Creator Evaluation"; bstr_t strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC"; // Initialize the COM subsystem CoInitialize(0); // IPDFCreactiveXPtr is a smart pointer type defined in pdfcreactivex.tlh, // the type library header file generated by the #import instruction above IPDFCreactiveXPtr pdf; // Create the PDFCreactiveX instance pdf.CreateInstance(__uuidof(PDFCreactiveX)); // set license key pdf->SetLicenseKey(_bstr_t(strLicenseTo), _bstr_t(strActivationCode)); // Set CurrentPage pdf->CurrentPage = 1; // Create a Table in the current Page pdf->CreateObject(acObjectTypeTable, "Table1"); IacObjectPtr oTable = pdf->GetObjectByName("Table1"); // Configuration Table oTable->Attribute["Left"] = 1000; oTable->Attribute["Top"] = 200; oTable->Attribute["Right"] = pdf->GetObjectAttribute("Pages[1]", "Width"); oTable->Attribute["Bottom"] = pdf->GetObjectAttribute("Pages[1]", "Length"); _variant_t varAttribute; varAttribute.vt = VT_I4; // integers varAttribute.bVal = acBorderWidthSimple; oTable->Attribute["BorderWidth"] = varAttribute; // Create rows and columns oTable->Attribute["Rows"] = 10; oTable->Attribute["Columns"] = 5; // Creates Cell and Row Objects IacObjectPtr cell; IacObjectPtr cellsRow; for (int row = 1; row < (int)oTable->Attribute["Rows"]; row++) { // selecting the row to give configure the height cellsRow = pdf->GetObjectByName("Table1.Cells[" + _bstr_t(_variant_t(row)) + "]"); // This example divides the rows into the size Bottom value int intRowHeight = ((int)(oTable->Attribute["Bottom"]) - (int)(oTable->Attribute["Top"])) / (int)oTable->Attribute["Rows"]; cellsRow->Attribute["Height"] = intRowHeight; for (int column = 1; column < (int)oTable->Attribute["Columns"]; column++) { // Access to the cell objects cell = pdf->GetObjectByName("Table1.Cells[" + _bstr_t(_variant_t(row)) + "," + _bstr_t(_variant_t(column)) + "]"); cell->Attribute["Text"] = "AT[" + _bstr_t(_variant_t(row)) + "," + _bstr_t(_variant_t(column)) + "]"; _variant_t varAttribute1; varAttribute1.vt = VT_I4; // integers varAttribute1.lVal = 2; cell->Attribute["HorzAlign"] = varAttribute1; varAttribute1.lVal = 2; cell->Attribute["VertAlign"] = varAttribute1; varAttribute1.lVal = 0xFF00FF; cell->Attribute["BorderColor"] = varAttribute1; varAttribute1.lVal = 3; cell->Attribute["BorderWidth"] = varAttribute1; varAttribute1.lVal = 1; cell->Attribute["DataType"] = varAttribute1; // Width of cell in TWIPS. Changing this property changes the width of the column where the cell is located. int intColWidth = ((int)(oTable->Attribute["Right"]) - (int)(oTable->Attribute["Left"])) / (int)oTable->Attribute["Columns"]; cell->Attribute["Width"] = intColWidth; } } // Save PDF pdf->Save("c:\\temp\\CreatePDFDocument_resulting.pdf", acFileSaveView); return 0; }
' ObjectType constants Const acObjectTypeArrow = 36 Const acObjectTypeBarcode = 45 Const acObjectTypeCell = 33 Const acObjectTypeCheckBox = 21 Const acObjectTypeEllipse = 4 Const acObjectTypeExcel = 17 Const acObjectTypeField = 6 Const acObjectTypeGraph = 19 Const acObjectTypeHighlight = 23 Const acObjectTypeLine = 1 Const acObjectTypePicture = 7 Const acObjectTypePolygon = 8 Const acObjectTypeRoundFrame = 3 Const acObjectTypeRow = 32 Const acObjectTypeSelection = 24 Const acObjectTypeSignature = 39 Const acObjectTypeStickyNote = 22 Const acObjectTypeTable = 16 Const acObjectTypeText = 5 ' acBorderWidth constants Const acBorderWidthNone = 0 Const acBorderWidthSimple = 1 Const acBorderWidthDouble = 2 Const acBorderWidthTriple = 3 Const acBorderWidthQuadruple = 4 ' acHorzAlign constants Const acHorzAlignLeft = 1 Const acHorzAlignCenter = 2 Const acHorzAlignRight = 3 Const acHorzJustify = 4 ' acVertAlign constants Const acVertAlignTop = 1 Const acVertAlignCenter = 2 Const acVertAlignBottom = 3 ' acDataType constants Const acDataTypeUnkown = 0 Const acDataTypeText = 1 Const acDataTypeNumerical = 2 Const acDataTypeDate = 3 ' FileSave Constants Const acFileSaveAll = 0 Const acFileSaveDefault = -1 Const acFileSaveView = 1 Const acFileSaveDesign = 2 Const acFileSavePDFA_7 = 3 Const acFileSavePDFA = 4 Const acFileSavePDF14 = 5 ' Constants for Activation codes Const strLicenseTo = "Amyuni PDF Creator Evaluation" Const strActivationCode = "07EFCDAB010001004282943F2AF19A88F332D9E781E40460727DF8A42847A1BDE06DB61C71E94E2D90424BF8762385335F9D6884E9FC" ' Initializing PDFCreativeX Object Dim pdf Set pdf = CreateObject("PDFCreactiveX.PDFCreactiveX.6.5") ' Set license key pdf.SetLicenseKey strLicenseTo, strActivationCode ' Set CurrentPage pdf.CurrentPage = 1 ' Create a Table in the current Page pdf.CreateObject acObjectTypeTable, "Table1" ' Define Object Dim oTable Set oTable = pdf.GetObjectByName("Table1") ' Configuration Table oTable("Left") = 1000 oTable("Top") = 200 oTable("Right") = pdf.ObjectAttribute("Pages[1]", "Width") - 1000 oTable("Bottom") = pdf.ObjectAttribute("Pages[1]", "Length") - 200 oTable("BorderWidth") = acBorderWidthSimple ' Create rows And columns oTable("Rows") = 10 oTable("Columns") = 5 ' Creates Cell and Row Objects Dim cell Dim cellsRow For row = 1 To oTable("Rows") ' selecting the row to give configure the height Set cellsRow = pdf.GetObjectByName("Table1.Cells[" & CStr(row) & "]") ' This example divides the rows into the size Bottom value Dim intRowHeight intRowHeight = (oTable("Bottom") - oTable("Top")) / oTable("Rows") cellsRow("Height") = intRowHeight For column = 1 To oTable("Columns") ' Access to the cell objects Set cell = pdf.GetObjectByName("Table1.Cells[" & CStr(row) & "," + CStr(column) & "]") cell("Text") = "AT[" & CStr(row) & "," & column & "]" cell("HorzAlign") = acHorzAlignCenter cell("VertAlign") = acVertAlignCenter cell("BorderColor") = &HFF00FF cell("BorderWidth") = acBorderWidthTriple cell("DataType") = acDataTypeText ' Width of cell in TWIPS. Changing this property changes the width of the column where the cell Is located. Dim intColWidth intColWidth = (oTable("Right") - oTable("Left")) / oTable("Columns") cell("Width") = intColWidth Next Next ' Save PDF pdf.Save "c:\temp\CreatePDFDocument_resulting.pdf", acFileSaveView