libhpdftbl 1.5.0
Table construction library for Haru PDF library
|
Routines for plain and dynamic callback function. More...
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <iconv.h>
#include <hpdf.h>
#include <libgen.h>
#include <sys/stat.h>
#include <dlfcn.h>
#include "hpdftbl.h"
Functions | |
void | hpdftbl_set_dlhandle (void *handle) |
Set the handle for scope of dynamic function search. 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_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_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_label_cb (hpdftbl_t t, hpdftbl_content_callback_t cb) |
Set table label callback. More... | |
int | hpdftbl_set_post_cb (hpdftbl_t t, hpdftbl_callback_t cb) |
Set table post processing callback. More... | |
int | hpdftbl_set_canvas_cb (hpdftbl_t t, hpdftbl_canvas_callback_t cb) |
Set cell canvas callback. More... | |
int | hpdftbl_set_content_dyncb (hpdftbl_t t, const char *cb_name) |
Specify dynamic (late) loading callback content function. More... | |
int | hpdftbl_set_canvas_dyncb (hpdftbl_t t, const char *cb_name) |
Specify dynamic (late) loading callback content function. More... | |
int | hpdftbl_set_label_dyncb (hpdftbl_t t, const char *cb_name) |
Specify dynamic (late) loading callback for table label function. More... | |
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. More... | |
int | hpdftbl_set_content_style_dyncb (hpdftbl_t t, const char *cb_name) |
Specify dynamic (late) loading callback for table style function. More... | |
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. More... | |
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. More... | |
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. More... | |
int | hpdftbl_set_post_dyncb (hpdftbl_t t, const char *cb_name) |
Set table post processing callback. 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_content_style_cb (hpdftbl_t t, hpdftbl_content_style_callback_t cb) |
Set callback to specify cell content style. More... | |
Routines for plain and dynamic callback function.
All functions ending with _cb
are used to specify standard callback functions which stores a function pointer bounded at compile time. All functions ending i _dyncb
are used to set dynamic callback functions which are bound at run time. The function name are stored as string and resolved at runtime.
Copyright (C) 2022 Johan Persson
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_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_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_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_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) |
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_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 |