Skip to content

Commit c83380b

Browse files
committed
PDFBOX-1529: refactor to prepare for lineHeight
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1922737 13f79535-47bb-0310-9956-ffa450edef68
1 parent 5568978 commit c83380b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,12 @@ public void createPDFFromText( PDDocument doc, Reader text ) throws IOException
235235
font = new PDType1Font(standardFont);
236236
}
237237
final int margin = 40;
238-
float height = font.getBoundingBox().getHeight() / FONTSCALE;
238+
float fontHeight = font.getBoundingBox().getHeight() / FONTSCALE;
239239
PDRectangle actualMediaBox =
240240
landscape ? new PDRectangle(mediaBox.getHeight(), mediaBox.getWidth()) : mediaBox;
241241

242-
//calculate font height and increase by a factor.
243-
height = height * fontSize * LINE_HEIGHT_FACTOR;
242+
// calculate line height and increase by a factor.
243+
float lineHeight = fontHeight * fontSize * LINE_HEIGHT_FACTOR;
244244
BufferedReader data = new BufferedReader(text);
245245
String nextLine;
246246
PDPage page = new PDPage(actualMediaBox);
@@ -344,16 +344,16 @@ 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 + height;
347+
y = page.getMediaBox().getHeight() - margin + lineHeight;
348348
contentStream.newLineAtOffset(margin, y);
349349
}
350350

351351
if (contentStream == null)
352352
{
353353
throw new IOException("Error:Expected non-null content stream.");
354354
}
355-
contentStream.newLineAtOffset(0, -height);
356-
y -= height;
355+
contentStream.newLineAtOffset(0, -lineHeight);
356+
y -= lineHeight;
357357
contentStream.showText(nextLineToDraw.toString());
358358
if (ff)
359359
{
@@ -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 + height;
367+
y = page.getMediaBox().getHeight() - margin + lineHeight;
368368
contentStream.newLineAtOffset(margin, y);
369369
}
370370
}

0 commit comments

Comments
 (0)