You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2021/04/02 14:51:57 UTC
svn commit: r1888314 -
/pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java
Author: tilman
Date: Fri Apr 2 14:51:56 2021
New Revision: 1888314
URL: http://svn.apache.org/viewvc?rev=1888314&view=rev
Log:
PDFBOX-4892: performance improvements, as suggested by valerybokov
Modified:
pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java
Modified: pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java?rev=1888314&r1=1888313&r2=1888314&view=diff
==============================================================================
--- pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java (original)
+++ pdfbox/branches/2.0/tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java Fri Apr 2 14:51:56 2021
@@ -133,6 +133,8 @@ public class TextToPDF
// There is a special case of creating a PDF document from an empty string.
boolean textIsEmpty = true;
+ StringBuilder nextLineToDraw = new StringBuilder();
+
while( (nextLine = data.readLine()) != null )
{
@@ -145,24 +147,25 @@ public class TextToPDF
int lineIndex = 0;
while( lineIndex < lineWords.length )
{
- StringBuilder nextLineToDraw = new StringBuilder();
+ nextLineToDraw.setLength(0);
float lengthIfUsingNextWord = 0;
boolean ff = false;
do
{
String word1, word2 = "";
- int indexFF = lineWords[lineIndex].indexOf('\f');
+ String word = lineWords[lineIndex];
+ int indexFF = word.indexOf('\f');
if (indexFF == -1)
{
- word1 = lineWords[lineIndex];
+ word1 = word;
}
else
{
ff = true;
- word1 = lineWords[lineIndex].substring(0, indexFF);
- if (indexFF < lineWords[lineIndex].length())
+ word1 = word.substring(0, indexFF);
+ if (indexFF < word.length())
{
- word2 = lineWords[lineIndex].substring(indexFF + 1);
+ word2 = word.substring(indexFF + 1);
}
}
// word1 is the part before ff, word2 after
@@ -504,7 +507,7 @@ public class TextToPDF
/**
* Sets paper orientation.
*
- * @param landscape
+ * @param landscape true for landscape orientation
*/
public void setLandscape(boolean landscape)
{