Page events were designed to place text at precise positions, not to add
text or tables to the document. Sometimes it works but most of the times
there's too much interference and the text or table get on top of each
other. You can solve your problem by increasing the top margin and placing a
PdfPTable at a precise position for the header.
Best Regards,
Paulo Soares
> -----Original Message-----
> From: Preeti Sehgal [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, July 30, 2002 16:30
> To: [EMAIL PROTECTED]
> Subject: RE: [iText-questions] overlapping text when using
> onStartPage Event
>
> Here if the OnStartPageEvent Code:
>
> public void onStartPage(PdfWriter writer, Document doc) {
> try {
> lifeTable = new Table(4);
> lifeTable.setWidth(100);
> lifeTable.setBorderWidth(0);
> lifeTable.setBorder(Rectangle.NO_BORDER);
> lifeTable.setPadding(0);
> lifeTable.setSpacing(0);
>
> Cell title = new Cell(new Chunk(res.getString("Individual Life
> Quotation"),new Font(Font.TIMES_NEW_ROMAN,16,Font.BOLD)));
> title.setBackgroundColor(Color.lightGray);
> title.setHorizontalAlignment(Element.ALIGN_CENTER);
> title.setVerticalAlignment(Element.ALIGN_MIDDLE);
> title.setBorder(Rectangle.NO_BORDER);
> title.setColspan(4);
> title.setRowspan(1);
> lifeTable.addCell(title);
>
> if(!mQuote) {
> Cell insCompany = new Cell(new
> Chunk(res.getString("Insurance Company"),boldFont12));
> insCompany.setHorizontalAlignment(Element.ALIGN_LEFT);
> insCompany.setBorder(Rectangle.NO_BORDER);
> insCompany.setColspan(1);
> insCompany.setRowspan(1);
> lifeTable.addCell(insCompany);
>
> Cell pl = new Cell(new
> Chunk(res.getString("Plan"),boldFont12));
> pl.setHorizontalAlignment(Element.ALIGN_LEFT);
> pl.setBorder(Rectangle.NO_BORDER);
> pl.setColspan(1);
> pl.setRowspan(1);
> lifeTable.addCell(pl);
>
> }
> Cell ins = new Cell(new
> Chunk(res.getString("Insured"),boldFont12));
> ins.setHorizontalAlignment(Element.ALIGN_LEFT);
> ins.setBorder(Rectangle.NO_BORDER);
> ins.setColspan(1);
> ins.setRowspan(1);
> lifeTable.addCell(ins);
>
> Cell smoking = new Cell(new Chunk(res.getString("Smoking
> Habit"),boldFont12));
> smoking.setHorizontalAlignment(Element.ALIGN_LEFT);
> smoking.setBorder(Rectangle.NO_BORDER);
> smoking.setColspan(1);
> smoking.setRowspan(1);
> lifeTable.addCell(smoking);
>
> Cell bDay = new Cell(new Chunk(res.getString("Date of
> Birth"),boldFont12));
> bDay.setHorizontalAlignment(Element.ALIGN_LEFT);
> bDay.setBorder(Rectangle.NO_BORDER);
> bDay.setColspan(1);
> bDay.setRowspan(1);
> lifeTable.addCell(bDay);
>
> Cell gen = new Cell(new
> Chunk(res.getString("Gender"),boldFont12));
> gen.setHorizontalAlignment(Element.ALIGN_LEFT);
> gen.setBorder(Rectangle.NO_BORDER);
> gen.setColspan(1);
> gen.setRowspan(1);
> lifeTable.addCell(gen);
>
>
> Cell aAge = new Cell(new Chunk(res.getString("Actual
> Age"),boldFont12));
> aAge.setHorizontalAlignment(Element.ALIGN_LEFT);
> aAge.setBorder(Rectangle.NO_BORDER);
> aAge.setColspan(1);
> aAge.setRowspan(1);
> lifeTable.addCell(aAge);
>
> Cell nAge = new Cell(new Chunk(res.getString("Nearest
> Age"),boldFont12));
> nAge.setHorizontalAlignment(Element.ALIGN_LEFT);
> nAge.setBorder(Rectangle.NO_BORDER);
> nAge.setColspan(1);
> nAge.setRowspan(1);
> lifeTable.addCell(nAge);
>
> Cell amount = new Cell(new Chunk(res.getString("Face
> Amount"),boldFont12));
> amount.setHorizontalAlignment(Element.ALIGN_LEFT);
> amount.setBorder(Rectangle.NO_BORDER);
> amount.setColspan(1);
> amount.setRowspan(1);
> lifeTable.addCell(amount);
>
> Cell prov = new Cell(new Chunk("Province",boldFont12));
> prov.setHorizontalAlignment(Element.ALIGN_LEFT);
> prov.setBorder(Rectangle.NO_BORDER);
> prov.setColspan(1);
> prov.setRowspan(1);
> lifeTable.addCell(prov);
>
> createEmptyCell(lifeTable,4);
> doc.add(lifeTable);
> } catch (DocumentException e) {
> System.out.println(e.getMessage());
> }
> }//end onStartPage
>
>
>
> And here is the code where I actually create the files:
>
> Document doc;
> doc = new Document(PageSize.LETTER,15,15,20,20);
> File pdf = new File(this.path);
> PdfWriter writer = PdfWriter.getInstance(doc, new
> FileOutputStream(pdf));
> //add doc info
> doc.addTitle(res.getString("IQ3 on the Web"));
> doc.addSubject(res.getString("IQ3 on the Web"));
> doc.open();
> ReportEvents repEvent = new ReportEvents();
> //for page events
> writer.setPageEvent(repEvent);
> if(mQuote) {
> //if coming from mutliquote
> repEvent.onStartPage(writer,doc);
> //create page header table
> doc.add(premTable1);
> doc.newPage();
> doc.add(premTable2);
> repEvent.onCloseDocument(writer,doc);
> //create notes + info tables
>
> } else {
> //if coming from quote
> this.buildLifeTable();
> this.buildProdInfo();
> this.buildInfoTable();
> this.buildNotes();
> doc.add(lifeTable);
> doc.add(prodInfoQ);
> doc.add(premTable1);
> doc.add(notesTable);
> doc.add(infoTable);
> }
> doc.close();
> }
>
> Thanks J.
>
> -----Original Message-----
> > FROM: Paulo Soares
> > DATE: 07/26/2002 02:51:30SUBJECT: RE: [iText-questions]
> > overlapping text when using onStartPage Eve Unless you post a code
> snippet > all I can do is guess.
>
> >Best Regards,
> >Paulo Soares
>
>
> > -----Original Message-----
> > From: Preeti Sehgal [SMTP:<EMAIL: PROTECTED>]
> > Sent: Thursday, July 25, 2002 19:49
> > To: <EMAIL: PROTECTED>
> > Subject: [iText-questions] overlapping text when using
> onStartPage
> > Event
> >
> > Hi,
> >
> > I am using the onStartPage Event to display a header on
> each
> > page of my pdf report. When the second page gets displayed, the new
> text
> > overlaps my header. Is there any way to prevent this?
> >
> > Thanks,
> > J.
> >
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> iText-questions mailing list
> <EMAIL: PROTECTED>
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: Dice - The leading online job board
> for high-tech professionals. Search and apply for tech jobs today!
> http://seeker.dice.com/seeker.epl?rel_code=31
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
-------------------------------------------------------
This sf.net email is sponsored by: Dice - The leading online job board
for high-tech professionals. Search and apply for tech jobs today!
http://seeker.dice.com/seeker.epl?rel_code=31
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions