src/lib/pdf.h File Reference

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_settingswkhtmltopdf_create_global_settings ()
 Create a new global settings object for pdf conversion.
CAPI wkhtmltopdf_object_settingswkhtmltopdf_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_converterwkhtmltopdf_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.

Detailed Description

Provides C bindings for pdf conversion.


Typedef Documentation

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.

Parameters:
converter The converter that issued the callback
val The integer value
See also:
wkhtmltopdf_set_progress_changed, wkhtmltopdf_set_finished_callback

Function pointer type used for the error and warning callbacks.

Parameters:
converter The converter that issued the callback
str A utf8 encoded string containing the error or warning message.
See also:
wkhtmltopdf_set_error_callback, wkhtmltopdf_set_warning_callback

Function pointer type used for the phase_changed callback.

Parameters:
converter The converter that issued the callback
See also:
wkhtmltopdf_set_phase_changed_callback

Function Documentation

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.

Parameters:
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.

Returns:
1 on success and 0 otherwise
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

Parameters:
settings The global settings to use during conversion.
Returns:
A wkhtmltopdf converter object
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.

Returns:
A wkhtmltopdf global settings object
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.

Returns:
an object settings instance
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.

Parameters:
converter The converter to find the current phase of
Returns:
The current phase of the supplied converter
CAPI int wkhtmltopdf_deinit (  ) 

Deinit wkhtmltopdf.

Free up resources used by wkhtmltopdf, when this has been called no other wkhtmltopdf function can be called.

Returns:
1 on success and 0 otherwise
See also:
wkhtmltopdf_init
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.

Parameters:
settings The converter object to destroy
CAPI int wkhtmltopdf_extended_qt (  ) 

Check if the library is build against the wkhtmltopdf version of QT.

Returns:
1 if the library was build against the wkhtmltopdf version of QT and 0 otherwise
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.

See also:
Setting, wkhtmltopdf_create_global_settings, wkhtmltopdf_set_global_setting
Parameters:
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
Returns:
1 If the the setting exists and was read successfully and 0 otherwise
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.

See also:
Setting, wkhtmltopdf_create_global_settings, wkhtmltopdf_set_global_setting
Parameters:
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
Returns:
1 If the the setting exists and was read successfully and 0 otherwise
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.

Parameters:
converter The converter to query
d A pointer to a pointer that will be made to point to the output data
Returns:
The length of 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.

Parameters:
converter The converter to query
Returns:
The HTTP error code.
CAPI int wkhtmltopdf_init ( int  use_graphics  ) 

Setup wkhtmltopdf.

Must be called before any other functions.

Parameters:
use_graphics Should we use a graphics system
Returns:
1 on success and 0 otherwise
See also:
wkhtmltopdf_deinit
CAPI int wkhtmltopdf_phase_count ( wkhtmltopdf_converter converter  ) 

Get the total number of phases the conversion process will go trough.

Parameters:
converter The converter to query
Returns:
The total number of phases in the conversion process
See also:
wkhtmltopdf_current_phase, wkhtmltopdf_phase_description
CAPI const char* wkhtmltopdf_phase_description ( wkhtmltopdf_converter converter,
int  phase 
)

Return a short utf8 description of a conversion phase.

Parameters:
converter The converter to query
phase The number of the conversion step of which we want a description
Returns:
A description of the conversion phase
See also:
wkhtmltopdf_current_phase, wkhtmltopdf_phase_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%"

Parameters:
converter The converter to query
Returns:
A string containing a progress indication
See also:
wkhtmltopdf_set_progress_changed_callback
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.

Parameters:
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.

Parameters:
converter The converter which finish events to call back from
cb The function to call when the conversion has finished has occurred.
See also:
wkhtmltopdf_convert
CAPI int wkhtmltopdf_set_global_setting ( wkhtmltopdf_global_settings settings,
const char *  name,
const char *  value 
)

Alter a setting in a global settings object.

See also:
Pdf global settings, wkhtmltopdf_create_global_settings, wkhtmltopdf_get_global_setting
Parameters:
settings The settings object to change
name The name of the setting
value The new value for the setting
Returns:
1 if the setting was updated successfully and 0 otherwise.
CAPI int wkhtmltopdf_set_object_setting ( wkhtmltopdf_object_settings settings,
const char *  name,
const char *  value 
)

Alter a setting in a object settings object.

See also:
Setting, wkhtmltopdf_create_object_settings, wkhtmltopdf_get_object_setting
Parameters:
settings The settings object to change
name The name of the setting
value The new value for the setting
Returns:
1 if the setting was updated successfully and 0 otherwise.
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

Parameters:
converter The converter which phase change events to call back from
cb The function to call when phases change
See also:
wkhtmltopdf_current_phase, wkhtmltopdf_phase_count, wkhtmltopdf_phase_description
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.

Parameters:
converter The converter which progress events to call back from
cb The function to call when progress has occurred.
See also:
wkhtmltopdf_progress_description
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.

Parameters:
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.

Returns:
Qt version
 All Classes Files Functions Variables Typedefs
Generated on Wed Aug 11 20:28:47 2010 for libwkhtmltox by  doxygen 1.6.3