libhpdftbl 1.5.0
Table construction library for Haru PDF library
Loading...
Searching...
No Matches
hpdftbl.h
Go to the documentation of this file.
1
31#include "config.h"
32#ifndef hpdftbl_H
33#define hpdftbl_H
34
35#ifdef __cplusplus
36// in case we have C++ code, we should use its' types and logic
37#include <algorithm>
38typedef std::_Bool _Bool;
39#endif
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45#ifndef TRUE
47#define TRUE 1
48#endif
49
50#ifndef FALSE
52#define FALSE 0
53#endif
54
55#ifndef max
56
60#define max(a,b) (((a)>(b)) ? (a):(b))
61
65#define min(a,b) (((a)<(b)) ? (a):(b))
66#endif
67
69extern int hpdftbl_err_code ;
70
72extern int hpdftbl_err_row ;
73
75extern int hpdftbl_err_col ;
76
78extern int hpdftbl_err_lineno;
79
81extern char *hpdftbl_err_file;
82
84extern char hpdftbl_err_extrainfo[];
85
87#define THEME_JSON_VERSION 1
88
90#define TABLE_JSON_VERSION 1
91
92
94#define HPDF_FF_TIMES "Times-Roman"
96#define HPDF_FF_TIMES_ITALIC "Times-Italic"
98#define HPDF_FF_TIMES_BOLD "Times-Bold"
100#define HPDF_FF_TIMES_BOLDITALIC "Times-BoldItalic"
102#define HPDF_FF_HELVETICA "Helvetica"
104#define HPDF_FF_HELVETICA_ITALIC "Helvetica-Oblique"
106#define HPDF_FF_HELVETICA_BOLD "Helvetica-Bold"
108#define HPDF_FF_HELVETICA_BOLDITALIC "Helvetica-BoldOblique"
110#define HPDF_FF_COURIER "Courier"
112#define HPDF_FF_COURIER_BOLD "Courier-Bold"
114#define HPDF_FF_COURIER_IALIC "Courier-Oblique"
116#define HPDF_FF_COURIER_BOLDITALIC "Courier-BoldOblique"
117
118
119
120#ifdef __cplusplus
124#define _TO_HPDF_RGB(r, g, b) \
125 { r / 255.0f, g / 255.0f, b / 255.0f }
126#else
130#define HPDF_RGB_CONVERT(r, g, b) \
131 (HPDF_RGBColor) { r / 255.0f, g / 255.0f, b / 255.0f }
132#endif
133
134#ifdef __cplusplus
135
136#define HPDF_COLOR_DARK_RED { 0.6f, 0.0f, 0.0f }
137#define HPDF_COLOR_RED { 1.0f, 0.0f, 0.0f }
138#define HPDF_COLOR_LIGHT_GREEN { 0.9f, 1.0f, 0.9f }
139#define HPDF_COLOR_GREEN { 0.4f, 0.9f, 0.4f }
140#define HPDF_COLOR_DARK_GREEN { 0.05f, 0.37f, 0.02f }
141#define HPDF_COLOR_DARK_GRAY { 0.2f, 0.2f, 0.2f }
142#define HPDF_COLOR_LIGHT_GRAY { 0.9f, 0.9f, 0.9f }
143#define HPDF_COLOR_XLIGHT_GRAY { 0.95f, 0.95f, 0.95f }
144#define HPDF_COLOR_GRAY { 0.5f, 0.5f, 0.5f }
145#define HPDF_COLOR_SILVER { 0.75f, 0.75f, 0.75f }
146#define HPDF_COLOR_LIGHT_BLUE { 1.0f, 1.0f, 0.9f }
147#define HPDF_COLOR_BLUE { 0.0f, 0.0f, 1.0f }
148#define HPDF_COLOR_DARK_BLUE { 0.0f, 0.0f, 0.6f }
149#define HPDF_COLOR_WHITE { 1.0f, 1.0f, 1.0f }
150#define HPDF_COLOR_BLACK { 0.0f, 0.0f, 0.0f }
151
152#else
153
154#define HPDF_COLOR_DARK_RED (HPDF_RGBColor) { 0.6f, 0.0f, 0.0f }
155#define HPDF_COLOR_RED (HPDF_RGBColor) { 1.0f, 0.0f, 0.0f }
156#define HPDF_COLOR_LIGHT_GREEN (HPDF_RGBColor) { 0.9f, 1.0f, 0.9f }
157#define HPDF_COLOR_GREEN (HPDF_RGBColor) { 0.4f, 0.9f, 0.4f }
158#define HPDF_COLOR_DARK_GREEN (HPDF_RGBColor) { 0.05f, 0.37f, 0.02f }
159#define HPDF_COLOR_DARK_GRAY (HPDF_RGBColor) { 0.2f, 0.2f, 0.2f }
160#define HPDF_COLOR_LIGHT_GRAY (HPDF_RGBColor) { 0.9f, 0.9f, 0.9f }
161#define HPDF_COLOR_XLIGHT_GRAY (HPDF_RGBColor) { 0.95f, 0.95f, 0.95f }
162#define HPDF_COLOR_GRAY (HPDF_RGBColor) { 0.5f, 0.5f, 0.5f }
163#define HPDF_COLOR_SILVER (HPDF_RGBColor) { 0.75f, 0.75f, 0.75f }
164#define HPDF_COLOR_LIGHT_BLUE (HPDF_RGBColor) { 1.0f, 1.0f, 0.9f }
165#define HPDF_COLOR_BLUE (HPDF_RGBColor) { 0.0f, 0.0f, 1.0f }
166#define HPDF_COLOR_DARK_BLUE (HPDF_RGBColor) { 0.0f, 0.0f, 0.6f }
167#define HPDF_COLOR_WHITE (HPDF_RGBColor) { 1.0f, 1.0f, 1.0f }
168#define HPDF_COLOR_BLACK (HPDF_RGBColor) { 0.0f, 0.0f, 0.0f }
169
170#endif
171
172#define HPDF_COLOR_ORANGE HPDF_RGB_CONVERT(0xF5, 0xD0, 0x98);
173#define HPDF_COLOR_ALMOST_BLACK HPDF_RGB_CONVERT(0x14, 0x14, 0x14);
174
183#define DEFAULT_AUTO_VBOTTOM_MARGIN_FACTOR 0.5
184
188#define HPDFTBL_DEFAULT_TARGET_ENCODING "ISO8859-4"
189
193#define HPDFTBL_DEFAULT_SOURCE_ENCODING "UTF-8"
194
198#define A4PAGE_HEIGHT_CM 29.7
199
203#define A4PAGE_WIDTH_CM 21.0
204
208#define A3PAGE_HEIGHT_CM 42.0
209
213#define A3PAGE_WIDTH_CM 29.7
214
218#define LETTERRPAGE_HEIGHT_CM 27.9
219
223#define LETTERRPAGE_WIDTH_CM 21.6
224
228#define LEGALPAGE_HEIGHT_CM 35.6
229
233#define LEGALPAGE_WIDTH_CM 21.6
234
238#define HPDFTBL_END_CELLSPECS {0, 0, 0, 0, 0, 0, 0, 0, 0}
239
243#define HPDF_COLOR_FROMRGB(r, g, b) (HPDF_RGBColor){(r)/255.0,(g)/255.0,(b)/255.0}
244
248#define HPDFTBL_MIN_CALCULATED_PERCENT_CELL_WIDTH 2.0
249
256#define hpdftbl_cm2dpi(c) (((HPDF_REAL)(c))/2.54*72)
257
265#define _HPDFTBL_SET_ERR(t, err, r, c) do {hpdftbl_err_code=err;hpdftbl_err_row=r;hpdftbl_err_col=c;hpdftbl_err_lineno=__LINE__;hpdftbl_err_file=__FILE__; if(hpdftbl_err_handler){hpdftbl_err_handler(t,r,c,err);}} while(0)
266
273#define _HPDFTBL_SET_ERR_EXTRA(info) do {strncpy(hpdftbl_err_extrainfo,info,1023);hpdftbl_err_extrainfo[1023]=0;} while(0)
274
278#define _HPDFTBL_CHK_TABLE(t) do {if(NULL == t) {hpdftbl_err_code=-3;hpdftbl_err_row=-1;hpdftbl_err_col=-1;return -1;}} while(0)
279
283#define _HPDFTBL_IDX(r, c) (r*t->cols+c)
284
292typedef enum hpdftbl_text_align {
293 LEFT = 0,
294 CENTER = 1,
295 RIGHT = 2
297
303typedef struct text_style {
304 char *font;
305 HPDF_REAL fsize;
306 HPDF_RGBColor color;
307 HPDF_RGBColor background;
310
311
320typedef struct hpdftbl *hpdftbl_t;
321
330typedef char *(*hpdftbl_content_callback_t)(void *, size_t, size_t);
331
341typedef void (*hpdftbl_canvas_callback_t)(HPDF_Doc, HPDF_Page, void *, size_t, size_t, HPDF_REAL, HPDF_REAL, HPDF_REAL,
342 HPDF_REAL);
343
353typedef _Bool (*hpdftbl_content_style_callback_t)(void *, size_t, size_t, char *content, hpdf_text_style_t *);
354
355
366
375typedef enum hpdftbl_dashstyle {
389
395typedef struct grid_style {
396 HPDF_REAL width;
397 HPDF_RGBColor color;
400
410 size_t row;
412 size_t col;
414 char *label;
416 char *content;
418 size_t colspan;
420 size_t rowspan;
422 HPDF_REAL height;
424 HPDF_REAL width;
426 HPDF_REAL delta_x;
428 HPDF_REAL delta_y;
430 HPDF_REAL textwidth;
453};
454
461
470struct hpdftbl {
472 HPDF_Doc pdf_doc;
474 HPDF_Page pdf_page;
476 size_t cols;
478 size_t rows;
480 HPDF_REAL posx;
482 HPDF_REAL posy;
484 HPDF_REAL height;
486 HPDF_REAL minrowheight;
492 HPDF_REAL width;
494 void *tag;
551 HPDF_RGBColor zebra_color1;
553 HPDF_RGBColor zebra_color2;
558};
559
569typedef struct hpdftbl_cell_spec {
571 size_t row;
573 size_t col;
575 unsigned rowspan;
577 unsigned colspan;
579 char *label;
589
596typedef struct hpdftbl_spec {
598 char *title;
606 size_t rows;
608 size_t cols;
610 HPDF_REAL xpos;
612 HPDF_REAL ypos;
614 HPDF_REAL width;
616 HPDF_REAL height;
628
635typedef struct hpdftbl_theme {
663 HPDF_RGBColor zebra_color1;
665 HPDF_RGBColor zebra_color2;
669
677typedef void (*hpdftbl_error_handler_t)(hpdftbl_t, int, int, int);
678
680
681/*
682 * Table creation and destruction function
683 */
685hpdftbl_create(size_t rows, size_t cols);
686
688hpdftbl_create_title(size_t rows, size_t cols, char *title);
689
690int
691hpdftbl_stroke(HPDF_Doc pdf,
692 HPDF_Page page, hpdftbl_t t,
693 HPDF_REAL xpos, HPDF_REAL ypos,
694 HPDF_REAL width, HPDF_REAL height);
695
696int
697hpdftbl_stroke_pos(HPDF_Doc pdf,
698 const HPDF_Page page, hpdftbl_t t);
699
700int
701hpdftbl_stroke_from_data(HPDF_Doc pdf_doc, HPDF_Page pdf_page, hpdftbl_spec_t *tbl_spec, hpdftbl_theme_t *theme);
702
703int
705 const HPDF_REAL xpos, const HPDF_REAL ypos,
706 const HPDF_REAL width, HPDF_REAL height);
707
708int
710
711int
712hpdftbl_get_last_auto_height(HPDF_REAL *height);
713
714void
715hpdftbl_set_anchor_top_left(hpdftbl_t tbl, _Bool anchor);
716
717_Bool
719
720/*
721 * Table error handling functions
722 */
725
726const char *
727hpdftbl_get_errstr(int err);
728
729const char *
730hpdftbl_hpdf_get_errstr(HPDF_STATUS err_code);
731
732int
733hpdftbl_get_last_errcode(const char **errstr, int *row, int *col);
734
735void
736hpdftbl_get_last_err_file(int *lineno, char **file, char **extrainfo);
737
738void
739hpdftbl_default_table_error_handler(hpdftbl_t t, int r, int c, int err);
740
741/*
742 * Theme handling functions
743 */
744int
746
749
750int
752
753int
755
756/*
757 * Table layout adjusting functions
758 */
759
760void
762
763int
765
766int
767hpdftbl_set_colwidth_percent(hpdftbl_t t, size_t c, float w);
768
769int
771
772int
773hpdftbl_set_cellspan(hpdftbl_t t, size_t r, size_t c, size_t rowspan, size_t colspan);
774
775/*
776 * Table style handling functions
777 */
778int
779hpdftbl_set_zebra(hpdftbl_t t, _Bool use, int phase);
780
781int
782hpdftbl_set_zebra_color(hpdftbl_t t, HPDF_RGBColor z1, HPDF_RGBColor z2);
783
784int
785hpdftbl_use_labels(hpdftbl_t t, _Bool use);
786
787int
788hpdftbl_use_labelgrid(hpdftbl_t t, _Bool use);
789
790int
791hpdftbl_set_background(hpdftbl_t t, HPDF_RGBColor background);
792
793int
794hpdftbl_set_inner_tgrid_style(hpdftbl_t t, HPDF_REAL width, HPDF_RGBColor color, hpdftbl_line_dashstyle_t dashstyle);
795
796int
797hpdftbl_set_inner_vgrid_style(hpdftbl_t t, HPDF_REAL width, HPDF_RGBColor color, hpdftbl_line_dashstyle_t dashstyle);
798
799int
800hpdftbl_set_inner_hgrid_style(hpdftbl_t t, HPDF_REAL width, HPDF_RGBColor color, hpdftbl_line_dashstyle_t dashstyle);
801
802int
803hpdftbl_set_inner_grid_style(hpdftbl_t t, HPDF_REAL width, HPDF_RGBColor color, hpdftbl_line_dashstyle_t dashstyle);
804
805int
806hpdftbl_set_outer_grid_style(hpdftbl_t t, HPDF_REAL width, HPDF_RGBColor color, hpdftbl_line_dashstyle_t dashstyle);
807
808int
809hpdftbl_set_header_style(hpdftbl_t t, char *font, HPDF_REAL fsize, HPDF_RGBColor color, HPDF_RGBColor background);
810
811int
813
814int
815hpdftbl_use_header(hpdftbl_t t, _Bool use);
816
817int
818hpdftbl_set_label_style(hpdftbl_t t, char *font, HPDF_REAL fsize, HPDF_RGBColor color, HPDF_RGBColor background);
819
820int
821hpdftbl_set_row_content_style(hpdftbl_t t, size_t r, char *font, HPDF_REAL fsize, HPDF_RGBColor color,
822 HPDF_RGBColor background);
823
824int
825hpdftbl_set_col_content_style(hpdftbl_t t, size_t c, char *font, HPDF_REAL fsize, HPDF_RGBColor color,
826 HPDF_RGBColor background);
827
828int
829hpdftbl_set_content_style(hpdftbl_t t, char *font, HPDF_REAL fsize, HPDF_RGBColor color, HPDF_RGBColor background);
830
831int
832hpdftbl_set_cell_content_style(hpdftbl_t t, size_t r, size_t c, char *font, HPDF_REAL fsize, HPDF_RGBColor color,
833 HPDF_RGBColor background);
834
835int
836hpdftbl_set_title_style(hpdftbl_t t, char *font, HPDF_REAL fsize, HPDF_RGBColor color, HPDF_RGBColor background);
837
838/*
839 * Table content handling
840 */
841int
842hpdftbl_set_cell(hpdftbl_t t, size_t r, size_t c, char *label, char *content);
843
844int
845hpdftbl_set_tag(hpdftbl_t t, void *tag);
846
847int
848hpdftbl_set_title(hpdftbl_t t, char *title);
849
850int
852
853int
854hpdftbl_set_labels(hpdftbl_t t, char **labels);
855
856int
857hpdftbl_set_content(hpdftbl_t t, char **content);
858
859/*
860 * Table callback functions
861 */
862int
864
865int
867
868int
870
871int
873
874int
876
877int
879
880int
882
883int
885
886int
888
889/*
890 * Table dynamic callback functions
891 */
892void
894
895int
897
898int
900
901int
902hpdftbl_set_cell_content_dyncb(hpdftbl_t, size_t, size_t, const char *);
903
904int
906
907int
908hpdftbl_set_cell_label_dyncb(hpdftbl_t, size_t, size_t, const char *);
909
910int
912
913int
914hpdftbl_set_cell_content_style_dyncb(hpdftbl_t, size_t, size_t, const char *);
915
916int
917hpdftbl_set_cell_canvas_dyncb(hpdftbl_t, size_t, size_t, const char *);
918
919int
920hpdftbl_set_post_dyncb(hpdftbl_t t, const char *cb_name);
921
922/*
923 * Text encoding
924 */
925void
926hpdftbl_set_text_encoding(char *target, char *source);
927
928int
929hpdftbl_encoding_text_out(HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, char *text);
930
931/*
932 * Misc utility and widget functions
933 */
934
935void
936HPDF_RoundedCornerRectangle(HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height,
937 HPDF_REAL rad);
938
939void
940hpdftbl_stroke_grid(HPDF_Doc pdf, HPDF_Page page);
941
942void
943hpdftbl_table_widget_letter_buttons(HPDF_Doc doc, HPDF_Page page,
944 HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height,
945 HPDF_RGBColor on_color, HPDF_RGBColor off_color,
946 HPDF_RGBColor on_background, HPDF_RGBColor off_background,
947 HPDF_REAL fsize,
948 const char *letters, _Bool *state);
949
950void
951hpdftbl_widget_slide_button(HPDF_Doc doc, HPDF_Page page,
952 HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height, _Bool state);
953
954void
955hpdftbl_widget_hbar(HPDF_Doc doc, HPDF_Page page,
956 HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height,
957 HPDF_RGBColor color, float val, _Bool hide_val);
958
959void
960hpdftbl_widget_segment_hbar(HPDF_Doc doc, HPDF_Page page,
961 HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height,
962 size_t num_segments, HPDF_RGBColor on_color, double val_percent,
963 _Bool hide_val);
964
965void
966hpdftbl_widget_strength_meter(HPDF_Doc doc, HPDF_Page page,
967 HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height,
968 size_t num_segments, HPDF_RGBColor on_color, size_t num_on_segments);
969
970int
971hpdftbl_stroke_pdfdoc(HPDF_Doc pdf_doc, char *file);
972
973#ifdef HAVE_LIBJANSSON
974
975int
976hpdftbl_dump(hpdftbl_t tbl, char *filename);
977
978int
979hpdftbl_dumps(hpdftbl_t tbl, char *buff, size_t buffsize);
980
981int
982hpdftbl_load(hpdftbl_t tbl, char *filename);
983
984int
985hpdftbl_loads(hpdftbl_t tbl, char *buff);
986
987int
988hpdftbl_theme_dump(hpdftbl_theme_t *theme, char *filename);
989
990int
991hpdftbl_theme_dumps(hpdftbl_theme_t *theme, char *buff, size_t buffsize);
992
993int
994hpdftbl_theme_loads(hpdftbl_theme_t *tbl, char *buff);
995
996int
997hpdftbl_theme_load(hpdftbl_theme_t *tbl, char *filename);
998
999#endif
1000
1001size_t
1002xstrlcat(char *dst, const char *src, size_t siz);
1003
1004size_t
1005xstrlcpy(char * __restrict dst, const char * __restrict src, size_t dsize);
1006
1007int
1008hpdftbl_read_file(char *buff, size_t buffsize, char *filename);
1009
1010/*
1011 * Internal functions
1012 */
1013_Bool
1014chktbl(hpdftbl_t, size_t, size_t);
1015
1016#ifdef __cplusplus
1017}
1018#endif
1019
1020#endif /* hpdftbl_H */
void hpdftbl_table_widget_letter_buttons(HPDF_Doc doc, HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height, HPDF_RGBColor on_color, HPDF_RGBColor off_color, HPDF_RGBColor on_background, HPDF_RGBColor off_background, HPDF_REAL fsize, const char *letters, _Bool *state)
Display an array of letters as a table where each letter is its own "mini" cell and sorrounded by a...
Definition: hpdftbl_widget.c:74
int hpdftbl_read_file(char *buff, size_t buffsize, char *filename)
Read content of file into a specified buffer.
Definition: read_file.c:42
void HPDF_RoundedCornerRectangle(HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height, HPDF_REAL rad)
Draw rectangle with rounded corner.
Definition: hpdftbl.c:257
int hpdftbl_stroke_pdfdoc(HPDF_Doc pdf_doc, char *file)
Stroke PDF document to file with check that the directory in path exists.
Definition: hpdftbl.c:1883
char *(* hpdftbl_content_callback_t)(void *, size_t, size_t)
Type specification for the table content callback.
Definition: hpdftbl.h:330
int hpdftbl_theme_dump(hpdftbl_theme_t *theme, char *filename)
Serialize the specified theme structure to a named file.
Definition: hpdftbl_dump.c:108
int hpdftbl_get_last_auto_height(HPDF_REAL *height)
Get the height calculated for the last constructed table.
Definition: hpdftbl.c:1433
hpdftbl_error_handler_t hpdftbl_set_errhandler(hpdftbl_error_handler_t)
Specify errhandler for the table routines.
Definition: hpdftbl_errstr.c:361
void(* hpdftbl_callback_t)(hpdftbl_t)
Callback type for optional post processing when constructing table from a data array.
Definition: hpdftbl.h:365
hpdftbl_theme_t * hpdftbl_get_default_theme(void)
Return the default theme.
Definition: hpdftbl_theme.c:259
void(* hpdftbl_error_handler_t)(hpdftbl_t, int, int, int)
TYpe for error handler function.
Definition: hpdftbl.h:677
int hpdftbl_encoding_text_out(HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, char *text)
Strke text with current encoding.
Definition: hpdftbl.c:220
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
void hpdftbl_get_last_err_file(int *lineno, char **file, char **extrainfo)
Get the filename and line number where the last error occurred.
Definition: hpdftbl_errstr.c:345
int hpdftbl_set_canvas_dyncb(hpdftbl_t, const char *)
Specify dynamic (late) loading callback content function.
Definition: hpdftbl_callback.c:327
int hpdftbl_set_cell_label_cb(hpdftbl_t t, size_t r, size_t c, hpdftbl_content_callback_t cb)
Set cell label callback.
Definition: hpdftbl_callback.c:140
int hpdftbl_set_min_rowheight(hpdftbl_t t, float h)
Set the minimum row height in the table.
Definition: hpdftbl.c:416
void hpdftbl_default_table_error_handler(hpdftbl_t t, int r, int c, int err)
A basic default table error handler.
Definition: hpdftbl_errstr.c:287
struct hpdftbl * hpdftbl_t
Table handle is a pointer to the hpdftbl structure.
Definition: hpdftbl.h:320
void hpdftbl_widget_segment_hbar(HPDF_Doc doc, HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height, size_t num_segments, HPDF_RGBColor on_color, double val_percent, _Bool hide_val)
Draw a horizontal segment meter that can be used to visualize a discrete value.
Definition: hpdftbl_widget.c:299
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_set_content_style_cb(hpdftbl_t t, hpdftbl_content_style_callback_t cb)
Set callback to specify cell content style.
Definition: hpdftbl_callback.c:690
_Bool(* hpdftbl_content_style_callback_t)(void *, size_t, size_t, char *content, hpdf_text_style_t *)
Type specification for the content style.
Definition: hpdftbl.h:353
int hpdftbl_err_row
The row where the last error was generated.
Definition: hpdftbl_errstr.c:84
int hpdftbl_use_labelgrid(hpdftbl_t t, _Bool use)
Shorter vertical line to mark labels.
Definition: hpdftbl.c:687
int hpdftbl_set_header_halign(hpdftbl_t t, hpdftbl_text_align_t align)
Set table header horizontal text align.
Definition: hpdftbl.c:628
size_t xstrlcpy(char *__restrict dst, const char *__restrict src, size_t dsize)
Safe string copy.
Definition: xstr.c:26
int hpdftbl_set_cell_content_style_cb(hpdftbl_t t, size_t r, size_t c, hpdftbl_content_style_callback_t cb)
Set cell specific callback to specify cell content style.
Definition: hpdftbl_callback.c:664
_Bool chktbl(hpdftbl_t, size_t, size_t)
Internal function. Check that a row and column are within the table.
Definition: hpdftbl.c:785
int hpdftbl_set_background(hpdftbl_t t, HPDF_RGBColor background)
Set table background color.
Definition: hpdftbl.c:614
int hpdftbl_use_labels(hpdftbl_t t, _Bool use)
Enable/Disable the use of cell labels.
Definition: hpdftbl.c:666
int hpdftbl_set_content_style(hpdftbl_t t, char *font, HPDF_REAL fsize, HPDF_RGBColor color, HPDF_RGBColor background)
Set text style for text content.
Definition: hpdftbl.c:1100
hpdftbl_text_align
Enumeration for horizontal text alignment.
Definition: hpdftbl.h:292
@ CENTER
Definition: hpdftbl.h:294
@ LEFT
Definition: hpdftbl.h:293
@ RIGHT
Definition: hpdftbl.h:295
int hpdftbl_set_post_cb(hpdftbl_t t, hpdftbl_callback_t cb)
Set table post processing callback.
Definition: hpdftbl_callback.c:232
struct hpdftbl_cell_spec hpdftbl_cell_spec_t
Used in data driven table creation.
char hpdftbl_err_extrainfo[]
Extra info that may be specified at the point of error.
Definition: hpdftbl_errstr.c:96
char * hpdftbl_err_file
Hold the file name where the last error occurred.
Definition: hpdftbl_errstr.c:93
int hpdftbl_set_header_style(hpdftbl_t t, char *font, HPDF_REAL fsize, HPDF_RGBColor color, HPDF_RGBColor background)
Specify style for table header row.
Definition: hpdftbl.c:597
int hpdftbl_get_last_errcode(const char **errstr, int *row, int *col)
Return last error code.
Definition: hpdftbl_errstr.c:316
void(* hpdftbl_canvas_callback_t)(HPDF_Doc, HPDF_Page, void *, size_t, size_t, HPDF_REAL, HPDF_REAL, HPDF_REAL, HPDF_REAL)
Type specification for the table canvas callback.
Definition: hpdftbl.h:341
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_destroy_theme(hpdftbl_theme_t *theme)
Destroy existing theme structure and free memory.
Definition: hpdftbl_theme.c:302
int hpdftbl_setpos(hpdftbl_t t, const HPDF_REAL xpos, const HPDF_REAL ypos, const HPDF_REAL width, HPDF_REAL height)
Set size and position for table.
Definition: hpdftbl.c:1614
void hpdftbl_set_dlhandle(void *)
Set the handle for scope of dynamic function search.
Definition: hpdftbl_callback.c:65
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_set_cell_label_dyncb(hpdftbl_t, size_t, size_t, const char *)
Specify dynamic (late) loading callback for cell label function.
Definition: hpdftbl_callback.c:415
int hpdftbl_set_cell_canvas_dyncb(hpdftbl_t, size_t, size_t, const char *)
Specify dynamic (late) loading callback cell canvas function.
Definition: hpdftbl_callback.c:591
int hpdftbl_set_content_style_dyncb(hpdftbl_t, const char *)
Specify dynamic (late) loading callback for table style function.
Definition: hpdftbl_callback.c:459
int hpdftbl_set_zebra(hpdftbl_t t, _Bool use, int phase)
Definition: hpdftbl.c:556
const char * hpdftbl_hpdf_get_errstr(HPDF_STATUS err_code)
Function to return a human readable error string for an error code from Core HPDF library.
Definition: hpdftbl_errstr.c:232
int hpdftbl_set_tag(hpdftbl_t t, void *tag)
Set an optional tag for the table.
Definition: hpdftbl.c:706
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
size_t xstrlcat(char *dst, const char *src, size_t siz)
Safe string concatenation.
Definition: xstr.c:68
struct hpdftbl_spec hpdftbl_spec_t
Used in data driven table creation.
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
int hpdftbl_apply_theme(hpdftbl_t t, hpdftbl_theme_t *theme)
Apply a specified theme to a table.
Definition: hpdftbl_theme.c:177
int hpdftbl_set_label_style(hpdftbl_t t, char *font, HPDF_REAL fsize, HPDF_RGBColor color, HPDF_RGBColor background)
Set the text style for labels in the entire table.
Definition: hpdftbl.c:1074
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_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
int hpdftbl_set_post_dyncb(hpdftbl_t t, const char *cb_name)
Set table post processing callback.
Definition: hpdftbl_callback.c:628
hpdftbl_t hpdftbl_create(size_t rows, size_t cols)
Create a new table with no title.
Definition: hpdftbl.c:311
struct text_style hpdf_text_style_t
Specification of a text style.
int hpdftbl_theme_loads(hpdftbl_theme_t *tbl, char *buff)
Load theme from a serialized string. This is the invert function of hpdftbl_theme_dumps().
Definition: hpdftbl_load.c:209
int hpdftbl_destroy(hpdftbl_t t)
Destroy a table and free all memory.
Definition: hpdftbl.c:750
struct grid_style hpdftbl_grid_style_t
Specification for table grid lines.
void hpdftbl_widget_hbar(HPDF_Doc doc, HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height, HPDF_RGBColor color, float val, _Bool hide_val)
Draw a horizontal partially filled bar to indicate an analog (percentage) value.
Definition: hpdftbl_widget.c:239
enum hpdftbl_text_align hpdftbl_text_align_t
Enumeration for horizontal text alignment.
int hpdftbl_set_title_halign(hpdftbl_t t, hpdftbl_text_align_t align)
Set horizontal alignment for table title.
Definition: hpdftbl.c:1242
void hpdftbl_widget_strength_meter(HPDF_Doc doc, HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height, size_t num_segments, HPDF_RGBColor on_color, size_t num_on_segments)
Draw a phone strength meter.
Definition: hpdftbl_widget.c:383
int hpdftbl_set_row_content_style(hpdftbl_t t, size_t r, char *font, HPDF_REAL fsize, HPDF_RGBColor color, HPDF_RGBColor background)
Set the text style for an entire row of cells.
Definition: hpdftbl.c:1124
enum hpdftbl_dashstyle hpdftbl_line_dashstyle_t
Possible line dash styles for grid lines.
int hpdftbl_set_colwidth_percent(hpdftbl_t t, size_t c, float w)
Set column width as percentage of overall table width.
Definition: hpdftbl.c:435
int hpdftbl_theme_dumps(hpdftbl_theme_t *theme, char *buff, size_t buffsize)
Serialize theme structure to a string buffer.
Definition: hpdftbl_dump.c:135
hpdftbl_dashstyle
Possible line dash styles for grid lines.
Definition: hpdftbl.h:375
@ LINE_DASHDOT1
Definition: hpdftbl.h:386
@ LINE_DASH5
Definition: hpdftbl.h:385
@ LINE_DOT2
Definition: hpdftbl.h:378
@ LINE_SOLID
Definition: hpdftbl.h:376
@ LINE_DASH2
Definition: hpdftbl.h:382
@ LINE_DASH4
Definition: hpdftbl.h:384
@ LINE_DASHDOT2
Definition: hpdftbl.h:387
@ LINE_DOT3
Definition: hpdftbl.h:379
@ LINE_DOT1
Definition: hpdftbl.h:377
@ LINE_DASH1
Definition: hpdftbl.h:381
@ LINE_DOT4
Definition: hpdftbl.h:380
@ LINE_DASH3
Definition: hpdftbl.h:383
void hpdftbl_set_anchor_top_left(hpdftbl_t tbl, _Bool anchor)
Switch stroking anchor point.
Definition: hpdftbl.c:135
int hpdftbl_clear_spanning(hpdftbl_t t)
Clear all cell spanning.
Definition: hpdftbl.c:893
int hpdftbl_err_col
The column where the last error was generated.
Definition: hpdftbl_errstr.c:87
int hpdftbl_set_zebra_color(hpdftbl_t t, HPDF_RGBColor z1, HPDF_RGBColor z2)
Specify first and second color for a zebra grid table.
Definition: hpdftbl.c:574
hpdftbl_error_handler_t hpdftbl_err_handler
This stores a pointer to the function acting as the error handler callback.
Definition: hpdftbl.c:61
void hpdftbl_set_bottom_vmargin_factor(hpdftbl_t t, HPDF_REAL f)
The margin from the bottom of the cell to the baseline of the text is calculated as a fraction of the...
Definition: hpdftbl.c:297
int hpdftbl_stroke(HPDF_Doc pdf, HPDF_Page page, hpdftbl_t t, HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height)
Stroke the table.
Definition: hpdftbl.c:1682
struct hpdftbl_theme hpdftbl_theme_t
Define a set of styles into a table theme.
int hpdftbl_dumps(hpdftbl_t tbl, char *buff, size_t buffsize)
Serialize a table structure to a string buffer.
Definition: hpdftbl_dump.c:218
const char * hpdftbl_get_errstr(int err)
Translate a table error code to a human readable string.
Definition: hpdftbl_errstr.c:256
int hpdftbl_set_title(hpdftbl_t t, char *title)
Set table title.
Definition: hpdftbl.c:1223
_Bool hpdftbl_get_anchor_top_left(hpdftbl_t tbl)
Get stroking anchor point.
Definition: hpdftbl.c:150
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_err_code
Stores the last generated error code.
Definition: hpdftbl_errstr.c:81
int hpdftbl_err_lineno
Hold the line number of the last error occurred.
Definition: hpdftbl_errstr.c:90
int hpdftbl_set_canvas_cb(hpdftbl_t t, hpdftbl_canvas_callback_t cb)
Set cell canvas callback.
Definition: hpdftbl_callback.c:258
int hpdftbl_stroke_from_data(HPDF_Doc pdf_doc, HPDF_Page pdf_page, hpdftbl_spec_t *tbl_spec, hpdftbl_theme_t *theme)
Construct the table from a array specification.
Definition: hpdftbl.c:1265
int hpdftbl_set_label_dyncb(hpdftbl_t, const char *)
Specify dynamic (late) loading callback for table label function.
Definition: hpdftbl_callback.c:370
int hpdftbl_set_content_dyncb(hpdftbl_t, const char *)
Specify dynamic (late) loading callback content function.
Definition: hpdftbl_callback.c:285
void hpdftbl_widget_slide_button(HPDF_Doc doc, HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, HPDF_REAL width, HPDF_REAL height, _Bool state)
Table widget that draws a sliding on/off switch. Meant to be used in a canvas callback to display a b...
Definition: hpdftbl_widget.c:140
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
int hpdftbl_set_cell_canvas_cb(hpdftbl_t t, size_t r, size_t c, hpdftbl_canvas_callback_t cb)
Set cell canvas callback.
Definition: hpdftbl_callback.c:178
int hpdftbl_set_cell_content_style(hpdftbl_t t, size_t r, size_t c, char *font, HPDF_REAL fsize, HPDF_RGBColor color, HPDF_RGBColor background)
Set the text style for content of specified cell.
Definition: hpdftbl.c:1171
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_grid_style(hpdftbl_t t, HPDF_REAL width, HPDF_RGBColor color, hpdftbl_line_dashstyle_t dashstyle)
Set inner border grid style.
Definition: hpdftbl.c:481
void hpdftbl_set_text_encoding(char *target, char *source)
Determine text source encoding.
Definition: hpdftbl.c:172
int hpdftbl_set_cell_content_style_dyncb(hpdftbl_t, size_t, size_t, const char *)
Specify dynamic (late) loading callback for cell style function.
Definition: hpdftbl_callback.c:507
int hpdftbl_set_col_content_style(hpdftbl_t t, size_t c, char *font, HPDF_REAL fsize, HPDF_RGBColor color, HPDF_RGBColor background)
Set the text style for an entire column of cells.
Definition: hpdftbl.c:1147
int hpdftbl_set_cell(hpdftbl_t t, size_t r, size_t c, char *label, char *content)
Set content for specific cell.
Definition: hpdftbl.c:805
int hpdftbl_loads(hpdftbl_t tbl, char *buff)
Import a table structure from a serialized json buffert.
Definition: hpdftbl_load.c:369
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
void hpdftbl_stroke_grid(HPDF_Doc pdf, HPDF_Page page)
Definition: hpdftbl_grid.c:46
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_cell_content_dyncb(hpdftbl_t, size_t, size_t, const char *)
Specify dynamic (late) loading callback cell content function.
Definition: hpdftbl_callback.c:551
int hpdftbl_set_title_style(hpdftbl_t t, char *font, HPDF_REAL fsize, HPDF_RGBColor color, HPDF_RGBColor background)
Set the table title text style.
Definition: hpdftbl.c:1200
int hpdftbl_set_content_cb(hpdftbl_t t, hpdftbl_content_callback_t cb)
Set table content callback.
Definition: hpdftbl_callback.c:86
Specification for table grid lines.
Definition: hpdftbl.h:395
HPDF_REAL width
Definition: hpdftbl.h:396
HPDF_RGBColor color
Definition: hpdftbl.h:397
hpdftbl_line_dashstyle_t line_dashstyle
Definition: hpdftbl.h:398
Used in data driven table creation.
Definition: hpdftbl.h:569
hpdftbl_content_callback_t content_cb
Definition: hpdftbl.h:581
hpdftbl_content_style_callback_t style_cb
Definition: hpdftbl.h:585
size_t col
Definition: hpdftbl.h:573
size_t row
Definition: hpdftbl.h:571
unsigned rowspan
Definition: hpdftbl.h:575
hpdftbl_canvas_callback_t canvas_cb
Definition: hpdftbl.h:587
char * label
Definition: hpdftbl.h:579
unsigned colspan
Definition: hpdftbl.h:577
hpdftbl_content_callback_t label_cb
Definition: hpdftbl.h:583
Specification of individual cells in the table.
Definition: hpdftbl.h:408
char * canvas_dyncb
Definition: hpdftbl.h:446
hpdf_text_style_t content_style
Definition: hpdftbl.h:448
hpdftbl_content_callback_t content_cb
Definition: hpdftbl.h:432
HPDF_REAL delta_x
Definition: hpdftbl.h:426
size_t rowspan
Definition: hpdftbl.h:420
HPDF_REAL delta_y
Definition: hpdftbl.h:428
hpdftbl_content_style_callback_t style_cb
Definition: hpdftbl.h:440
HPDF_REAL width
Definition: hpdftbl.h:424
char * content_dyncb
Definition: hpdftbl.h:434
struct hpdftbl_cell * parent_cell
Definition: hpdftbl.h:452
HPDF_REAL height
Definition: hpdftbl.h:422
size_t colspan
Definition: hpdftbl.h:418
size_t col
Definition: hpdftbl.h:412
HPDF_REAL textwidth
Definition: hpdftbl.h:430
size_t row
Definition: hpdftbl.h:410
char * content
Definition: hpdftbl.h:416
hpdftbl_canvas_callback_t canvas_cb
Definition: hpdftbl.h:444
char * label_dyncb
Definition: hpdftbl.h:438
char * content_style_dyncb
Definition: hpdftbl.h:442
char * label
Definition: hpdftbl.h:414
hpdftbl_content_callback_t label_cb
Definition: hpdftbl.h:436
Used in data driven table creation.
Definition: hpdftbl.h:596
hpdftbl_content_callback_t content_cb
Definition: hpdftbl.h:618
_Bool use_labelgrid
Definition: hpdftbl.h:604
HPDF_REAL ypos
Definition: hpdftbl.h:612
hpdftbl_content_style_callback_t style_cb
Definition: hpdftbl.h:622
HPDF_REAL width
Definition: hpdftbl.h:614
HPDF_REAL height
Definition: hpdftbl.h:616
HPDF_REAL xpos
Definition: hpdftbl.h:610
size_t cols
Definition: hpdftbl.h:608
hpdftbl_cell_spec_t * cell_spec
Definition: hpdftbl.h:626
_Bool use_labels
Definition: hpdftbl.h:602
_Bool use_header
Definition: hpdftbl.h:600
size_t rows
Definition: hpdftbl.h:606
hpdftbl_callback_t post_cb
Definition: hpdftbl.h:624
char * title
Definition: hpdftbl.h:598
hpdftbl_content_callback_t label_cb
Definition: hpdftbl.h:620
Define a set of styles into a table theme.
Definition: hpdftbl.h:635
hpdf_text_style_t content_style
Definition: hpdftbl.h:637
_Bool use_header_row
Definition: hpdftbl.h:651
_Bool use_zebra
Definition: hpdftbl.h:659
HPDF_REAL bottom_vmargin_factor
Definition: hpdftbl.h:667
hpdf_text_style_t title_style
Definition: hpdftbl.h:643
_Bool use_label_grid_style
Definition: hpdftbl.h:649
hpdftbl_grid_style_t inner_vborder
Definition: hpdftbl.h:653
hpdftbl_grid_style_t outer_border
Definition: hpdftbl.h:645
hpdf_text_style_t header_style
Definition: hpdftbl.h:641
HPDF_RGBColor zebra_color2
Definition: hpdftbl.h:665
_Bool use_labels
Definition: hpdftbl.h:647
int zebra_phase
Definition: hpdftbl.h:661
HPDF_RGBColor zebra_color1
Definition: hpdftbl.h:663
hpdftbl_grid_style_t inner_tborder
Definition: hpdftbl.h:657
hpdf_text_style_t label_style
Definition: hpdftbl.h:639
hpdftbl_grid_style_t inner_hborder
Definition: hpdftbl.h:655
Core table handle.
Definition: hpdftbl.h:470
char * canvas_dyncb
Definition: hpdftbl.h:526
hpdf_text_style_t content_style
Definition: hpdftbl.h:510
hpdftbl_grid_style_t outer_grid
Definition: hpdftbl.h:535
hpdftbl_content_callback_t content_cb
Definition: hpdftbl.h:516
_Bool use_header_row
Definition: hpdftbl.h:502
HPDF_REAL posy
Definition: hpdftbl.h:482
_Bool use_zebra
Definition: hpdftbl.h:545
hpdftbl_grid_style_t inner_vgrid
Definition: hpdftbl.h:537
hpdftbl_grid_style_t inner_tgrid
Definition: hpdftbl.h:541
void * tag
Definition: hpdftbl.h:494
HPDF_REAL width
Definition: hpdftbl.h:492
hpdftbl_grid_style_t inner_hgrid
Definition: hpdftbl.h:539
char * content_dyncb
Definition: hpdftbl.h:518
HPDF_REAL bottom_vmargin_factor
Definition: hpdftbl.h:490
hpdf_text_style_t title_style
Definition: hpdftbl.h:498
_Bool use_label_grid_style
Definition: hpdftbl.h:508
HPDF_REAL height
Definition: hpdftbl.h:484
float * col_width_percent
Definition: hpdftbl.h:555
hpdftbl_content_style_callback_t content_style_cb
Definition: hpdftbl.h:520
hpdftbl_cell_t * cells
Definition: hpdftbl.h:557
size_t cols
Definition: hpdftbl.h:476
hpdf_text_style_t header_style
Definition: hpdftbl.h:500
HPDF_RGBColor zebra_color2
Definition: hpdftbl.h:553
char * title_txt
Definition: hpdftbl.h:496
HPDF_Doc pdf_doc
Definition: hpdftbl.h:472
int zebra_phase
Definition: hpdftbl.h:549
HPDF_REAL posx
Definition: hpdftbl.h:480
hpdftbl_canvas_callback_t canvas_cb
Definition: hpdftbl.h:524
char * label_dyncb
Definition: hpdftbl.h:514
char * content_style_dyncb
Definition: hpdftbl.h:522
HPDF_RGBColor zebra_color1
Definition: hpdftbl.h:551
_Bool use_cell_labels
Definition: hpdftbl.h:506
size_t rows
Definition: hpdftbl.h:478
hpdftbl_callback_t post_cb
Definition: hpdftbl.h:531
hpdf_text_style_t label_style
Definition: hpdftbl.h:504
HPDF_Page pdf_page
Definition: hpdftbl.h:474
HPDF_REAL minrowheight
Definition: hpdftbl.h:486
_Bool anchor_is_top_left
Definition: hpdftbl.h:488
char * post_dyncb
Definition: hpdftbl.h:533
hpdftbl_content_callback_t label_cb
Definition: hpdftbl.h:512
Specification of a text style.
Definition: hpdftbl.h:303
char * font
Definition: hpdftbl.h:304
HPDF_RGBColor color
Definition: hpdftbl.h:306
HPDF_REAL fsize
Definition: hpdftbl.h:305
hpdftbl_text_align_t halign
Definition: hpdftbl.h:308
HPDF_RGBColor background
Definition: hpdftbl.h:307