Hello I try to build a PDF-file with several pages, but I always get the same
error.
I create a pdf which has a table. When there are many entries for the table,
there should be another page created in the pdf, but not in a new pdf-file.
When there are not much entries and i can print it all in one page,
everything is fine.
The error i'm getting is this:
[code]
pageEntries: 20
pageEntries: 10
java.lang.NullPointerException: Font and size must be set before writing any
text
[/code]
and this is the code:
[code]
private void printDocument(Vector<String> tableValues) throws
DocumentException
{
Document document;
try {
document = new Document(PageSize.A4.rotate());
//System.out.println("page: " +
this.cv.getPdfPanel().getPage());
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream(outputPath));
document.open();
this.initSideAssignments();
PdfContentByte cb = writer.getDirectContent();
cb.setFontAndSize(initNeoSansPro(), 12);
//Alle Seiten werden erzeugt
for(int i = 0; i < this.sideAssignments.size(); i++)
this.printPages(cb, tableValues, document,
this.sideAssignments.elementAt(i), i);
document.close();
writer.close();
} catch (Exception e) {
e.printStackTrace();
}
}
private static BaseFont initNeoSansPro()
{
Font neoSansPro =
FontFactory.getFont("./font/NeoSansPro-Regular.ttf",
BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
BaseFont base = neoSansPro.getBaseFont();
return base;
}
private void printPages(PdfContentByte cb, Vector<String>
tableValues, Document doc, Vector<Assignment> assvec, int side)
{
System.out.println("pageEntries: " + assvec.size());
cb.setFontAndSize(initNeoSansPro(), 12);
if(side > 0)
doc.newPage();
.....
}
[/code]
I searched the www for an answer, but i could not find anything. I hope
someone knows what to do here.
Kind regards,
Michael
--
View this message in context:
http://itext-general.2136553.n4.nabble.com/Writing-PDF-with-several-pages-tp3848315p3848315.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php