DynaPDF Manual - Page 96
Previous Page 95 Index Next Page 97
Tables
Page 96 of 839
The default color space for all object types is DeviceRGB. Images should normally be inserted in the
native image color space. This can be achieved by setting the flag tfUseImageCS. The flag is inherited
from the table, columns, and rows as usual. See SetFlags() for further information.
The color space for images can be set with SetColor() and SetColorEx(). The color value is only used
for 1 bit images. If an image color is defined and if the image is a 1 bit image then it will be output as
an image mask. In this case, non-zero pixel values are drawn in the defined image color and zero
pixel values produce no output.
If no image color is defined then 1 bit images are drawn as opaque black & white image.
Table Creation
A table can be created with the function CreateTable() in C or C++. All other interfaces contain the
table class CPDFTable or TPDFTable in Delphi which encapsulates the table functions into a native
class object. The class name is dynatable in PHP.
The constructor takes the number of rows which should be allocated, as well as the number of
columns and the default row height.
Since VB 6 does not support parameterized constructors, the function CreateTable() must be
called after creating the class instance.
The number of pre-allocated rows should be large enough to avoid unnecessary memory re-
allocations. Note that this is just the size of the array that holds the rows which will be added later.
An unused row requires 4 or 8 bytes memory (32 or 64 bit).
The constructor does not allocate rows. The first chunk will be allocated when the first row is added.
C/C++ deveopers must delete a table object when no longer needed with DeleteTable(). The
destructor of the class CPDFTable calls this function automatically in other programming languages
when the class instance will be deleted.
In programming languages which use reference counting like PHP or VB 6, it is very important to
delete tables and the associated PDF instance in the right order, especially if a table contains
references of other tables. This is the case when a sub table was inserted into a cell.
Delete first all tables which contain references of other tables and delete finally the sub tables. This
makes sure that the reference count reaches zero when trying to release the class instance.
Tables must also be deleted before the associated PDF instance will be deleted since a table contains
a reference of this PDF instance! These rules must be carefully considered to avoid memory leaks.
Although it is not required to delete tables in the right order in C or C++ or Delphi, it is best practice
to do so.
Previous topic: Table and cell properties, Table color spaces
Next topic: Table Functions, AddColumn, AddRow