@@ -330,7 +330,7 @@ public void createPDFFromText( PDDocument doc, Reader text ) throws IOException
330330 }
331331 while (lineIndex < lineWords .length && lengthIfUsingNextWord < maxStringLength );
332332
333- if (y < margin )
333+ if (y - lineHeight < margin )
334334 {
335335 // We have crossed the end-of-page boundary and need to extend the
336336 // document by another page.
@@ -344,7 +344,7 @@ public void createPDFFromText( PDDocument doc, Reader text ) throws IOException
344344 contentStream = new PDPageContentStream (doc , page );
345345 contentStream .setFont (font , fontSize );
346346 contentStream .beginText ();
347- y = page .getMediaBox ().getHeight () - margin + lineHeight ;
347+ y = page .getMediaBox ().getHeight () - margin ;
348348 contentStream .newLineAtOffset (margin , y );
349349 }
350350
@@ -364,7 +364,7 @@ public void createPDFFromText( PDDocument doc, Reader text ) throws IOException
364364 contentStream = new PDPageContentStream (doc , page );
365365 contentStream .setFont (font , fontSize );
366366 contentStream .beginText ();
367- y = page .getMediaBox ().getHeight () - margin + lineHeight ;
367+ y = page .getMediaBox ().getHeight () - margin ;
368368 contentStream .newLineAtOffset (margin , y );
369369 }
370370 }
0 commit comments