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.

Thanks,
Chandu.

Hi,
you’re using online export service:
dhtmlxgrid.appspot.com/export/pdf’

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.

-Chandu.

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.

Regards,
Chandu

Hi,
you should download export script from here:
viewtopic.php?f=23&t=20151

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 dhtmlx.com) 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:-

“java.io.FileNotFoundException: \header.jpg (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(FileInputStream.java:120)
at java.io.FileInputStream.(FileInputStream.java:79)
at com.dhtmlx.xml2pdf.PDFWriter.printFooter(PDFWriter.java:348)
at com.dhtmlx.xml2pdf.PDFWriter.generate(PDFWriter.java:77)
at PDFGenerator.doPost(PDFGenerator.java:18)”

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.

Thanks,
Steve
dhtmlxgrid_export.zip (2.27 KB)


Can anyone please help on the issue as stated above.

Thanks,
Steve

Hi,
sorry for the delay in answerring.
You should specify full path to header/footer images in PDFWriter.java:

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.

Thanks,
Steve