How to Insert a Table into PDF
Creating tables with text formatted using standard HTML tags is straightforward using Foxit Quick PDF Library. After positioning and creating the table, set the default HTML styles for the specific HTML tags to be used for formatting, then the content can added using the SetTableCellContent function.
Some sample Delphi code for creating and formatting a PDF table appears below:
// * Create a PDF table with HTML text formatting */
// Set top-left origin
QP.SetOrigin(1);
// Create table, set default HTML text styles and add content
id = QP.CreateTable(1, 6);
QP.SetHTMLNormalFont("Default", QP.AddTrueTypeFont("Arial", 0));
QP.SetHTMLBoldFont("Default", QP.AddTrueTypeFont("Arial [Bold]", 0));
QP.SetHTMLItalicFont("Default", QP.AddTrueTypeFont("Arial [Italic]", 0));
QP.SetHTMLBoldItalicFont("Default", QP.AddTrueTypeFont("Arial [BoldItalic]", 0));
QP.SetTableColumnWidth(id, 1, 6, 72);
QP.SetTableCellContent(id, 1, 1, "My Text
Normal Text");
QP.DrawTableRows(id, 36, 36, QP.PageHeight() - 72, 1, 0);
// Save the new document to disk
QP.SaveToFile("Table.pdf");
This article refers to a deprecated product. If you are looking for support for Foxit PDF SDK, please click here.
Updated on May 16, 2022