Provides C bindings for pdf conversion. More...
#include <wkhtmltox/dllbegin.inc>Go to the source code of this file.
Typedefs | |
|
typedef struct wkhtmltopdf_global_settings | wkhtmltopdf_global_settings |
|
typedef struct wkhtmltopdf_object_settings | wkhtmltopdf_object_settings |
|
typedef struct wkhtmltopdf_converter | wkhtmltopdf_converter |
| typedef void(* | wkhtmltopdf_str_callback )(wkhtmltopdf_converter *converter, const char *str) |
| Function pointer type used for the error and warning callbacks. | |
| typedef void(* | wkhtmltopdf_int_callback )(wkhtmltopdf_converter *converter, const int val) |
| Function pointer type used for the progress_changed and finished callbacks. | |
| typedef void(* | wkhtmltopdf_void_callback )(wkhtmltopdf_converter *converter) |
| Function pointer type used for the phase_changed callback. | |
Functions | |
| CAPI int | wkhtmltopdf_init (int use_graphics) |
| Setup wkhtmltopdf. | |
| CAPI int | wkhtmltopdf_deinit () |
| Deinit wkhtmltopdf. | |
| CAPI int | wkhtmltopdf_extended_qt () |
| Check if the library is build against the wkhtmltopdf version of QT. | |
| CAPI const char * | wkhtmltopdf_version () |
| Return the version of wkhtmltopdf Example: 0.10.0_beta4. The string is utf8 encoded and is owned by wkhtmltopdf. | |
| CAPI wkhtmltopdf_global_settings * | wkhtmltopdf_create_global_settings () |
| Create a new global settings object for pdf conversion. | |
| CAPI wkhtmltopdf_object_settings * | wkhtmltopdf_create_object_settings () |
| Create an object used to store object settings. | |
| CAPI int | wkhtmltopdf_set_global_setting (wkhtmltopdf_global_settings *settings, const char *name, const char *value) |
| Alter a setting in a global settings object. | |
| CAPI int | wkhtmltopdf_get_global_setting (wkhtmltopdf_global_settings *settings, const char *name, char *value, int vs) |
| Retrieve a setting in a global settings object. | |
| CAPI int | wkhtmltopdf_set_object_setting (wkhtmltopdf_object_settings *settings, const char *name, const char *value) |
| Alter a setting in a object settings object. | |
| CAPI int | wkhtmltopdf_get_object_setting (wkhtmltopdf_object_settings *settings, const char *name, char *value, int vs) |
| Retrieve a setting in a global settings object. | |
| CAPI wkhtmltopdf_converter * | wkhtmltopdf_create_converter (wkhtmltopdf_global_settings *settings) |
| Create a wkhtmltopdf converter object. | |
| CAPI void | wkhtmltopdf_destroy_converter (wkhtmltopdf_converter *converter) |
| Destroy a wkhtmltopdf converter object. | |
| CAPI void | wkhtmltopdf_set_warning_callback (wkhtmltopdf_converter *converter, wkhtmltopdf_str_callback cb) |
| Set the function that should be called when an errors occurs during conversion. | |
| CAPI void | wkhtmltopdf_set_error_callback (wkhtmltopdf_converter *converter, wkhtmltopdf_str_callback cb) |
| Set the function that should be called when an warning message is issued during conversion. | |
| CAPI void | wkhtmltopdf_set_phase_changed_callback (wkhtmltopdf_converter *converter, wkhtmltopdf_void_callback cb) |
| Set the function that should be called whenever conversion changes phase. | |
| CAPI void | wkhtmltopdf_set_progress_changed_callback (wkhtmltopdf_converter *converter, wkhtmltopdf_int_callback cb) |
| Set the function that should be called when progress have been done during conversion. | |
| CAPI void | wkhtmltopdf_set_finished_callback (wkhtmltopdf_converter *converter, wkhtmltopdf_int_callback cb) |
| Set the function that should be called once the conversion has finished. | |
| CAPI int | wkhtmltopdf_convert (wkhtmltopdf_converter *converter) |
| Convert the input objects into a pdf document. | |
| CAPI void | wkhtmltopdf_add_object (wkhtmltopdf_converter *converter, wkhtmltopdf_object_settings *setting, const char *data) |
| add an object (web page to convert) | |
| CAPI int | wkhtmltopdf_current_phase (wkhtmltopdf_converter *converter) |
| Get the number of the current conversion phase. | |
| CAPI int | wkhtmltopdf_phase_count (wkhtmltopdf_converter *converter) |
| Get the total number of phases the conversion process will go trough. | |
| CAPI const char * | wkhtmltopdf_phase_description (wkhtmltopdf_converter *converter, int phase) |
| Return a short utf8 description of a conversion phase. | |
| CAPI const char * | wkhtmltopdf_progress_string (wkhtmltopdf_converter *converter) |
| Return a short utf8 string indicating progress within a phase. | |
| CAPI int | wkhtmltopdf_http_error_code (wkhtmltopdf_converter *converter) |
| Return the largest HTTP error code encountered during conversion. | |
| CAPI long | wkhtmltopdf_get_output (wkhtmltopdf_converter *converter, const unsigned char **) |
| Get the output document generated during conversion. | |
Provides C bindings for pdf conversion.
Function pointer type used for the progress_changed and finished callbacks.
For the progress_changed callback the value indicated the progress within the current phase in percent. For the finished callback the value if 1 if the conversion has successful and 0 otherwise.
| converter | The converter that issued the callback | |
| val | The integer value |
Function pointer type used for the error and warning callbacks.
| converter | The converter that issued the callback | |
| str | A utf8 encoded string containing the error or warning message. |
Function pointer type used for the phase_changed callback.
| converter | The converter that issued the callback |
| CAPI void wkhtmltopdf_add_object | ( | wkhtmltopdf_converter * | converter, | |
| wkhtmltopdf_object_settings * | settings, | |||
| const char * | data | |||
| ) |
add an object (web page to convert)
Add the object described by the supplied object settings to the list of objects (web pages to convert), objects are placed in the output pdf in the order of addition. Once the object has been added, the supplied settings may no longer be accessed, it Wit eventually be freed by wkhtmltopdf. If a none NULL and none empty utf8 encoded string is supplied to data, this HTML content will be converted instead of the content located at "page" setting of the supplied object settings instance.
| converter | The converter to add the object to | |
| settings | The setting describing the object to add | |
| data | HTML content of the object to convert or NULL |
| CAPI int wkhtmltopdf_convert | ( | wkhtmltopdf_converter * | converter | ) |
Convert the input objects into a pdf document.
This is the main method for the conversion process, during conversion progress information warning, and errors are reported using the supplied call backs. Once the conversion is done the output pdf (or ps) file will be placed at the location of the "out" setting supplied in the global settings object during construction of the converter. If this setting is not supplied or set to the empty string, the output can be retrieved using the wkhtmltopdf_get_output function.
converter The converter to perform the conversion on.
| CAPI wkhtmltopdf_converter* wkhtmltopdf_create_converter | ( | wkhtmltopdf_global_settings * | settings | ) |
Create a wkhtmltopdf converter object.
The converter object is used to convert one or more objects(web sides) into a single pdf. Once a settings object has been parsed, it may no longer be accessed, and will eventually be freed. The returned converter object must be freed by calling wkhtmltopdf_destroy_converter
| settings | The global settings to use during conversion. |
| CAPI wkhtmltopdf_global_settings* wkhtmltopdf_create_global_settings | ( | ) |
Create a new global settings object for pdf conversion.
Create a new global settings object for pdf conversion, settings can be altered with wkhtmltopdf_set_global_setting, and inspected with wkhtmltopdf_get_global_setting. Once the desired settings have been set a converter object can be created using wkhtmltopdf_create_converter.
| CAPI wkhtmltopdf_object_settings* wkhtmltopdf_create_object_settings | ( | ) |
Create an object used to store object settings.
Create a new Object settings object for pdf conversion, settings can be altered with wkhtmltopdf_set_object_setting, and inspected with wkhtmltopdf_get_object_setting. Once the desired settings have been set the object can be added to a converter by calling wkhtmltopdf_add_resource.
| CAPI int wkhtmltopdf_current_phase | ( | wkhtmltopdf_converter * | converter | ) |
Get the number of the current conversion phase.
Conversion is done in a number of named phases, this function will retrieve the number of the current conversion phase, which will be a number between 0 and wkhtmltopdf_phase_count(converter)-1.
The description (name) of any phase can be retrieved by calling the wkhtmltopdf_phase_description method.
| converter | The converter to find the current phase of |
| CAPI int wkhtmltopdf_deinit | ( | ) |
Deinit wkhtmltopdf.
Free up resources used by wkhtmltopdf, when this has been called no other wkhtmltopdf function can be called.
| CAPI void wkhtmltopdf_destroy_converter | ( | wkhtmltopdf_converter * | converter | ) |
Destroy a wkhtmltopdf converter object.
An object must be destroyed to free up its memory, once it has been destroyed it may no longer be accessed.
| settings | The converter object to destroy |
| CAPI int wkhtmltopdf_extended_qt | ( | ) |
Check if the library is build against the wkhtmltopdf version of QT.
| CAPI int wkhtmltopdf_get_global_setting | ( | wkhtmltopdf_global_settings * | settings, | |
| const char * | name, | |||
| char * | value, | |||
| int | vs | |||
| ) |
Retrieve a setting in a global settings object.
| settings | The settings object to inspect | |
| name | The name of the setting to read | |
| value | A buffer of length at least vs, where the value is stored. | |
| vs | The length of value |
| CAPI int wkhtmltopdf_get_object_setting | ( | wkhtmltopdf_object_settings * | settings, | |
| const char * | name, | |||
| char * | value, | |||
| int | vs | |||
| ) |
Retrieve a setting in a global settings object.
| settings | The settings object to inspect | |
| name | The name of the setting to read | |
| value | A buffer of length at least vs, where the value is stored. | |
| vs | The length of value |
| CAPI long wkhtmltopdf_get_output | ( | wkhtmltopdf_converter * | converter, | |
| const unsigned char ** | d | |||
| ) |
Get the output document generated during conversion.
If no "out" location was specified in the global settings object, the binary output (pdf document) of the convection process will be stored in a buffer.
| converter | The converter to query | |
| d | A pointer to a pointer that will be made to point to the output data |
| CAPI int wkhtmltopdf_http_error_code | ( | wkhtmltopdf_converter * | converter | ) |
Return the largest HTTP error code encountered during conversion.
Return the largest HTTP code greater then or equal to 300 encountered during loading of any of the supplied objects, if no such error code is found 0 is returned. This function will only return a useful result after wkhtmltopdf_convert has been called.
| converter | The converter to query |
| CAPI int wkhtmltopdf_init | ( | int | use_graphics | ) |
Setup wkhtmltopdf.
Must be called before any other functions.
| use_graphics | Should we use a graphics system |
| CAPI int wkhtmltopdf_phase_count | ( | wkhtmltopdf_converter * | converter | ) |
Get the total number of phases the conversion process will go trough.
| converter | The converter to query |
| CAPI const char* wkhtmltopdf_phase_description | ( | wkhtmltopdf_converter * | converter, | |
| int | phase | |||
| ) |
Return a short utf8 description of a conversion phase.
| converter | The converter to query | |
| phase | The number of the conversion step of which we want a description |
| CAPI const char* wkhtmltopdf_progress_string | ( | wkhtmltopdf_converter * | converter | ) |
Return a short utf8 string indicating progress within a phase.
Will typically return a string like "40%"
| converter | The converter to query |
| CAPI void wkhtmltopdf_set_error_callback | ( | wkhtmltopdf_converter * | converter, | |
| wkhtmltopdf_str_callback | cb | |||
| ) |
Set the function that should be called when an warning message is issued during conversion.
| converter | The converter object on which warnings we want the callback to be called | |
| cb | The function to call when warning message is issued |
| CAPI void wkhtmltopdf_set_finished_callback | ( | wkhtmltopdf_converter * | converter, | |
| wkhtmltopdf_int_callback | cb | |||
| ) |
Set the function that should be called once the conversion has finished.
| converter | The converter which finish events to call back from | |
| cb | The function to call when the conversion has finished has occurred. |
| CAPI int wkhtmltopdf_set_global_setting | ( | wkhtmltopdf_global_settings * | settings, | |
| const char * | name, | |||
| const char * | value | |||
| ) |
Alter a setting in a global settings object.
| settings | The settings object to change | |
| name | The name of the setting | |
| value | The new value for the setting |
| CAPI int wkhtmltopdf_set_object_setting | ( | wkhtmltopdf_object_settings * | settings, | |
| const char * | name, | |||
| const char * | value | |||
| ) |
Alter a setting in a object settings object.
| settings | The settings object to change | |
| name | The name of the setting | |
| value | The new value for the setting |
| CAPI void wkhtmltopdf_set_phase_changed_callback | ( | wkhtmltopdf_converter * | converter, | |
| wkhtmltopdf_void_callback | cb | |||
| ) |
Set the function that should be called whenever conversion changes phase.
The number of the new phase can be found by calling wkhtmltopdf_current_phase
| converter | The converter which phase change events to call back from | |
| cb | The function to call when phases change |
| CAPI void wkhtmltopdf_set_progress_changed_callback | ( | wkhtmltopdf_converter * | converter, | |
| wkhtmltopdf_int_callback | cb | |||
| ) |
Set the function that should be called when progress have been done during conversion.
The progress in percent within the current phase is given as an integer to the callback function.
| converter | The converter which progress events to call back from | |
| cb | The function to call when progress has occurred. |
| CAPI void wkhtmltopdf_set_warning_callback | ( | wkhtmltopdf_converter * | converter, | |
| wkhtmltopdf_str_callback | cb | |||
| ) |
Set the function that should be called when an errors occurs during conversion.
| converter | The converter object on which errors we want the callback to be called | |
| cb | The function to call when an error occurs |
| CAPI const char* wkhtmltopdf_version | ( | ) |
Return the version of wkhtmltopdf Example: 0.10.0_beta4. The string is utf8 encoded and is owned by wkhtmltopdf.
1.6.3