# Table From API Module

Module to create tables on a PDF page, based on API definition.

This module describes the functions and structures that allow you to define tables on a PDF page, based on an API definition.

With HOOPS Publish API, a table is defined on three levels: the cell, the row, and the table. Obviously a table contains a set of rows, and a row contains a set of cells. Then the style applied can be defined at cell level, at row level, or at table level.

For this, use the function `A3DPDFTableCellDescCreate()`to create cells. Use the function `A3DPDFTableRowDescCreate()`to create a row, the cells included being specified with `m_ppCells`member. Finally use the function `A3DPDFTableCreateFromDesc()`to create the table, the rows being included with `m_ppRows`member. Then, the table is positioned on the PDF page using the function `A3DPDFPageInsertTable()`.

As an example, a simple table is defined with HOOPS Publish API by creating three rows of three cells each. Two different styles are specified: one for the first (header) row and one for second and third row.

The styles are defined with code such as

    A3DPDFTableStyleDatastylerow0=A3D_MAKE_DATA(A3DPDFTableStyleData);
    outStyle.m_iFontSize=fontSize;
    outStyle.m_pcFontName="Helvetica";
    outStyle.m_eHorizAlignment=kA3DPDFTableAlignHCentered
    outStyle.m_iRowHeight=20;
    outStyle.m_iColumnWidth=70;

The cells are defined with code such as

    std::vector<A3DPDFTableCellDesc*>aCells;
    A3DPDFTableCellDesc*pTableCellDesc;
    A3DPDFTableCellDescDatasTableCellDescData=A3D_MAKE_DATA(A3DPDFTableCellDescData);
    sTableCellDescData.m_pcCellString="Bob";
    A3DPDFTableCellDescCreate(&sTableCellDescData,&pTableCellDesc);
    aCells.push_back(pTableCellDesc);

The rows are defined with code such as

    std::vector<A3DPDFTableRowDesc*>aRows;
    A3DPDFTableRowDesc*pTableRowDesc;
    A3DPDFTableRowDescDatasTableRowDescData=A3D_MAKE_DATA(A3DPDFTableRowDescData);
    sTableRowDescData.m_ppCells=(A3DPDFTableCellDesc**)malloc(aCells.size()*sizeof(A3DPDFTableCellDesc**));
    for(size_ti=0;i<aCells.size();i++)
    sTableRowDescData.m_ppCells[i]=aCells[i];
    sTableRowDescData.m_pStyle=&stylerow0;
    sTableRowDescData.m_iNumberOfCells=static_cast<A3DUns32>(aCells.size());
    A3DPDFTableRowDescCreate(&sTableRowDescData,&pTableRowDesc);
    aRows.push_back(pTableRowDesc);

then the table is defined with:

    A3DPDFTableDescDatasTableDescData=A3D_MAKE_DATA(A3DPDFTableDescData);
    sTableDescData.m_ppRows=(A3DPDFTableRowDesc**)malloc(aRows.size()*A3DUns32(sizeof(A3DPDFTableRowDesc*)));
    sTableDescData.m_iNumberOfRows=static_cast<A3DUns32>(aRows.size());
    for(size_ti=0;i<aRows.size();i++)
    sTableDescData.m_ppRows[i]=aRows[i];
    A3DPDFTableCreateFromDesc(pDoc,&sTableDescData,&pTable);

A code example is provided in the package to demonstrate the creation of a Table with these functions. Please see samples/publishing/DemoFunctionalities.

Parameters

> pCellDescData: The cell description.

> ppCellDesc: The Table cell descriptor created.

Returns

> A3D_SUCCESS in case of success or an error code

Structures

- `A3DPDFTableStyleData`
- `A3DPDFTableCellDescData`
- `A3DPDFTableRowDescData`
- `A3DPDFTableDescData`

Functions

- `A3DPDFTableCellDescCreate()`
- `A3DPDFTableRowDescCreate()`
- `A3DPDFTableCreateFromDesc()`

Conversation saved
HOOPSY BETA

### Hello! I'm HOOPSY

Your multilingual generative AI assistant for documentation. Ask me anything about HOOPS Exchange in your own language, or choose a sample question below to start a conversation:

What is HOOPS Exchange?
What are the latest release notes for HOOPS Exchange?
How do I start evaluating HOOPS Exchange?
How do I write my first sample application?
How can I get assistance?

HOOPSY may store conversations according to OpenAI's policy. Responses may not always be accurate.

HOOPSY is thinking...