Hi. An inner class solved the prob.
as in the following:
class PEvent extends PdfPageEventHelper {
public void onStartPage(PdfWriter writer, Document document) {
System.out.println("STARTPAGE " );
}
public void onEndPage(PdfWriter writer,Document document) {
System.out.println("ENDPAGE " );
}
}
//String path = getServletContext().getRealPath("/");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document document = new Document(PageSize.A6);
PdfWriter writer = PdfWriter.getInstance(document,baos);
PEvent pe = new PEvent();
writer.setPageEvent(pe);
document.open();
Kr.
Luke.
Luke Vanderfluit wrote:
> Hi.
>
> Im trying to override a method in a jsp page.
>
> In the following code Im trying to get a system message to print
> whenever an 'onStartPage' event is fired.
> Im not getting the desired result.
>
> How do I override an event method within a JSP?
>
> Kr.
> Luke.
>
>
> <%@ page contentType="text/pdf"
> import="com.lowagie.*,com.lowagie.text.*,com.lowagie.text.pdf.*,java.io.*,java.util.Iterator,java.util.Map,java.util.HashMap,java.util.ArrayList,java.util.regex.Pattern,java.util.Date,java.awt.Color,java.sql.Connection,java.sql.PreparedStatement,java.sql.ResultSet,com.eddygordon.*,java.text.SimpleDateFormat"%><%!
> public void onStartPage(PdfWriter writer, Document document) {
> System.out.println("STARTPAGE" );
> }
> %><%
>
> String path = getServletContext().getRealPath("/");
>
> ByteArrayOutputStream baos = new ByteArrayOutputStream();
> Document document = new Document(PageSize.A6);
> PdfWriter writer = PdfWriter.getInstance(document,baos);
> document.open();
>
> Color headerColor = new Color(166,30,34);
> Color colorBlack = new Color(0,0,0);
> BaseFont bf =
> BaseFont.createFont(BaseFont.HELVETICA,BaseFont.CP1252,BaseFont.NOT_EMBEDDED);
> BaseFont bf2 =
> BaseFont.createFont(BaseFont.HELVETICA,BaseFont.CP1252,BaseFont.NOT_EMBEDDED);
> Font font11Norm = new Font(bf,11,Font.NORMAL);
> Font font11Bold = new Font(bf,11,Font.BOLD,colorBlack);
> Font font10Norm = new Font(bf2,10,Font.NORMAL);
> Font font12BoldRed = new Font(bf,12,Font.BOLD,headerColor);
>
>
> document.add(new Paragraph(10,"Emergency
> Manual\n",font12BoldRed));
> for (int i = 0; i < 25; i++)
> document.add(new Paragraph("Hello paragraph 1." + i));
> document.newPage();
> ColumnText ct = new ColumnText(writer.getDirectContent());
> ct.setSimpleColumn(PageSize.A6.getLeft(36),
> PageSize.A6.getBottom(36),
> PageSize.A6.getRight(36), PageSize.A6.getTop(36));
> for (int i = 0; i < 25; i++)
> ct.addElement(new Paragraph("Hello ct 1." + i));
> int status = ct.go();
> while (ColumnText.hasMoreText(status)) {
> document.newPage();
> ct.setYLine(PageSize.A6.getTop(36));
> status = ct.go();
> }
> document.newPage();
> for (int i = 0; i < 10; i++)
> ct.addElement(new Paragraph("Hello ct 2." + i));
> status = ct.go();
> while (ColumnText.hasMoreText(status)) {
> document.newPage();
> ct.setYLine(PageSize.A6.getTop(36));
> status = ct.go();
> }
> document.newPage();
> for (int i = 0; i < 5; i++)
> document.add(new Paragraph("Hello paragraph 2." + i));
>
>
>
>
> //SEND STREAM
> document.close();
>
> response.setHeader("Expires","Mon,26 Jul 1997 05:00:00 GMT");
> response.setHeader("Cache-Control","no-store,no-cache,private");
> response.setHeader("Pragma","no-cache");
> response.setDateHeader("Last-Modified",System.currentTimeMillis());
>
> response.setHeader("Content-Disposition","attachment;
> filename=\"WEMM_Manual.pdf\"");
> response.setIntHeader("Content-Length",baos.size());
> baos.writeTo(response.getOutputStream());
> response.getOutputStream().flush();
>
>
> %>
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
> Studies have shown that voting for your favorite open source project,
> along with a healthy diet, reduces your potential for chronic lameness
> and boredom. Vote Now at http://www.sourceforge.net/community/cca08
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> Do you like iText?
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> Or leave a tip: https://tipit.to/itexttipjar
--
Luke Vanderfluit
Analyst / Web Programmer
e3Learning.com.au
08 8221 6422
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar