libhpdftbl 1.5.0
Table construction library for Haru PDF library
Loading...
Searching...
No Matches
tut_ex20.c

Defining a table and adjusting the gridlines.

#include "unit_test.inc.h"
void
create_table_ex20(HPDF_Doc pdf_doc, HPDF_Page pdf_page) {
const size_t num_rows = 5;
const size_t num_cols = 4;
hpdftbl_t tbl = hpdftbl_create(num_rows, num_cols);
content_t content, labels;
setup_dummy_content_label(&content, &labels, num_rows, num_cols);
hpdftbl_set_content(tbl, content);
hpdftbl_set_labels(tbl, labels);
hpdftbl_set_inner_vgrid_style(tbl, 0.7, HPDF_COLOR_DARK_GRAY, LINE_SOLID);
hpdftbl_set_inner_hgrid_style(tbl, 0.8, HPDF_COLOR_GRAY, LINE_DOT1);
hpdftbl_set_inner_tgrid_style(tbl, 1.5, HPDF_COLOR_BLACK, LINE_SOLID);
hpdftbl_set_outer_grid_style(tbl, 1.5, HPDF_COLOR_BLACK, LINE_SOLID);
HPDF_REAL xpos = hpdftbl_cm2dpi(1);
HPDF_REAL ypos = hpdftbl_cm2dpi(A4PAGE_HEIGHT_CM - 1);
HPDF_REAL width = hpdftbl_cm2dpi(10);
HPDF_REAL height = 0; // Calculate height automatically
// Stroke the table to the page
hpdftbl_stroke(pdf_doc, pdf_page, tbl, xpos, ypos, width, height);
}
TUTEX_MAIN(create_table_ex20, FALSE)
int hpdftbl_set_content(hpdftbl_t t, char **content)
Set the content for the table.
Definition: hpdftbl.c:1048
int hpdftbl_set_outer_grid_style(hpdftbl_t t, HPDF_REAL width, HPDF_RGBColor color, hpdftbl_line_dashstyle_t dashstyle)
Set outer border grid style.
Definition: hpdftbl.c:460
int hpdftbl_use_labelgrid(hpdftbl_t t, _Bool use)
Shorter vertical line to mark labels.
Definition: hpdftbl.c:687
int hpdftbl_use_labels(hpdftbl_t t, _Bool use)
Enable/Disable the use of cell labels.
Definition: hpdftbl.c:666
int hpdftbl_set_inner_tgrid_style(hpdftbl_t t, HPDF_REAL width, HPDF_RGBColor color, hpdftbl_line_dashstyle_t dashstyle)
Set inner horizontal top border grid style.
Definition: hpdftbl.c:540
int hpdftbl_set_labels(hpdftbl_t t, char **labels)
Set the text for the cell labels.
Definition: hpdftbl.c:1010
hpdftbl_t hpdftbl_create(size_t rows, size_t cols)
Create a new table with no title.
Definition: hpdftbl.c:311
int hpdftbl_set_inner_vgrid_style(hpdftbl_t t, HPDF_REAL width, HPDF_RGBColor color, hpdftbl_line_dashstyle_t dashstyle)
Set inner vertical border grid style.
Definition: hpdftbl.c:518
int hpdftbl_stroke(HPDF_Doc pdf, const HPDF_Page page, hpdftbl_t t, const HPDF_REAL xpos, const HPDF_REAL ypos, const HPDF_REAL width, HPDF_REAL height)
Stroke the table.
Definition: hpdftbl.c:1682
int hpdftbl_use_header(hpdftbl_t t, _Bool use)
Enable/disable the interpretation of the top row as a header row.
Definition: hpdftbl.c:646
int hpdftbl_set_inner_hgrid_style(hpdftbl_t t, HPDF_REAL width, HPDF_RGBColor color, hpdftbl_line_dashstyle_t dashstyle)
Set inner horizontal border grid style.
Definition: hpdftbl.c:499
#define TRUE
Boolean truth value.
Definition: hpdftbl.h:47
#define FALSE
Boolean false value.
Definition: hpdftbl.h:52
@ LINE_SOLID
Definition: hpdftbl.h:376
@ LINE_DOT1
Definition: hpdftbl.h:377
#define A4PAGE_HEIGHT_CM
Standard A4 paper height in cm.
Definition: hpdftbl.h:198
#define hpdftbl_cm2dpi(c)
Convert cm to dots using the default resolution (72 DPI)
Definition: hpdftbl.h:256
Core table handle.
Definition: hpdftbl.h:470
Common functions for all unit-test/examples.
void setup_dummy_content_label(content_t *content, content_t *labels, size_t rows, size_t cols)
Create both array of char pointers to simulate real table content as well as an array of simulated la...
Definition: unit_test.inc.h:258
char ** content_t
An array of char pointers.
Definition: unit_test.inc.h:230
#define TUTEX_MAIN(_tbl_, _showgrid_)
Macro to create a main() function to call the table creation function for each example....
Definition: unit_test.inc.h:322