Skip to content

Commit 4a17bbc

Browse files
committed
PDFBOX-1529: fix bugs for top and bottom margins
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1922742 13f79535-47bb-0310-9956-ffa450edef68
1 parent c83380b commit 4a17bbc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)