Example of importing a table and theme from a serialized representation.
#ifndef _MSC_VER
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
#define FROM_JSON 0
void
create_table_ex41(HPDF_Doc pdf_doc, HPDF_Page pdf_page) {
#if FROM_JSON == 0
fprintf(stderr,
"Loaded %s\n",
mkfullpath(
"tut_ex41.json"));
fprintf(stderr,
"Loaded %s\n",
mkfullpath(
"tut41_theme.json"));
} else {
fprintf(stderr,
"Failed to load: %s\n",
mkfullpath(
"tut41_theme.json"));
exit(1);
}
} else {
fprintf(stderr,
"Failed to load: %s\n",
mkfullpath(
"tut_ex41.json"));
exit(1);
}
#else
const size_t num_rows = 4;
const size_t num_cols = 2;
HPDF_REAL height = 0;
#endif
}
#ifndef _MSC_VER
#pragma GCC diagnostic pop
#endif
int hpdftbl_set_content(hpdftbl_t t, char **content)
Set the content for the table.
Definition: hpdftbl.c:1048
int hpdftbl_use_labels(hpdftbl_t t, _Bool use)
Enable/Disable the use of cell labels.
Definition: hpdftbl.c:666
int hpdftbl_set_cellspan(hpdftbl_t t, size_t r, size_t c, size_t rowspan, size_t colspan)
Set cell spanning.
Definition: hpdftbl.c:839
int hpdftbl_set_zebra(hpdftbl_t t, _Bool use, int phase)
Definition: hpdftbl.c:556
int hpdftbl_stroke_pos(HPDF_Doc pdf, const HPDF_Page page, hpdftbl_t t)
Stroke the table using the already specified size and position within the table.
Definition: hpdftbl.c:1654
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_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_theme_dump(hpdftbl_theme_t *theme, char *filename)
Serialize the specified theme structure to a named file.
Definition: hpdftbl_dump.c:108
hpdftbl_theme_t * hpdftbl_get_default_theme(void)
Return the default theme.
Definition: hpdftbl_theme.c:259
int hpdftbl_load(hpdftbl_t tbl, char *filename)
Import a table structure from a serialized table on file.
Definition: hpdftbl_load.c:330
int hpdftbl_dump(hpdftbl_t tbl, char *filename)
Serialize a table structure as a JSON file.
Definition: hpdftbl_dump.c:190
int hpdftbl_get_theme(hpdftbl_t tbl, hpdftbl_theme_t *theme)
Extract theme from settings of a specific table.
Definition: hpdftbl_theme.c:218
int hpdftbl_apply_theme(hpdftbl_t t, hpdftbl_theme_t *theme)
Apply a specified theme to a table.
Definition: hpdftbl_theme.c:177
#define TRUE
Boolean truth value.
Definition: hpdftbl.h:47
#define FALSE
Boolean false value.
Definition: hpdftbl.h:52
#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_theme_load(hpdftbl_theme_t *tbl, char *filename)
Read a theme from a previous serialized theme from a named file.
Definition: hpdftbl_load.c:282
Define a set of styles into a table theme.
Definition: hpdftbl.h:635
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 * mkfullpath(char *filename)
Add the full path to the tests directory as prefix to the supplied filename as argument.
Definition: unit_test.inc.h:295
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