libhpdftbl 1.5.0
Table construction library for Haru PDF library
|
Header file for libhpdftbl. More...
#include "config.h"
Go to the source code of this file.
Data Structures | |
struct | text_style |
Specification of a text style. More... | |
struct | grid_style |
Specification for table grid lines. More... | |
struct | hpdftbl_cell |
Specification of individual cells in the table. More... | |
struct | hpdftbl |
Core table handle. More... | |
struct | hpdftbl_cell_spec |
Used in data driven table creation. More... | |
struct | hpdftbl_spec |
Used in data driven table creation. More... | |
struct | hpdftbl_theme |
Define a set of styles into a table theme. More... | |
Macros | |
#define | hpdftbl_H |
#define | TRUE 1 |
Boolean truth value. | |
#define | FALSE 0 |
Boolean false value. | |
#define | max(a, b) (((a)>(b)) ? (a):(b)) |
Return the maximum value of numeric variables. | |
#define | min(a, b) (((a)<(b)) ? (a):(b)) |
Return the minimum value of numeric variables. | |
#define | THEME_JSON_VERSION 1 |
#define | TABLE_JSON_VERSION 1 |
#define | HPDF_FF_TIMES "Times-Roman" |
#define | HPDF_FF_TIMES_ITALIC "Times-Italic" |
#define | HPDF_FF_TIMES_BOLD "Times-Bold" |
#define | HPDF_FF_TIMES_BOLDITALIC "Times-BoldItalic" |
#define | HPDF_FF_HELVETICA "Helvetica" |
#define | HPDF_FF_HELVETICA_ITALIC "Helvetica-Oblique" |
#define | HPDF_FF_HELVETICA_BOLD "Helvetica-Bold" |
#define | HPDF_FF_HELVETICA_BOLDITALIC "Helvetica-BoldOblique" |
#define | HPDF_FF_COURIER "Courier" |
#define | HPDF_FF_COURIER_BOLD "Courier-Bold" |
#define | HPDF_FF_COURIER_IALIC "Courier-Oblique" |
#define | HPDF_FF_COURIER_BOLDITALIC "Courier-BoldOblique" |
#define | HPDF_RGB_CONVERT(r, g, b) (HPDF_RGBColor) { r / 255.0f, g / 255.0f, b / 255.0f } |
Utility macro to create a HPDF color constant from integer RGB values. | |
#define | HPDF_COLOR_DARK_RED (HPDF_RGBColor) { 0.6f, 0.0f, 0.0f } |
#define | HPDF_COLOR_RED (HPDF_RGBColor) { 1.0f, 0.0f, 0.0f } |
#define | HPDF_COLOR_LIGHT_GREEN (HPDF_RGBColor) { 0.9f, 1.0f, 0.9f } |
#define | HPDF_COLOR_GREEN (HPDF_RGBColor) { 0.4f, 0.9f, 0.4f } |
#define | HPDF_COLOR_DARK_GREEN (HPDF_RGBColor) { 0.05f, 0.37f, 0.02f } |
#define | HPDF_COLOR_DARK_GRAY (HPDF_RGBColor) { 0.2f, 0.2f, 0.2f } |
#define | HPDF_COLOR_LIGHT_GRAY (HPDF_RGBColor) { 0.9f, 0.9f, 0.9f } |
#define | HPDF_COLOR_XLIGHT_GRAY (HPDF_RGBColor) { 0.95f, 0.95f, 0.95f } |
#define | HPDF_COLOR_GRAY (HPDF_RGBColor) { 0.5f, 0.5f, 0.5f } |
#define | HPDF_COLOR_SILVER (HPDF_RGBColor) { 0.75f, 0.75f, 0.75f } |
#define | HPDF_COLOR_LIGHT_BLUE (HPDF_RGBColor) { 1.0f, 1.0f, 0.9f } |
#define | HPDF_COLOR_BLUE (HPDF_RGBColor) { 0.0f, 0.0f, 1.0f } |
#define | HPDF_COLOR_DARK_BLUE (HPDF_RGBColor) { 0.0f, 0.0f, 0.6f } |
#define | HPDF_COLOR_WHITE (HPDF_RGBColor) { 1.0f, 1.0f, 1.0f } |
#define | HPDF_COLOR_BLACK (HPDF_RGBColor) { 0.0f, 0.0f, 0.0f } |
#define | HPDF_COLOR_ORANGE HPDF_RGB_CONVERT(0xF5, 0xD0, 0x98); |
#define | HPDF_COLOR_ALMOST_BLACK HPDF_RGB_CONVERT(0x14, 0x14, 0x14); |
#define | DEFAULT_AUTO_VBOTTOM_MARGIN_FACTOR 0.5 |
The margin from the bottom of the cell to the baseline of the text is calculated as a fraction of the font size. More... | |
#define | HPDFTBL_DEFAULT_TARGET_ENCODING "ISO8859-4" |
Default PDF text encodings. | |
#define | HPDFTBL_DEFAULT_SOURCE_ENCODING "UTF-8" |
Default input source text encodings. | |
#define | A4PAGE_HEIGHT_CM 29.7 |
Standard A4 paper height in cm. | |
#define | A4PAGE_WIDTH_CM 21.0 |
Standard A4 paper width in cm. | |
#define | A3PAGE_HEIGHT_CM 42.0 |
Standard A3 paper height in cm. | |
#define | A3PAGE_WIDTH_CM 29.7 |
Standard A3 paper width in cm. | |
#define | LETTERRPAGE_HEIGHT_CM 27.9 |
US Letter Height in cm. | |
#define | LETTERRPAGE_WIDTH_CM 21.6 |
US Letter width in cm. | |
#define | LEGALPAGE_HEIGHT_CM 35.6 |
US Legal Height in cm. | |
#define | LEGALPAGE_WIDTH_CM 21.6 |
US Legal Width in cm. | |
#define | HPDFTBL_END_CELLSPECS {0, 0, 0, 0, 0, 0, 0, 0, 0} |
Sentinel to mark the end of Cell Specifications for data driven table definition. | |
#define | HPDF_COLOR_FROMRGB(r, g, b) (HPDF_RGBColor){(r)/255.0,(g)/255.0,(b)/255.0} |
Utility macro to calculate a color constant from RGB integer values [0,255]. | |
#define | HPDFTBL_MIN_CALCULATED_PERCENT_CELL_WIDTH 2.0 |
The smallest size in percent of table width allowed by automatic calculation before giving an error. | |
#define | hpdftbl_cm2dpi(c) (((HPDF_REAL)(c))/2.54*72) |
Convert cm to dots using the default resolution (72 DPI) More... | |
#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) |
Call the error handler with specified error code and table row, col where error occured. More... | |
#define | _HPDFTBL_SET_ERR_EXTRA(info) do {strncpy(hpdftbl_err_extrainfo,info,1023);hpdftbl_err_extrainfo[1023]=0;} while(0) |
Set optional extra info at error state. (Currently only used by the late binding setting callback functions) More... | |
#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) |
NPE check before using a table handler. | |
#define | _HPDFTBL_IDX(r, c) (r*t->cols+c) |
Shortcut to calculate the index in an array from a row,column (table) position. | |
Typedefs | |
typedef enum hpdftbl_text_align | hpdftbl_text_align_t |
Enumeration for horizontal text alignment. More... | |
typedef struct text_style | hpdf_text_style_t |
Specification of a text style. More... | |
typedef struct hpdftbl * | hpdftbl_t |
Table handle is a pointer to the hpdftbl structure. More... | |
typedef char *(* | hpdftbl_content_callback_t) (void *, size_t, size_t) |
Type specification for the table content callback. More... | |
typedef 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. More... | |
typedef _Bool(* | hpdftbl_content_style_callback_t) (void *, size_t, size_t, char *content, hpdf_text_style_t *) |
Type specification for the content style. More... | |
typedef void(* | hpdftbl_callback_t) (hpdftbl_t) |
Callback type for optional post processing when constructing table from a data array. More... | |
typedef enum hpdftbl_dashstyle | hpdftbl_line_dashstyle_t |
Possible line dash styles for grid lines. More... | |
typedef struct grid_style | hpdftbl_grid_style_t |
Specification for table grid lines. More... | |
typedef struct hpdftbl_cell | hpdftbl_cell_t |
Type definition for the cell structure. More... | |
typedef struct hpdftbl_cell_spec | hpdftbl_cell_spec_t |
Used in data driven table creation. More... | |
typedef struct hpdftbl_spec | hpdftbl_spec_t |
Used in data driven table creation. More... | |
typedef struct hpdftbl_theme | hpdftbl_theme_t |
Define a set of styles into a table theme. More... | |
typedef void(* | hpdftbl_error_handler_t) (hpdftbl_t, int, int, int) |
TYpe for error handler function. More... | |
Enumerations | |
enum | hpdftbl_text_align { LEFT = 0 , CENTER = 1 , RIGHT = 2 } |
Enumeration for horizontal text alignment. More... | |
enum | hpdftbl_dashstyle { LINE_SOLID , LINE_DOT1 , LINE_DOT2 , LINE_DOT3 , LINE_DOT4 , LINE_DASH1 , LINE_DASH2 , LINE_DASH3 , LINE_DASH4 , LINE_DASH5 , LINE_DASHDOT1 , LINE_DASHDOT2 } |
Possible line dash styles for grid lines. More... | |
Functions | |
hpdftbl_t | hpdftbl_create (size_t rows, size_t cols) |
Create a new table with no title. More... | |
hpdftbl_t | hpdftbl_create_title (size_t rows, size_t cols, char *title) |
Create a new table with title top row. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
int | hpdftbl_destroy (hpdftbl_t t) |
Destroy a table and free all memory. More... | |
int | hpdftbl_get_last_auto_height (HPDF_REAL *height) |
Get the height calculated for the last constructed table. More... | |
void | hpdftbl_set_anchor_top_left (hpdftbl_t tbl, _Bool anchor) |
Switch stroking anchor point. More... | |
_Bool | hpdftbl_get_anchor_top_left (hpdftbl_t tbl) |
Get stroking anchor point. More... | |
hpdftbl_error_handler_t | hpdftbl_set_errhandler (hpdftbl_error_handler_t) |
Specify errhandler for the table routines. More... | |
const char * | hpdftbl_get_errstr (int err) |
Translate a table error code to a human readable string. More... | |
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. More... | |
int | hpdftbl_get_last_errcode (const char **errstr, int *row, int *col) |
Return last error code. More... | |
void | hpdftbl_get_last_err_file (int *lineno, char **file, char **extrainfo) |
Get the filename and line number where the last error occurred. More... | |
void | hpdftbl_default_table_error_handler (hpdftbl_t t, int r, int c, int err) |
A basic default table error handler. More... | |
int | hpdftbl_apply_theme (hpdftbl_t t, hpdftbl_theme_t *theme) |
Apply a specified theme to a table. More... | |
hpdftbl_theme_t * | hpdftbl_get_default_theme (void) |
Return the default theme. More... | |
int | hpdftbl_get_theme (hpdftbl_t tbl, hpdftbl_theme_t *theme) |
Extract theme from settings of a specific table. More... | |
int | hpdftbl_destroy_theme (hpdftbl_theme_t *theme) |
Destroy existing theme structure and free memory. More... | |
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 font size. The margin is calculated as: More... | |
int | hpdftbl_set_min_rowheight (hpdftbl_t t, float h) |
Set the minimum row height in the table. More... | |
int | hpdftbl_set_colwidth_percent (hpdftbl_t t, size_t c, float w) |
Set column width as percentage of overall table width. More... | |
int | hpdftbl_clear_spanning (hpdftbl_t t) |
Clear all cell spanning. More... | |
int | hpdftbl_set_cellspan (hpdftbl_t t, size_t r, size_t c, size_t rowspan, size_t colspan) |
Set cell spanning. More... | |
int | hpdftbl_set_zebra (hpdftbl_t t, _Bool use, int phase) |
int | hpdftbl_set_zebra_color (hpdftbl_t t, HPDF_RGBColor z1, HPDF_RGBColor z2) |
Specify first and second color for a zebra grid table. More... | |
int | hpdftbl_use_labels (hpdftbl_t t, _Bool use) |
Enable/Disable the use of cell labels. More... | |
int | hpdftbl_use_labelgrid (hpdftbl_t t, _Bool use) |
Shorter vertical line to mark labels. More... | |
int | hpdftbl_set_background (hpdftbl_t t, HPDF_RGBColor background) |
Set table background color. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
int | hpdftbl_set_header_halign (hpdftbl_t t, hpdftbl_text_align_t align) |
Set table header horizontal text align. More... | |
int | hpdftbl_use_header (hpdftbl_t t, _Bool use) |
Enable/disable the interpretation of the top row as a header row. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
int | hpdftbl_set_cell (hpdftbl_t t, size_t r, size_t c, char *label, char *content) |
Set content for specific cell. More... | |
int | hpdftbl_set_tag (hpdftbl_t t, void *tag) |
Set an optional tag for the table. More... | |
int | hpdftbl_set_title (hpdftbl_t t, char *title) |
Set table title. More... | |
int | hpdftbl_set_title_halign (hpdftbl_t t, hpdftbl_text_align_t align) |
Set horizontal alignment for table title. More... | |
int | hpdftbl_set_labels (hpdftbl_t t, char **labels) |
Set the text for the cell labels. More... | |
int | hpdftbl_set_content (hpdftbl_t t, char **content) |
Set the content for the table. More... | |
int | hpdftbl_set_content_cb (hpdftbl_t t, hpdftbl_content_callback_t cb) |
Set table content callback. More... | |
int | hpdftbl_set_cell_content_cb (hpdftbl_t t, size_t r, size_t c, hpdftbl_content_callback_t cb) |
Set cell content callback. More... | |
int | hpdftbl_set_label_cb (hpdftbl_t t, hpdftbl_content_callback_t cb) |
Set table label callback. More... | |
int | hpdftbl_set_cell_label_cb (hpdftbl_t t, size_t r, size_t c, hpdftbl_content_callback_t cb) |
Set cell label callback. More... | |
int | hpdftbl_set_canvas_cb (hpdftbl_t t, hpdftbl_canvas_callback_t cb) |
Set cell canvas callback. More... | |
int | hpdftbl_set_cell_canvas_cb (hpdftbl_t t, size_t r, size_t c, hpdftbl_canvas_callback_t cb) |
Set cell canvas callback. More... | |
int | hpdftbl_set_content_style_cb (hpdftbl_t t, hpdftbl_content_style_callback_t cb) |
Set callback to specify cell content style. More... | |
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. More... | |
int | hpdftbl_set_post_cb (hpdftbl_t t, hpdftbl_callback_t cb) |
Set table post processing callback. More... | |
void | hpdftbl_set_dlhandle (void *) |
Set the handle for scope of dynamic function search. More... | |
int | hpdftbl_set_content_dyncb (hpdftbl_t, const char *) |
Specify dynamic (late) loading callback content function. More... | |
int | hpdftbl_set_canvas_dyncb (hpdftbl_t, const char *) |
Specify dynamic (late) loading callback content function. More... | |
int | hpdftbl_set_cell_content_dyncb (hpdftbl_t, size_t, size_t, const char *) |
Specify dynamic (late) loading callback cell content function. More... | |
int | hpdftbl_set_label_dyncb (hpdftbl_t, const char *) |
Specify dynamic (late) loading callback for table label function. More... | |
int | hpdftbl_set_cell_label_dyncb (hpdftbl_t, size_t, size_t, const char *) |
Specify dynamic (late) loading callback for cell label function. More... | |
int | hpdftbl_set_content_style_dyncb (hpdftbl_t, const char *) |
Specify dynamic (late) loading callback for table style function. More... | |
int | hpdftbl_set_cell_content_style_dyncb (hpdftbl_t, size_t, size_t, const char *) |
Specify dynamic (late) loading callback for cell style function. More... | |
int | hpdftbl_set_cell_canvas_dyncb (hpdftbl_t, size_t, size_t, const char *) |
Specify dynamic (late) loading callback cell canvas function. More... | |
int | hpdftbl_set_post_dyncb (hpdftbl_t t, const char *cb_name) |
Set table post processing callback. More... | |
void | hpdftbl_set_text_encoding (char *target, char *source) |
Determine text source encoding. More... | |
int | hpdftbl_encoding_text_out (HPDF_Page page, HPDF_REAL xpos, HPDF_REAL ypos, char *text) |
Strke text with current encoding. More... | |
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. More... | |
void | hpdftbl_stroke_grid (HPDF_Doc pdf, HPDF_Page page) |
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 frame. Each boxed letter can be in an "on" state or "off" state which is illustrated with different font and fac colors. More... | |
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 boolean value. More... | |
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. More... | |
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. More... | |
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. More... | |
int | hpdftbl_stroke_pdfdoc (HPDF_Doc pdf_doc, char *file) |
Stroke PDF document to file with check that the directory in path exists. More... | |
int | hpdftbl_dump (hpdftbl_t tbl, char *filename) |
Serialize a table structure as a JSON file. More... | |
int | hpdftbl_dumps (hpdftbl_t tbl, char *buff, size_t buffsize) |
Serialize a table structure to a string buffer. More... | |
int | hpdftbl_load (hpdftbl_t tbl, char *filename) |
Import a table structure from a serialized table on file. More... | |
int | hpdftbl_loads (hpdftbl_t tbl, char *buff) |
Import a table structure from a serialized json buffert. More... | |
int | hpdftbl_theme_dump (hpdftbl_theme_t *theme, char *filename) |
Serialize the specified theme structure to a named file. More... | |
int | hpdftbl_theme_dumps (hpdftbl_theme_t *theme, char *buff, size_t buffsize) |
Serialize theme structure to a string buffer. More... | |
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(). More... | |
int | hpdftbl_theme_load (hpdftbl_theme_t *tbl, char *filename) |
Read a theme from a previous serialized theme from a named file. More... | |
size_t | xstrlcat (char *dst, const char *src, size_t siz) |
Safe string concatenation. More... | |
size_t | xstrlcpy (char *__restrict dst, const char *__restrict src, size_t dsize) |
Safe string copy. More... | |
int | hpdftbl_read_file (char *buff, size_t buffsize, char *filename) |
Read content of file into a specified buffer. More... | |
_Bool | chktbl (hpdftbl_t, size_t, size_t) |
Internal function. Check that a row and column are within the table. More... | |
Variables | |
int | hpdftbl_err_code |
Stores the last generated error code. More... | |
int | hpdftbl_err_row |
The row where the last error was generated. More... | |
int | hpdftbl_err_col |
The column where the last error was generated. More... | |
int | hpdftbl_err_lineno |
Hold the line number of the last error occurred. More... | |
char * | hpdftbl_err_file |
Hold the file name where the last error occurred. More... | |
char | hpdftbl_err_extrainfo [] |
Extra info that may be specified at the point of error. More... | |
hpdftbl_error_handler_t | hpdftbl_err_handler |
This stores a pointer to the function acting as the error handler callback. | |
Header file for libhpdftbl.
Copyright (C) 2022 Johan Persson
Released under the MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#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) |
Call the error handler with specified error code and table row, col where error occured.
t | Table handler |
err | Error code |
r | Row where error occured |
c | Column where error occured |
#define _HPDFTBL_SET_ERR_EXTRA | ( | info | ) | do {strncpy(hpdftbl_err_extrainfo,info,1023);hpdftbl_err_extrainfo[1023]=0;} while(0) |
Set optional extra info at error state. (Currently only used by the late binding setting callback functions)
info | Extra info that can be set by a function at a state of error |
#define DEFAULT_AUTO_VBOTTOM_MARGIN_FACTOR 0.5 |
The margin from the bottom of the cell to the baseline of the text is calculated as a fraction of the font size.
The margin is calculated as:
#define HPDF_FF_COURIER "Courier" |
Font family
#define HPDF_FF_COURIER_BOLD "Courier-Bold" |
Font family
#define HPDF_FF_COURIER_BOLDITALIC "Courier-BoldOblique" |
Font family
#define HPDF_FF_COURIER_IALIC "Courier-Oblique" |
Font family
#define HPDF_FF_HELVETICA "Helvetica" |
Font family
#define HPDF_FF_HELVETICA_BOLD "Helvetica-Bold" |
Font family
#define HPDF_FF_HELVETICA_BOLDITALIC "Helvetica-BoldOblique" |
Font family
#define HPDF_FF_HELVETICA_ITALIC "Helvetica-Oblique" |
Font family
#define HPDF_FF_TIMES "Times-Roman" |
Font family
#define HPDF_FF_TIMES_BOLD "Times-Bold" |
Font family
#define HPDF_FF_TIMES_BOLDITALIC "Times-BoldItalic" |
Font family
#define HPDF_FF_TIMES_ITALIC "Times-Italic" |
Font family
#define hpdftbl_cm2dpi | ( | c | ) | (((HPDF_REAL)(c))/2.54*72) |
Convert cm to dots using the default resolution (72 DPI)
c | Measure in cm |
#define TABLE_JSON_VERSION 1 |
Data structure version for serialization of tables
#define THEME_JSON_VERSION 1 |
Data structure version for serialization of themes
typedef struct text_style hpdf_text_style_t |
Specification of a text style.
This structure collects the basic properties for a text string (font, color, background, horizontal alignment)
typedef void(* hpdftbl_callback_t) (hpdftbl_t) |
Callback type for optional post processing when constructing table from a data array.
Type for generic table callback used when constructing a table from data. This can be used to perform any potential table manipulation. The callback happens after the table has been fully constructed and just before it is stroked.
typedef 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.
A canvas callback, if specified, is called for each cell before the content is stroked. The callback will be given the bounding box for the cell (x,y,width,height) in addition to the row and column the cell has.
typedef struct hpdftbl_cell_spec hpdftbl_cell_spec_t |
Used in data driven table creation.
A table can be specified by creating a array of this structure together with the hpdftbl_spec_t structure. The array should have one entry for each cell in the table.
typedef struct hpdftbl_cell hpdftbl_cell_t |
Type definition for the cell structure.
This is an internal structure that represents an individual cell in the table.
typedef char *(* hpdftbl_content_callback_t) (void *, size_t, size_t) |
Type specification for the table content callback.
The content callback is used to specify the textual content in a cell and is an alternative method to specifying the content to be displayed.
typedef _Bool(* hpdftbl_content_style_callback_t) (void *, size_t, size_t, char *content, hpdf_text_style_t *) |
Type specification for the content style.
The content callback is used to specify the textual style in a cell and is an alternative method to specifying the style of content to be displayed.
typedef void(* hpdftbl_error_handler_t) (hpdftbl_t, int, int, int) |
TYpe for error handler function.
The error handler (of set) will be called if the table library descovers an error condition
typedef struct grid_style hpdftbl_grid_style_t |
Specification for table grid lines.
Contains line properties used when stroking a grid line
typedef enum hpdftbl_dashstyle hpdftbl_line_dashstyle_t |
Possible line dash styles for grid lines.
In the illustration of the patterns "x"=solid and "_"=space.
For each pattern we show two full cycles which should give a good visual indication of the different patterns.
typedef struct hpdftbl_spec hpdftbl_spec_t |
Used in data driven table creation.
This is used together with an array of cell specification hpdftbl_cell_spec_t to specify the layout of a table.
Table handle is a pointer to the hpdftbl structure.
This is the basic table handle used in almost all API calls. A table reference is returned when a table is created.
typedef enum hpdftbl_text_align hpdftbl_text_align_t |
Enumeration for horizontal text alignment.
typedef struct hpdftbl_theme hpdftbl_theme_t |
Define a set of styles into a table theme.
Contains all information about the styles of various elements in the table that together make up the table style
enum hpdftbl_dashstyle |
Possible line dash styles for grid lines.
In the illustration of the patterns "x"=solid and "_"=space.
For each pattern we show two full cycles which should give a good visual indication of the different patterns.
enum hpdftbl_text_align |
_Bool chktbl | ( | hpdftbl_t | t, |
size_t | r, | ||
size_t | c | ||
) |
Internal function. Check that a row and column are within the table.
Internal function. Check that a row and column are within the table
t | Table handle |
r | Row |
c | Column |
Referenced by hpdftbl_set_cell(), hpdftbl_set_cell_canvas_cb(), hpdftbl_set_cell_content_cb(), hpdftbl_set_cell_content_style(), hpdftbl_set_cell_content_style_cb(), hpdftbl_set_cell_label_cb(), and hpdftbl_set_cellspan().
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.
Draw a rectangle with rounded corner with the current line width, color. The rectangle will not be stroked.
page | Page handle |
xpos | Lower left x-position of rectangle |
ypos | Lower left y-position of rectangle |
width | Width of rectangle |
height | Height of rectangle |
rad | Radius of corners |
Referenced by hpdftbl_widget_slide_button().
int hpdftbl_apply_theme | ( | hpdftbl_t | t, |
hpdftbl_theme_t * | theme | ||
) |
Apply a specified theme to a table.
Note however that a limitation (by design) of themes is that settings in individual cells are not recorded in a theme since a theme can be applied to any table despite the structure. This mean only settings that are generic to a table is stored in a theme. Not individal cells.
The default table theme can be retrieved with hpdftbl_get_default_theme()
t | Table handle |
theme | Theme reference |
Referenced by hpdftbl_create_title(), and hpdftbl_stroke_from_data().
int hpdftbl_clear_spanning | ( | hpdftbl_t | t | ) |
Clear all cell spanning.
Reset all spanning cells to no spanning
t | Table handle |
hpdftbl_t hpdftbl_create | ( | size_t | rows, |
size_t | cols | ||
) |
Create a new table with no title.
Create a new table structure. This is the basic handler needed for most other API functions.
rows | Number of rows |
cols | Number of columns |
hpdftbl_t hpdftbl_create_title | ( | size_t | rows, |
size_t | cols, | ||
char * | title | ||
) |
Create a new table with title top row.
Create a new table structure. This is the basic handler needed for most other API functions.
rows | Number of rows |
cols | Number of columns |
title | Title of table |
Referenced by hpdftbl_create(), and hpdftbl_stroke_from_data().
void hpdftbl_default_table_error_handler | ( | hpdftbl_t | t, |
int | r, | ||
int | c, | ||
int | err | ||
) |
A basic default table error handler.
This error handler is used as a callback that outputs the error to stderr in human readable format and quits the process.
t | Table where the error happened (can be NULL) |
r | Cell row |
c | Cell column |
err | The error code |
int hpdftbl_destroy | ( | hpdftbl_t | t | ) |
Destroy a table and free all memory.
Destroy a table previous created with table_create(), It is the calling routines responsibility not to acceess t
again.
t | Handle to table |
Referenced by hpdftbl_loads(), and hpdftbl_stroke_from_data().
int hpdftbl_destroy_theme | ( | hpdftbl_theme_t * | theme | ) |
Destroy existing theme structure and free memory.
Free all memory allocated by a theme
theme | The theme to free |
Referenced by hpdftbl_create_title(), and hpdftbl_theme_loads().
int hpdftbl_dump | ( | hpdftbl_t | tbl, |
char * | filename | ||
) |
Serialize a table structure as a JSON file.
The table is serialized as JSON file and have whitespaces and newlines to make it more human readable. The serialization is a complete representation of a table.
tbl | Table handle |
filename | Filename to write to. Any path specified must exists |
int hpdftbl_dumps | ( | hpdftbl_t | tbl, |
char * | buff, | ||
size_t | buffsize | ||
) |
Serialize a table structure to a string buffer.
The table is serialized as JSON and have whitespaces and newlines to make it more human readable. Note is is the callers responsibility to make sure the buffer is large enough to hold the serialized table.
tbl | Table handle of table to dump |
buff | Buffer to dump structure to |
buffsize | Size of buffer |
Referenced by hpdftbl_dump().
int hpdftbl_encoding_text_out | ( | HPDF_Page | page, |
HPDF_REAL | xpos, | ||
HPDF_REAL | ypos, | ||
char * | text | ||
) |
Strke text with current encoding.
Utility function to stroke text with character encoding. It is the calling routines responsibility to enclose text in a HPDF_Page_BeginText() / HPDF_Page_EndText()
page | Page handle |
xpos | X coordinate |
ypos | Y coordinate |
text | Text to print |
_Bool hpdftbl_get_anchor_top_left | ( | hpdftbl_t | tbl | ) |
Get stroking anchor point.
Get anchor point for table positioning. By default the top left is used.
tbl | Table handle |
hpdftbl_theme_t * hpdftbl_get_default_theme | ( | void | ) |
Return the default theme.
Create and return a theme corresponding to the default table theme. It is the calling functions responsibility to call hpdftbl_destroy_theme() to free the allocated memory. The default theme is a good starting point to just make minor modifications without having to define all elements.
Referenced by hpdftbl_create_title().
const char * hpdftbl_get_errstr | ( | int | err | ) |
Translate a table error code to a human readable string.
The function returns a pointer to a static string that cannot be modified. It will translate both internal table error messages as well as generic HPDF library error codes.
err | The error code to be translated |
Referenced by hpdftbl_default_table_error_handler(), and hpdftbl_get_last_errcode().
int hpdftbl_get_last_auto_height | ( | HPDF_REAL * | height | ) |
Get the height calculated for the last constructed table.
Get the last automatically calculated height when stroking a table. (The height will be automatically calculated if it was specified as 0)
height | Returned height |
void hpdftbl_get_last_err_file | ( | int * | lineno, |
char ** | file, | ||
char ** | extrainfo | ||
) |
Get the filename and line number where the last error occurred.
lineno | Set to the line number where the error occurred |
file | Set to the file where the error occurred |
extrainfo | Extra info string that may be set at the point of error |
int hpdftbl_get_last_errcode | ( | const char ** | errstr, |
int * | row, | ||
int * | col | ||
) |
Return last error code.
Return last error code. if errstr is not NULL a human readable string describing the error will be copied to the string. The error code will be reset after call.
errstr | A string buffer where the error string is written to |
row | The row where the error was found |
col | The col where the error was found |
int hpdftbl_get_theme | ( | hpdftbl_t | tbl, |
hpdftbl_theme_t * | theme | ||
) |
Extract theme from settings of a specific table.
This is useful if a table has been specified with some specific look & feel and another table should be given the same l&f.
Note however that a limitation (by design) of themes is that settings in individual cells are not recorded in a theme since a theme can be applied to any table despite the structure. This mean only settings that are generic to a table is stored in a theme. Not individal cells.
tbl | Table handle for table to have its settings extracted |
theme | Theme to be read out to. |
const char * hpdftbl_hpdf_get_errstr | ( | const HPDF_STATUS | err_code | ) |
Function to return a human readable error string for an error code from Core HPDF library.
The various error codes given by the HPDF library can be translated back to a string by the usage of this function. The function will return a pointer to a static string that can not be manipulated.
err_code | The error code |
Referenced by hpdftbl_get_errstr().
int hpdftbl_load | ( | hpdftbl_t | tbl, |
char * | filename | ||
) |
Import a table structure from a serialized table on file.
The json file make it possible to adjust the table directly. However it is easy to get it wrong. Some things to keep in mind while doing manual changes.
After reading a serialized table it can asily be be stroked with only two lines of code as the following code-snippet shows
hpdftbl_t
is a pointer type to struct hpdftbl
and hence must must be either dynamically allocated as the example here shows or an instance of the struct must be created whose address is given to this functions.tbl | Table to read into |
filename | File to read from |
int hpdftbl_loads | ( | hpdftbl_t | tbl, |
char * | buff | ||
) |
Import a table structure from a serialized json buffert.
This is the preferred way on how to store a table structure in for example a database.
Example:
tbl | Reference to table handle to be populated |
buff | Buffer with serialized data to read back |
Referenced by hpdftbl_load().
int hpdftbl_read_file | ( | char * | buff, |
size_t | buffsize, | ||
char * | filename | ||
) |
Read content of file into a specified buffer.
buff | Destination buffer |
buffsize | Size of buffer |
filename | Name of file to read from |
Referenced by hpdftbl_load(), and hpdftbl_theme_load().
void hpdftbl_set_anchor_top_left | ( | hpdftbl_t | tbl, |
const _Bool | anchor | ||
) |
Switch stroking anchor point.
Set anchor point for table positioning. By default the top left is used as anchor. Calling this function with FALSE can sets the anchor to bottom left instead.
tbl | Table handle |
anchor | Set to TRUE to use top left as anchor, FALSE for bottom left |
int hpdftbl_set_background | ( | hpdftbl_t | t, |
HPDF_RGBColor | background | ||
) |
Set table background color.
t | Table handle |
background | Background color |
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 font size. The margin is calculated as:
The default margin is specified by the define DEFAULT_AUTO_VBOTTOM_MARGIN_FACTOR
t | Table handle |
f | Bottom margin factor |
Referenced by hpdftbl_apply_theme().
int hpdftbl_set_canvas_cb | ( | hpdftbl_t | t, |
hpdftbl_canvas_callback_t | cb | ||
) |
Set cell canvas callback.
Set cell canvas callback. This callback gets called for each cell in the table. The purpose is to allow the client to add dynamic content to the specified cell. The callback is made before the cell border and content is drawn making it possible to for example add a background color to individual cells. The callback function will receive the Table tag, the row and column, the x, y position of the lower left corner of the table and the width and height of the cell. To set the canvas callback only for a specific cell use the hpdftbl_set_cell_canvas_cb() function
t | Table handle |
cb | Callback function |
Referenced by hpdftbl_set_canvas_dyncb().
int hpdftbl_set_canvas_dyncb | ( | hpdftbl_t | t, |
const char * | cb_name | ||
) |
Specify dynamic (late) loading callback content function.
The dynamic loading of callback function is a runtime binding of the named function as a callback. The library uses the dlsym() loading of external symbols. For the external symbol to be found it can not be defined as a static
symbol.
In case of error the extrainfo
extra information is set to the name of the callback which failed to be resolved at run time. This can be retrieved in an error handler by using the hpdftbl_get_last_err_file() to read it back.
t | Table handle |
cb_name | Name of the function to be used as canvas callback. This function must follow the signature of a callback function as specified in hpdftbl_canvas_callback_t. |
int hpdftbl_set_cell | ( | hpdftbl_t | t, |
size_t | r, | ||
size_t | c, | ||
char * | label, | ||
char * | content | ||
) |
Set content for specific cell.
Set label and content for a specific cell. If the specified cell is part of another cells spanning an error occurs (returns -1),
t | Table handle |
r | Row |
c | Column |
label | Label |
content | Text content |
Referenced by hpdftbl_stroke_from_data().
int hpdftbl_set_cell_canvas_cb | ( | hpdftbl_t | t, |
size_t | r, | ||
size_t | c, | ||
hpdftbl_canvas_callback_t | cb | ||
) |
Set cell canvas callback.
Set a canvas callback for an individual cell. This will override the table canvas callback. The canvas callback is called with arguments that give the bounding box for the cell. In that way a callback function may draw arbitrary graphic in the cell. The callback is made before the cell border and content is drawn making it possible to for example add a background color to individual cells. The callback function will receive the Table tag, the row and column, the x, y position of the lower left corner of the table and the width and height of the cell.
t | Table handle |
r | Cell row |
c | Cell column |
cb | Callback function |
Referenced by hpdftbl_set_cell_canvas_dyncb(), and hpdftbl_stroke_from_data().
int hpdftbl_set_cell_canvas_dyncb | ( | hpdftbl_t | t, |
size_t | r, | ||
size_t | c, | ||
const char * | cb_name | ||
) |
Specify dynamic (late) loading callback cell canvas function.
In case of error the extrainfo
extra information is set to the name of the callback which failed to be resolved at run time. This can be retrieved in an error handler by using the hpdftbl_get_last_err_file() to read it back.
t | Table handle |
r | Celll row |
c | Cell column |
cb_name | Name of the function to be used as canvas callback. This function must follow the signature of a callback function as specified in hpdftbl_canvas_callback_t |
int hpdftbl_set_cell_content_cb | ( | hpdftbl_t | t, |
size_t | r, | ||
size_t | c, | ||
hpdftbl_content_callback_t | cb | ||
) |
Set cell content callback.
Set a content callback for an individual cell. This will override the table content callback. The callback function will receive the Table tag and the row and column for the cell the callback is made for.
t | Table handle |
cb | Callback function |
r | Cell row |
c | Cell column |
Referenced by hpdftbl_set_cell_content_dyncb(), and hpdftbl_stroke_from_data().
int hpdftbl_set_cell_content_dyncb | ( | hpdftbl_t | t, |
size_t | r, | ||
size_t | c, | ||
const char * | cb_name | ||
) |
Specify dynamic (late) loading callback cell content function.
The dynamic loading of callback function is a runtime binding of the named function as a callback. The library uses the dlsym() loading of external symbols. For the external symbol to be found it can not be defined as a static
symbol.
In case of error the extrainfo
extra information is set to the name of the callback which failed to be resolved at run time. This can be retrieved in an error handler by using the hpdftbl_get_last_err_file() to read it back.
t | Table handle |
r | Cell row |
c | Cell column |
cb_name | Name of the function to be used as content callback. This function must follow the signature of a callback function as specified in hpdftbl_content_callback_t. |
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.
SSet the font style for content of specified cell. This will override the global cell content setting.
t | Table handle |
r | Cell row |
c | Cell column |
font | Font name |
fsize | Font size |
color | Color |
background | Background color |
Referenced by hpdftbl_set_col_content_style(), and hpdftbl_set_row_content_style().
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.
Set callback to format the style for the specified cell
t | Table handle |
r | Cell row |
c | Cell column |
cb | Callback function |
Referenced by hpdftbl_set_cell_content_style_dyncb(), and hpdftbl_stroke_from_data().
int hpdftbl_set_cell_content_style_dyncb | ( | hpdftbl_t | t, |
size_t | r, | ||
size_t | c, | ||
const char * | cb_name | ||
) |
Specify dynamic (late) loading callback for cell style function.
The dynamic loading of callback function is a runtime binding of the named function as a callback. The library uses the dlsym() loading of external symbols. For the external symbol to be found it can not be defined as a static
symbol. The callback function must have the signature defined by hpdftbl_content_style_callback_t
In case of error the extrainfo
extra information is set to the name of the callback which failed to be resolved at run time. This can be retrieved in an error handler by using the hpdftbl_get_last_err_file() to read it back.
t | Table handle |
r | Cell row |
c | Cell column |
cb_name | Name of the function to be used as label callback. This function must follow the signature of a callback function as specified in hpdftbl_content_style_callback_t. |
int hpdftbl_set_cell_label_cb | ( | hpdftbl_t | t, |
size_t | r, | ||
size_t | c, | ||
hpdftbl_content_callback_t | cb | ||
) |
Set cell label callback.
Set a label callback for an individual cell. This will override the table label callback. The callback function will receive the Table tag and the row and column for the cell the callback is made for.
t | Table handle |
cb | Callback function |
r | Cell row |
c | Cell column |
Referenced by hpdftbl_set_cell_label_dyncb(), and hpdftbl_stroke_from_data().
int hpdftbl_set_cell_label_dyncb | ( | hpdftbl_t | t, |
size_t | r, | ||
size_t | c, | ||
const char * | cb_name | ||
) |
Specify dynamic (late) loading callback for cell label function.
The dynamic loading of callback function is a runtime binding of the named function as a callback. The library uses the dlsym() loading of external symbols. For the external symbol to be found it can not be defined as a static
symbol. The callback function must have the signature defined by hpdftbl_content_callback_t
In case of error the extrainfo
extra information is set to the name of the callback which failed to be resolved at run time. This can be retrieved in an error handler by using the hpdftbl_get_last_err_file() to read it back.
t | Table handle |
r | Cell row |
c | Cell column |
cb_name | Name of the function to be used as label callback. This function must follow the signature of a callback function as specified in hpdftbl_content_callback_t. |
int hpdftbl_set_cellspan | ( | hpdftbl_t | t, |
size_t | r, | ||
size_t | c, | ||
size_t | rowspan, | ||
size_t | colspan | ||
) |
Set cell spanning.
Set row and column spanning for a cell, an expanded cell is referenced via the position of it's top-left cell
t | Table handle |
r | Row |
c | Column |
rowspan | Row span |
colspan | Column span |
Referenced by hpdftbl_stroke_from_data().
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.
Set font options for the specified column of cells. This will override the global cell content setting.
t | Table handle |
c | Column to affect |
font | Font name |
fsize | Font size |
color | Color |
background | Background color |
int hpdftbl_set_colwidth_percent | ( | hpdftbl_t | t, |
size_t | c, | ||
float | w | ||
) |
Set column width as percentage of overall table width.
Specify column width as percentage of total column width. Note that this will only take effect if the table has an overall width specified when stroked. Too avoid errors one column should be left unspecified to let the library use whatever space is left for that column.
t | Table handle |
c | Column to set width of first column has index 0 |
w | Width as percentage in range [0.0, 100.0] |
int hpdftbl_set_content | ( | hpdftbl_t | t, |
char ** | content | ||
) |
Set the content for the table.
Set content for all cells. It is the calling functions responsibility that the content array is big enough to cover the entire table. The string array corresponds to a flattened 2-d array and the label for cell (r,c) is calculated as (r * num_cols + c) where num_cols is the number of columns in the table.
It is allowed to specify NULL as placeholder for empty labels. The actual text in the table will be allocated with strdup() so it is safe to free the memory for the labels after the call to this function. Please note that even if the table contains spanning cells the content data must include empty data for covered cells. For a N x M table the data must have (N*M) entries.
Another way to specify the content is to use the callback mechanism. By setting up a content callback function that returns the content for a cell.
t | Table handle |
content | A one dimensional string array of content string |
int hpdftbl_set_content_cb | ( | hpdftbl_t | t, |
hpdftbl_content_callback_t | cb | ||
) |
Set table content callback.
This callback gets called for each cell in the table and the returned string will be used as the content. The string will be duplicated so it is safe for a client to reuse the string space. If NULL is returned from the callback then the content will be set to the content specified with the direct content setting. The callback function will receive the Table tag and the row and column for the cell the callback is made for.
t | Table handle |
cb | Callback function |
Referenced by hpdftbl_set_content_dyncb(), and hpdftbl_stroke_from_data().
int hpdftbl_set_content_dyncb | ( | hpdftbl_t | t, |
const char * | cb_name | ||
) |
Specify dynamic (late) loading callback content function.
The dynamic loading of callback function is a runtime binding of the named function as a callback. The library uses the dlsym() loading of external symbols. For the external symbol to be found it can not be defined as a static
symbol.
In case of error the extrainfo
extra information is set to the name of the callback which failed to be resolved at run time. This can be retrieved in an error handler by using the hpdftbl_get_last_err_file() to read it back.
t | Table handle |
cb_name | Name of the function to be used as content callback. This function must follow the signature of a callback function as specified in hpdftbl_content_callback_t. |
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.
Set style options for cell content (font, color, background). This will be applied for all cells in the table. If a style callback have been specified for either the table or a cell that style take precedence.
t | Table handle |
font | Font name |
fsize | Font size |
color | Color |
background | Background color |
Referenced by hpdftbl_apply_theme().
int hpdftbl_set_content_style_cb | ( | hpdftbl_t | t, |
hpdftbl_content_style_callback_t | cb | ||
) |
Set callback to specify cell content style.
Set callback to format the style for cells in the table. If a cell has its own content style callback that callback will override the generic table callback.
t | Table handle |
cb | Callback function |
Referenced by hpdftbl_set_content_style_dyncb(), and hpdftbl_stroke_from_data().
int hpdftbl_set_content_style_dyncb | ( | hpdftbl_t | t, |
const char * | cb_name | ||
) |
Specify dynamic (late) loading callback for table style function.
The dynamic loading of callback function is a runtime binding of the named function as a callback. The library uses the dlsym() loading of external symbols. For the external symbol to be found it can not be defined as a static
symbol. The callback function must have the signature defined by hpdftbl_content_style_callback_t
In case of error the extrainfo
extra information is set to the name of the callback which failed to be resolved at run time. This can be retrieved in an error handler by using the hpdftbl_get_last_err_file() to read it back.
t | Table handle |
cb_name | Name of the function to be used as label callback. This function must follow the signature of a callback function as specified in hpdftbl_content_style_callback_t. |
void hpdftbl_set_dlhandle | ( | void * | handle | ) |
Set the handle for scope of dynamic function search.
When using late binding (some os _dyncb() functions) the scope for where the runtime searches for the functions can be specified as is discussed in man 3 dlsym
. By default the library uses dl_handle which make the library first searches the current image and then all images it was built against.
If the dynamic callbacks are located in a runtime loaded library then the handle returned by dlopen() must be specified as the function will not be found otherwise.
handle | Predefined values or the handle returned by dlopen() (see man dlopen) |
hpdftbl_error_handler_t hpdftbl_set_errhandler | ( | hpdftbl_error_handler_t | err_handler | ) |
Specify errhandler for the table routines.
Note: The library provides a basic default error handler that can be used,
err_handler |
int hpdftbl_set_header_halign | ( | hpdftbl_t | t, |
hpdftbl_text_align_t | align | ||
) |
Set table header horizontal text align.
t | Table handle |
align | Alignment |
Referenced by hpdftbl_apply_theme().
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.
Set the font properties and background for the header row which is the top row if enabled. The header row will be automatically enabled after calling this function. The header can be enabled/disabled separately with hpdftbl_use_header()
t | Table handle |
font | Font name |
fsize | Font size |
color | Font color |
background | Cell background color |
Referenced by hpdftbl_apply_theme().
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.
This is a shortform to set both the vertical and horizontal gridline style with one call.
t | Table handle |
width | Line width (in pt) |
color | Line color |
dashstyle | Line dash style |
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.
t | Table handle |
width | Line width (in pt) |
color | Line color |
dashstyle | Line dash style |
Referenced by hpdftbl_apply_theme(), and hpdftbl_set_inner_grid_style().
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.
This would be the gridline just below the header row.
t | Table handle |
width | Line width (in pt) |
color | Line color |
dashstyle | Line dash style |
Referenced by hpdftbl_apply_theme().
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.
t | Table handle |
width | Line width (in pt) |
color | Line color |
dashstyle | Line dash style |
Referenced by hpdftbl_apply_theme(), and hpdftbl_set_inner_grid_style().
int hpdftbl_set_label_cb | ( | hpdftbl_t | t, |
hpdftbl_content_callback_t | cb | ||
) |
Set table label callback.
Set label callback. This callback gets called for each cell in the table and the returned string will be used as the label. The string will be duplicated so it is safe for a client to reuse the string space. If NULL is returned from the callback then the label will be set to the content specified with the direct label setting. The callback function will receive the Table tag and the row and column
t | Table handle |
cb | Callback function |
Referenced by hpdftbl_set_label_dyncb(), and hpdftbl_stroke_from_data().
int hpdftbl_set_label_dyncb | ( | hpdftbl_t | t, |
const char * | cb_name | ||
) |
Specify dynamic (late) loading callback for table label function.
The dynamic loading of callback function is a runtime binding of the named function as a callback. The library uses the dlsym() loading of external symbols. For the external symbol to be found it can not be defined as a static
symbol. symbols. The callback function must have the signature defined by hpdftbl_content_callback_t
In case of error the extrainfo
extra information is set to the name of the callback which failed to be resolved at run time. This can be retrieved in an error handler by using the hpdftbl_get_last_err_file() to read it back.
t | Table handle |
cb_name | Name of the function to be used as label callback. This function must follow the signature of a callback function as specified in hpdftbl_content_callback_t. |
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.
Set font, color and background options for cell labels. If a style callback have been specified for either the table or a cell that style take precedence.
t | Table handle |
font | Font name |
fsize | Font size |
color | Color |
background | Background color |
Referenced by hpdftbl_apply_theme().
int hpdftbl_set_labels | ( | hpdftbl_t | t, |
char ** | labels | ||
) |
Set the text for the cell labels.
Set labels for all the cell. It is the calling functions responsibility that the labels array is big enough to cover the entire table. The string array corresponds to a flattened 2-d array and the label for cell (r,c) is calculated as (r * num_cols + c) where num_cols is the number of columns in the table.
It is allowed to specify NULL as placeholder for empty labels. The actual text in the table will be allocated with strdup() so it is safe to free the memory for the labels after the call to this function. Please note that even if the table contains spanning cells the content data must include empty data for covered cells. For a N x M table the data must have (N*M) entries.
t | Table handle |
labels | A one dimensional string array of labels |
int hpdftbl_set_min_rowheight | ( | hpdftbl_t | t, |
float | h | ||
) |
Set the minimum row height in the table.
The row height is normally calculated based on the font size and if labels are displayed or not. However, it is not possible for the table to know the height of specific widgets (for example) without a two-pass table drawing algorithm.
To handle thos odd cases when the calculated height is not sufficient a manual minimum height can be specified.
t | Table handler |
h | The minimum height (in points). If specified as 0 the min height will have no effect. |
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.
t | Table handle |
width | Line width (in pt) |
color | Line color |
dashstyle | Line dash style |
Referenced by hpdftbl_apply_theme().
int hpdftbl_set_post_cb | ( | hpdftbl_t | t, |
hpdftbl_callback_t | cb | ||
) |
Set table post processing callback.
This is an optional post processing callback for anything in general to do after the table has been constructed. The callback happens after the table has been fully constructed and just before it is stroked.
t | Table handle |
cb | Callback function |
Referenced by hpdftbl_set_post_dyncb().
int hpdftbl_set_post_dyncb | ( | hpdftbl_t | t, |
const char * | cb_name | ||
) |
Set table post processing callback.
This is an optional post processing callback for anything in general to do after the table has been constructed. The callback only gets the table as its first and only argument. The callback happens after the table has been fully constructed and just before it is stroked.
t | Table handle |
cb_name | Callback function name |
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.
Set font options for the specified row of cells. This will override the global cell content.
t | Table handle |
r | Row to affect |
font | Font name |
fsize | Font size |
color | Color |
background | Background color |
int hpdftbl_set_tag | ( | hpdftbl_t | t, |
void * | tag | ||
) |
Set an optional tag for the table.
Set an optional tag in the table. The tag can be a pointer to anything. The tag is passed as the first argument in the various callbacks and can be used to supply table specific information or identify a specific table in the case the same callback is used for multiple tables.
t | The table handle |
tag | The tag (pointer to any object) |
void hpdftbl_set_text_encoding | ( | char * | target, |
char * | source | ||
) |
Determine text source encoding.
The default HPDF encoding is a standard PDF encoding. The problem with that is that now almost 100% of all code is written in UTF-8 encoding and trying to print text strings with accented characters will simply not work. For example the default encoding assumes that strings are given in UTF-8 and sets the target to ISO8859-4 which includes northern europe accented characters. The conversion is internally handled by the standard iconv() routines.
target | The target encoding. See HPDF documentation for supported encodings. |
source | The source encodings, i.e. what encodings are sth strings in the source specified in. |
int hpdftbl_set_title | ( | hpdftbl_t | t, |
char * | title | ||
) |
Set table title.
Set table title. A title will occupy a separate row above the table that is not included in the row count. A table is enabled when the table text is <> NULL and disabled when the title text is == NULL.
t | Table handle |
title | Title string |
int hpdftbl_set_title_halign | ( | hpdftbl_t | t, |
hpdftbl_text_align_t | align | ||
) |
Set horizontal alignment for table title.
t | Table handle |
align | Alignment |
Referenced by hpdftbl_apply_theme().
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.
Set font options for title
t | Table handle |
font | Font name |
fsize | Font size |
color | Color |
background | Background color |
Referenced by hpdftbl_apply_theme().
int hpdftbl_set_zebra | ( | hpdftbl_t | t, |
_Bool | use, | ||
int | phase | ||
) |
t | Table handle |
use | TRUE=Use Zebra, FALSE=Don't use zebra |
phase | 0=Start with color 1, 1=Start with color 1 |
Referenced by hpdftbl_apply_theme().
int hpdftbl_set_zebra_color | ( | hpdftbl_t | t, |
HPDF_RGBColor | z1, | ||
HPDF_RGBColor | z2 | ||
) |
Specify first and second color for a zebra grid table.
By default the colors start with z1
color. To have the top row (below any potential header row) instead start with z2 specify phase=1
in the hpdftbl_set_zebra() function.
t | Table handle |
z1 | Color 1 |
z2 | Color 2 |
Referenced by hpdftbl_apply_theme().
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.
The position is by default specified as the upper left corner of the table. Use the hpdftbl_set_origin_top_left() to use the bottom left of the table as reference point.
Ths standard stroke function hpdftbl_stroke() also take the size and position as argument for ease of use but the hpdftbl_stroke_pos() do assume that the table has it's size set.
t | Table handle |
xpos | x position for table |
ypos | y position for table |
width | width of table |
height | height of table. If the height is specified as 0 it will be automatically calculated. The calculated height can be retrieved after the table has been stroked by a call to hpdftbl_get_last_auto_height() |
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.
Stroke the table at the specified position and size. The position is by default specified as the upper left corner of the table. Use the hpdftbl_set_origin_top_left(FALSE) to use the bottom left of the table as reference point.
The HPDF document handle | |
page | The HPDF page handle |
t | Table handle |
xpos | x position for table |
ypos | y position for table |
width | width of table |
height | height of table. If the height is specified as 0 it will be automatically calculated. The calculated height can be retrieved after the table has been stroked by a call to hpdftbl_get_last_auto_height() |
Referenced by hpdftbl_stroke_from_data(), and hpdftbl_stroke_pos().
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.
Create and stroke a table specified by a data structure. This makes it easier to separate the view of the data from the model which provides the data. The intended use case is that the data structure specifies the core layout of the table together with the labels and callback functions to handle the content in each cell. Using this method to create a table also makes it much more maintainable.
pdf_doc | The PDF overall document |
pdf_page | The pageto stroke to |
tbl_spec | The table specification |
theme | Table theme to be applied |
void hpdftbl_stroke_grid | ( | HPDF_Doc | pdf, |
HPDF_Page | page | ||
) |
Stroke a point grid on specified page to make it easier to position text and tables.
Document handle | |
page | Page handle |
Referenced by setup_hpdf().
int hpdftbl_stroke_pdfdoc | ( | HPDF_Doc | pdf_doc, |
char * | file | ||
) |
Stroke PDF document to file with check that the directory in path exists.
Note: It is a checked error if the full path is longer than 1014 characters
pdf_doc | Haru PDF document handle |
file | Full pathname of file to write to |
Referenced by stroke_to_file().
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.
Stroke the table at the specified position and size. The position is by default specified as the upper left corner of the table. Use the hpdftbl_set_origin_top_left(FALSE) to use the bottom left of the table as reference point.
This is a convenient method to use when stroking a serialized table as the table already holds the size and position. Stroking a table read back ccan be done with just two lines of code
The HPDF document handle | |
page | The HPDF page handle |
t | Table handle |
void hpdftbl_table_widget_letter_buttons | ( | HPDF_Doc | doc, |
HPDF_Page | page, | ||
HPDF_REAL | xpos, | ||
HPDF_REAL | ypos, | ||
HPDF_REAL | width, | ||
HPDF_REAL | height, | ||
const HPDF_RGBColor | on_color, | ||
const HPDF_RGBColor | off_color, | ||
const HPDF_RGBColor | on_background, | ||
const HPDF_RGBColor | off_background, | ||
const 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 frame. Each boxed letter can be in an "on" state or "off" state which is illustrated with different font and fac colors.
doc | HPDF document handle |
page | HPDF page handle |
xpos | X-öosition of cell |
ypos | Y-Position of cell |
width | Width of cell |
height | Height of cell |
on_color | The font color in "on" state |
off_color | The font color in "off" state |
on_background | The face color in "on" state |
off_background | The face color in "off" state |
fsize | The font size |
letters | What letters to have in the boxes |
state | What state each boxed letter should be (0=off, 1=pn) |
int hpdftbl_theme_dump | ( | hpdftbl_theme_t * | theme, |
char * | filename | ||
) |
Serialize the specified theme structure to a named file.
The theme is serialized as JSON string array and have whitespaces and newlines to make it more human readable.
theme | Pointer to theme structure to be serialized |
filename | Filename to write to |
int hpdftbl_theme_dumps | ( | hpdftbl_theme_t * | theme, |
char * | buff, | ||
const size_t | buffsize | ||
) |
Serialize theme structure to a string buffer.
The theme is serialized as JSON string array and have whitespaces and newlines to make it more human readable.
theme | Theme to serialize |
buff | Buffer to write serialized theme to. It should be a minimum of 2k chars. |
buffsize | Buffer size (including ending string NULL) |
Referenced by hpdftbl_theme_dump().
int hpdftbl_theme_load | ( | hpdftbl_theme_t * | theme, |
char * | filename | ||
) |
Read a theme from a previous serialized theme from a named file.
Example:
theme | Theme to read into |
filename | File to read from |
int hpdftbl_theme_loads | ( | hpdftbl_theme_t * | theme, |
char * | buff | ||
) |
Load theme from a serialized string. This is the invert function of hpdftbl_theme_dumps().
theme | Theme to load to. |
buff | Buffer which holds the previous serialized theme |
Referenced by hpdftbl_theme_load().
int hpdftbl_use_header | ( | hpdftbl_t | t, |
_Bool | use | ||
) |
Enable/disable the interpretation of the top row as a header row.
A header row will have a different style and labels will be disabled on this row. In addition the text will be centered vertically and horizontal in the cell.
t | Table handle |
use | TRUE to enable, FALSE to disable |
Referenced by hpdftbl_stroke_from_data().
int hpdftbl_use_labelgrid | ( | hpdftbl_t | t, |
_Bool | use | ||
) |
Shorter vertical line to mark labels.
Set the usage of special grid style where the vertical grid only covers the label text and a gap to the next line. Horizontal lines are drawn as usual. The label grid style gives the table a "lighter" look.
t | Table handle |
use | TRUE to use label grid, FALSE o disable it |
Referenced by hpdftbl_stroke_from_data().
int hpdftbl_use_labels | ( | hpdftbl_t | t, |
_Bool | use | ||
) |
Enable/Disable the use of cell labels.
By default a newly created table will not use cell labels. Enabling labels will also by default enable the special label grid style. To adjust the grid style separately us the hpdftbl_use_labelgrid() method.
t | Table handle |
use | Set to TRUE for cell labels |
Referenced by hpdftbl_stroke_from_data().
void hpdftbl_widget_hbar | ( | const HPDF_Doc | doc, |
const HPDF_Page | page, | ||
const HPDF_REAL | xpos, | ||
const HPDF_REAL | ypos, | ||
const HPDF_REAL | width, | ||
const HPDF_REAL | height, | ||
const HPDF_RGBColor | color, | ||
const float | val, | ||
const _Bool | hide_val | ||
) |
Draw a horizontal partially filled bar to indicate an analog (percentage) value.
This function can not be used directly as a canvas callback since it needs additional parameters. Instead create a simple canvas callback that gives the additional parameters.
doc | HPDF Document handle |
page | HPDF Page handle |
xpos | Lower left x |
ypos | Lower left y |
width | Width of meter |
height | Height of meter |
color | Fill color for bar |
val | Percentage fill in range [0.0, 100.0] |
hide_val | TRUE to hide the value (in percent) at the right end of the entire bar |
void hpdftbl_widget_segment_hbar | ( | const HPDF_Doc | doc, |
const HPDF_Page | page, | ||
const HPDF_REAL | xpos, | ||
const HPDF_REAL | ypos, | ||
const HPDF_REAL | width, | ||
const HPDF_REAL | height, | ||
const size_t | num_segments, | ||
const HPDF_RGBColor | on_color, | ||
const double | val_percent, | ||
const _Bool | hide_val | ||
) |
Draw a horizontal segment meter that can be used to visualize a discrete value.
This function can not be used directly as a canvas callback since it needs additional parameters. Instead create a simple canvas callback that gives the additional parameters.
doc | HPDF Document handle |
page | HPDF Page handle |
xpos | Lower left x |
ypos | Lower left y |
width | Width of meter |
height | Height of meter |
num_segments | Total number of segments |
on_color | Color for "on" segment |
val_percent | To what extent should the bars be filled (as a value 0.0 - 1.0) |
hide_val | TRUE to hide the value (in percent) at the right end of the entire bar |
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 boolean value.
This function can not be used directly as a canvas callback since it needs the state of the button as an argument. Instead create a simple canvas callback that determines the wanted state and then just passes on all argument to this widget function.
doc | HPDF document handle |
page | HPDF page handle |
xpos | X-öosition of cell |
ypos | Y-Position of cell |
width | Width of cell |
height | Height of cell |
state | State of button On/Off |
void hpdftbl_widget_strength_meter | ( | const HPDF_Doc | doc, |
const HPDF_Page | page, | ||
const HPDF_REAL | xpos, | ||
const HPDF_REAL | ypos, | ||
const HPDF_REAL | width, | ||
const HPDF_REAL | height, | ||
const size_t | num_segments, | ||
const HPDF_RGBColor | on_color, | ||
const size_t | num_on_segments | ||
) |
Draw a phone strength meter.
This function can not be used directly as a canvas callback since it needs additional parameters. Instead create a simple canvas callback that gives the additional parameters.
doc | HPDF Document handle |
page | HPDF Page handle |
xpos | Lower left x |
ypos | Lower left y |
width | Width of meter |
height | Height of meter |
num_segments | Total number of segments |
on_color | Color for "on" segment |
num_on_segments | Number of on segments |
size_t xstrlcat | ( | char * | dst, |
const char * | src, | ||
size_t | siz | ||
) |
Safe string concatenation.
Appends src to string dst of size siz (unlike strncat, siz is the full size of dst, not space left). At most siz-1 characters will be copied. Always NUL terminates (unless siz <= strlen(dst)). Returns strlen(src) + MIN(siz, strlen(initial dst)). If retval >= siz, truncation occurred.
Taken from BSD library.
dst | Destination buffer |
src | Source buffer |
siz | Max size of destination buffer including terminating NULL |
siz
then data truncation happened. Referenced by hpdftbl_read_file(), and mkfullpath().
size_t xstrlcpy | ( | char *__restrict | dst, |
const char *__restrict | src, | ||
size_t | dsize | ||
) |
Safe string copy.
Copy string src to buffer dst of size dsize. At most dsize-1 chars will be copied. Always NUL terminates (unless dsize == 0). Returns strlen(src); if retval >= dsize, truncation occurred.
Taken from BSD library.
dst | Destination string |
src | Source string |
dsize | Maximum size of destination |
|
extern |
Stores the last generated error code.
Internal variable to record last error
Referenced by hpdftbl_get_errstr(), and hpdftbl_get_last_errcode().
|
extern |
The column where the last error was generated.
Internal variable to record last error
Referenced by hpdftbl_get_last_errcode().
|
extern |
Extra info that may be specified at the point of error.
Internal variable to record last error
Referenced by hpdftbl_get_last_err_file().
|
extern |
Hold the file name where the last error occurred.
Internal variable to record last error
Referenced by hpdftbl_get_last_err_file().
|
extern |
Hold the line number of the last error occurred.
Internal variable to record last error
Referenced by hpdftbl_get_last_err_file().
|
extern |
The row where the last error was generated.
Internal variable to record last error
Referenced by hpdftbl_get_last_errcode().