I need to create Table structure and fill data using Haru library in C++. Can anyone provide me sample example which create table structure using Haru library.
-
I was looking into mentioned url but not able to find information. – user765443 Jan 24 '14 at 07:55
-
One question, what will be best library for read and write pdf file in C++ – user765443 Jan 24 '14 at 07:56
2 Answers
I while ago I needed to produce some data tables as part of another project using Haru PDF. To simplify the creation of complex tables I wrote a small utility module to be used with the Haru PDF library that greatly simplifies the creation of complex tables. The module allows full customization of the table and supports for example cell spanning (both row and column). It also allows for the separation of layout and look&fell by a theme concept.
A simple usage example (just to give an idea) would be
int num_rows=5;
int num_cols=4;
char *table_title="Example 1: Basic table with default theme";
hpdf_table_t t = hpdf_table_create(num_rows,num_cols,table_title);
hpdf_table_set_content(t,content);
hpdf_table_set_labels(t,labels);
HPDF_REAL xpos=100;
HPDF_REAL ypos=630;
HPDF_REAL width=400;
HPDF_REAL height=0; // Calculate height automatically
hpdf_table_stroke(pdf_doc,pdf_page,t,xpos,ypos,width,height);
It is out of scope for this answer to discuss the code in more details but it should be fairly self documenting.
The module also allows both purely programmatic tables but also the creation of entirely data driven table creation (all layout and look & feel is taken from a structure). This allows a light-way model-view-controller approach to make maintenance easier. To fully use this relies on the client implementing callback functions that the module will call to get the corresponding data.
Since this was never intended to be released as a separate utility I haven't written up (yet) full documentation but I put together a quick standalone example which shows some of the features. The resulting PDF from running the example is included at github. However, all public API are fully Doxygen commented which should give some ideas on how it fits together.
You can find the module at (https://github.com/johan162/hpdf_table)
Update: Due to surprisingly many visits/questions I have taken the time to make a new release (1.4.0) with a completely rewritten documentation and reference which explains all the functionality of the library. The release also fixes all known small bugs as well as several new features.

- 383
- 1
- 2
- 11
You can use the draw_graph function in the encoding_list.c demo as an example. It is part of the source tar ball.

- 65
- 10
-
About the other question in your comment, see the following thread: [open-source-pdf-library-for-c-c-application](http://stackoverflow.com/questions/58730/open-source-pdf-library-for-c-c-application) – HJo Apr 23 '14 at 12:27