Java PDF header/footer image on every page

Hi,

I believe Version for java: support.dhtmlx.com/x-files/expor … id-pdf.war, does not have the capability to display header and footer on every page of pdf. All it does is shows the header image only on the first page of the pdf.

Looks like, this capability for showing header on every page is provided for only DHTMLX PHP version, as answered/described on this link viewtopic.php?f=23&t=19516&p=61618&hilit=%24pageHeader#p61618

If anyone has been able to or knows how to display the header image on every page of pdf using the java version, then please advise.

Thanks,
Steve

Hi,
please, use attached version, it implements printing of header and footer at each page.
Don’t forget to provide header/footer parameters (true) during calling export:
mygrid.toPDF(url, mode, header, footer);
grid-pdf-java-pageheader.zip (130 KB)

Hi,

I am trying to add header image to the pdf but even after adding the image to the classpath(inside classes folder), It throws an exception inside the image constructor while creating the image object.

Can you please help ?

Hi,
please, provide the full stacktrace.

Hi,
Here is the stack trace :

java.lang.Exception
	at com.pdfjet.JPEGImage.<init>(JPEGImage.java:126)
	at com.pdfjet.Image.<init>(Image.java:60)
	at com.dhtmlx.xml2pdf.PDFWriter.printHeader(PDFWriter.java:463)
	at com.dhtmlx.xml2pdf.PDFWriter.createPDF(PDFWriter.java:129)
	at com.dhtmlx.xml2pdf.PDFWriter.generate(PDFWriter.java:91)
	at com.dhtmlx.xml2pdf.PDFGenerator.doPost(PDFGenerator.java:19)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
	at java.lang.Thread.run(Thread.java:662)
private void printHeader() throws Exception {
		Boolean header = parser.getHeader();
		if (header == true) {
			InputStream is  = this.getClass().getClassLoader().getResourceAsStream("header.jpg");
			Image im = new Image(pdf,is , ImageType.JPEG);
			im.setPosition(offsetLeft, offsetTop);
			im.scaleBy(1);
			im.drawOn(page);
			pageHeight -= headerImgHeight;
			offsetTop += headerImgHeight;
			firstPage = true;
		}
	}

Let me know if anymore info is required.

Hi,
for some reasons pdfjet can’t open your image.
Please, make sure that you’re using jpeg image for header. If still doesn’t work then provide also image, please.

I am trying to add jpg image only but its failing for that. Also, i wont be able to provide the image here.

I have only tried to add jpg image as of now. I will also try to add PNG image as well and hope that it works.

You could send it to support[at]dhtmlx.com with mark that it’s for Dmitry Radyno.

Hi,

Something was wrong with the image i was trying to add. I added a different image and it got added to the page just fine.

Thanks