Use content to set content and labels.
#ifndef _MSC_VER
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#endif
static char *
cb_date(void *tag, size_t r, size_t c) {
static char buf[64];
time_t t = time(NULL);
ctime_r(&t, buf);
return buf;
} else {
return "Wed May 4 19:01:01 2022";
}
}
static char *
cb_content(void *tag, size_t r, size_t c) {
static char buf[32];
#if (defined _WIN32 || defined __WIN32__)
snprintf(buf, sizeof buf, "Content %02i x %02i", r, c);
#else
snprintf(buf, sizeof buf, "Content %02zu x %02zu", r, c);
#endif
return buf;
}
static char *
cb_labels(void *tag, size_t r, size_t c) {
static char buf[32];
#if (defined _WIN32 || defined __WIN32__)
if (0==r && 0==c) {
snprintf(buf, sizeof buf, "Date:");
} else {
snprintf(buf, sizeof buf, "Label %ix%i:", r, c);
}
#else
if (0==r && 0==c) {
snprintf(buf, sizeof buf, "Date:");
} else {
snprintf(buf, sizeof buf, "Label %zux%zu:", r, c);
}
#endif
return buf;
}
#ifndef _MSC_VER
#pragma GCC diagnostic pop
#endif
void
create_table_ex06(HPDF_Doc pdf_doc, HPDF_Page pdf_page) {
const size_t num_rows = 2;
const size_t num_cols = 2;
char *table_title = "tut_ex06: 2x2 table with callbacks";
HPDF_REAL height = 0;
}
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
hpdftbl_t hpdftbl_create_title(size_t rows, size_t cols, char *title)
Create a new table with title top row.
Definition: hpdftbl.c:326
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
#define TRUE
Boolean truth value.
Definition: hpdftbl.h:47
#define FALSE
Boolean false value.
Definition: hpdftbl.h:52
int hpdftbl_set_cell_content_cb(hpdftbl_t t, size_t r, size_t c, hpdftbl_content_callback_t cb)
Set cell content callback.
Definition: hpdftbl_callback.c:107
#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
int hpdftbl_set_label_cb(hpdftbl_t t, hpdftbl_content_callback_t cb)
Set table label callback.
Definition: hpdftbl_callback.c:212
int hpdftbl_set_content_cb(hpdftbl_t t, hpdftbl_content_callback_t cb)
Set table content callback.
Definition: hpdftbl_callback.c:86
Core table handle.
Definition: hpdftbl.h:470
Common functions for all unit-test/examples.
_Bool run_as_unit_test
For the case when we use this example as a unit/integration test we do not want data such as dates,...
Definition: unit_test.inc.h:35
#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