"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tools/src/main/java/org/apache/pdfbox/tools/TextToPDF.java" between
pdfbox-2.0.23-src.zip and pdfbox-2.0.24-src.zip

About: Apache PDFBox is a Java PDF library tool that allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

TextToPDF.java  (pdfbox-2.0.23-src):TextToPDF.java  (pdfbox-2.0.24-src)
skipping to change at line 136 skipping to change at line 136
BufferedReader data = new BufferedReader( text ); BufferedReader data = new BufferedReader( text );
String nextLine; String nextLine;
PDPage page = new PDPage(actualMediaBox); PDPage page = new PDPage(actualMediaBox);
PDPageContentStream contentStream = null; PDPageContentStream contentStream = null;
float y = -1; float y = -1;
float maxStringLength = page.getMediaBox().getWidth() - 2*margin; float maxStringLength = page.getMediaBox().getWidth() - 2*margin;
// There is a special case of creating a PDF document from an empty string. // There is a special case of creating a PDF document from an empty string.
boolean textIsEmpty = true; boolean textIsEmpty = true;
StringBuilder nextLineToDraw = new StringBuilder();
while( (nextLine = data.readLine()) != null ) while( (nextLine = data.readLine()) != null )
{ {
// The input text is nonEmpty. New pages will be created and add ed // The input text is nonEmpty. New pages will be created and add ed
// to the PDF document as they are needed, depending on the leng th of // to the PDF document as they are needed, depending on the leng th of
// the text. // the text.
textIsEmpty = false; textIsEmpty = false;
String[] lineWords = nextLine.replaceAll("[\\n\\r]+$", "").split (" "); String[] lineWords = nextLine.replaceAll("[\\n\\r]+$", "").split (" ");
int lineIndex = 0; int lineIndex = 0;
while( lineIndex < lineWords.length ) while( lineIndex < lineWords.length )
{ {
StringBuilder nextLineToDraw = new StringBuilder(); nextLineToDraw.setLength(0);
float lengthIfUsingNextWord = 0; float lengthIfUsingNextWord = 0;
boolean ff = false; boolean ff = false;
do do
{ {
String word1, word2 = ""; String word1, word2 = "";
int indexFF = lineWords[lineIndex].indexOf('\f'); String word = lineWords[lineIndex];
int indexFF = word.indexOf('\f');
if (indexFF == -1) if (indexFF == -1)
{ {
word1 = lineWords[lineIndex]; word1 = word;
} }
else else
{ {
ff = true; ff = true;
word1 = lineWords[lineIndex].substring(0, indexFF); word1 = word.substring(0, indexFF);
if (indexFF < lineWords[lineIndex].length()) if (indexFF < word.length())
{ {
word2 = lineWords[lineIndex].substring(indexFF + 1); word2 = word.substring(indexFF + 1);
} }
} }
// word1 is the part before ff, word2 after // word1 is the part before ff, word2 after
// both can be empty // both can be empty
// word1 can also be empty without ff, if a line has man y spaces // word1 can also be empty without ff, if a line has man y spaces
if (word1.length() > 0 || !ff) if (word1.length() > 0 || !ff)
{ {
nextLineToDraw.append(word1); nextLineToDraw.append(word1);
nextLineToDraw.append(" "); nextLineToDraw.append(" ");
} }
skipping to change at line 505 skipping to change at line 508
* @return true for landscape orientation * @return true for landscape orientation
*/ */
public boolean isLandscape() public boolean isLandscape()
{ {
return landscape; return landscape;
} }
/** /**
* Sets paper orientation. * Sets paper orientation.
* *
* @param landscape * @param landscape true for landscape orientation
*/ */
public void setLandscape(boolean landscape) public void setLandscape(boolean landscape)
{ {
this.landscape = landscape; this.landscape = landscape;
} }
} }
 End of changes. 7 change blocks. 
7 lines changed or deleted 10 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)