Author: tilman
Date: Sun Dec 29 15:11:18 2024
New Revision: 1922741

URL: http://svn.apache.org/viewvc?rev=1922741&view=rev
Log:
PDFBOX-1529: fix bugs for top and bottom margins

Modified:
    
pdfbox/branches/3.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java

Modified: 
pdfbox/branches/3.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/3.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java?rev=1922741&r1=1922740&r2=1922741&view=diff
==============================================================================
--- 
pdfbox/branches/3.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java 
(original)
+++ 
pdfbox/branches/3.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java 
Sun Dec 29 15:11:18 2024
@@ -330,7 +330,7 @@ public class TextToPDF implements Callab
                 }
                 while (lineIndex < lineWords.length && lengthIfUsingNextWord < 
maxStringLength);
 
-                if (y < margin)
+                if (y - lineHeight < margin)
                 {
                     // We have crossed the end-of-page boundary and need to 
extend the
                     // document by another page.
@@ -344,7 +344,7 @@ public class TextToPDF implements Callab
                     contentStream = new PDPageContentStream(doc, page);
                     contentStream.setFont(font, fontSize);
                     contentStream.beginText();
-                    y = page.getMediaBox().getHeight() - margin + lineHeight;
+                    y = page.getMediaBox().getHeight() - margin;
                     contentStream.newLineAtOffset(margin, y);
                 }
 
@@ -364,7 +364,7 @@ public class TextToPDF implements Callab
                     contentStream = new PDPageContentStream(doc, page);
                     contentStream.setFont(font, fontSize);
                     contentStream.beginText();
-                    y = page.getMediaBox().getHeight() - margin + lineHeight;
+                    y = page.getMediaBox().getHeight() - margin;
                     contentStream.newLineAtOffset(margin, y);
                 }
             }


Reply via email to