Problem in having header and footer in a pdf using java

Hi everyone,

Im creating a jsp in which I have button to export the data into pdf format like below which was working fine:

I wanted to have header and footer for the pdf. So I created two .png files and changed the above line to below.

But I could’t get the pdf. I think I did’t put the png files in the correct path.
Can anybody tell me how to handle this? PLease tell me where to have the png files. I have “dhtmlxgrid_export.js” in my import.


you’re using online export service:’

unfortunately it doesn’t provide header/footer supporting. To add header/footer in generated pdf you should use local export script at your server. There you may configure paths to images and print header and footer images.

Hi Radyno,

Thanks for your reply. I will try to do as you suggested.


Hey Raydno,

I will appreciate if you can explain - how to use the local export script at my server. I am really new to dhtmlxgrid, so if you can provide a small example then it would be of great help.


you should download export script from here:

If you use PHP at server side then you should locate export files at server and specify path for scheduler:

<input type="button" name="export_pdf" value="Export pdf" onclick="mygrid.toPDF( 'http://your_server_is_here/scheduler-pdf-php/generate.php','color')"/>

where ‘your_server_is_here’ must be replaced with your server name.

If you use Java then you should deploy war-package (it may be done by several ways according Java-server which you use, please read more about deploying projects yourself). After that you should configure export url:

<input type="button" name="export_pdf" value="Export pdf" onclick="mygrid.toPDF( 'http://localhost:8080/scheduler-pdf-java/generate','color')"/>

please, replace locahost:8080 according your server configurations.

Hi Radyno,

As per your suggestion given I am able to deploy grid-pdf(the war file as provided at on my local server. In addition, the pdf is coming up correctly, however displaying the header image, i.e. a logo or some other text, above the table and to set the column width is still not happening.

Attached is the screenshot of what grid-pdf workspace structure looks like. I tried placing .jpg files, wherever I can think of, however I am still getting the error as below:-

“ \header.jpg (The system cannot find the file specified)
at Method)
at com.dhtmlx.xml2pdf.PDFWriter.printFooter(
at com.dhtmlx.xml2pdf.PDFWriter.generate(
at PDFGenerator.doPost(”

Please help me in resolving the header/footer issue.

The jsp code from where I am calling is as below:-

Also I have attached dhtmlxgrid_export.js which I have included in the jsp page.

Steve (2.27 KB)

Can anyone please help on the issue as stated above.


sorry for the delay in answerring.
You should specify full path to header/footer images in

public String pathToImgs = "D:/www/export/test/export_imgs/"

In export_imgs should be located header.jpg/footer.jpg files.

I took grid-pdf-java.war file and customized the pdf functionality as per the requirements.