Export to pdf is opening in web browser

Hi

all I am new to dhtmlxgrid. I am using free version of it.

I am trying to export the grid data to pdf. But it is opening in web browser.

please help me to solve this issue

Thanks

MD. Samiuddin

The toPDF method accept a parameter called ‘target’.

if you would like to open the PDF document in the same window, you just have to pass ‘this’ as the value of ‘target’

for example, the code below I use to open my PDF in the same window

myGrid.toPDF('http://localhost:8080/XML2PDF/generate', 'color',null,null,null,this);

notice that last parameter passed (this) will make the function open the PDF in same window.

Good luck.

Hi

Maitham

Thanks for your reply. Actually I want to open it in the adobe reader. How to do that

Thanks in advance

Md.Samiuddin

Hi.
Modify PDFWriter.java like this, please:

	private void outputPDF(HttpServletResponse resp) throws Throwable {
		pdf.wrap();
	        resp.setContentType("application/pdf");
	        resp.addHeader("Content-Disposition", "attachment; filename=\"dhtmlxgrid.pdf\"");
	        pdf.getData().writeTo(resp.getOutputStream());
	}

This code will send additional header to tell browser that response should be saved on hard drive as usual file.