You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Alexander Shvartz (JIRA)" <ji...@apache.org> on 2009/10/12 05:14:31 UTC
[jira] Created: (PDFBOX-540) New functionality for class inherited
from PDFTextStripperByArea class
New functionality for class inherited from PDFTextStripperByArea class
----------------------------------------------------------------------
Key: PDFBOX-540
URL: https://issues.apache.org/jira/browse/PDFBOX-540
Project: PDFBox
Issue Type: Improvement
Components: PDFReader
Affects Versions: 0.7.3
Environment: Windows Vista
Reporter: Alexander Shvartz
Fix For: 0.7.3
New functionality for class inherited from PDFTextStripperByArea class
We were working with org.apache.pdfbox.util.PDFTextStripperByArea class. Using Rectangle class and methods of PDFTextStripperByArea class, such as getTextForRegion() and others, we have received the text that was identified in that region (in our case specific PDF page).
Our goal was to connect PDFTextStripperByArea class with TextPosition class which has methods to manage characters, such as getX(), getY() and many others. For this we supposed to use getCharactersByArticle() method. This is protected method from PDFTextStripper class, but we need this method in PDFTextStripperByArea class.
For this reason we suggest to create a new class by name (for example) PDFTextStripperByAreaChar, inherited from PDFTextStripperByArea class, and add to the new class functionality with public getCharactersByArticle() method:
//The class inherited from PDFTextStripperByArea with the additional
//functionality - the method getCharactersByArticle() taken like example
//from PDFTextStripper
package org.apache.pdfbox.util;
import java.io.IOException;
import java.util.List;
public class PDFTextStripperByAreaChar extends PDFTextStripperByArea
{
public PDFTextStripperByAreaChar() throws IOException
{
super();
}
public List getCharactersByArticle()
{
return charactersByArticle;
}
}
The example is:
PDFTextStripperByAreaChar stripperText = new PDFTextStripperByAreaChar();
//By idea originally taken from getTitle() method of //org.apache.pdfbox.util.PDFText2HTML class we can run the code to get X and Y coordinates of the special character:
Iterator textIter = stripperText.getCharactersByArticle().iterator();
String charPDF;
while (textIter.hasNext())
{
Iterator textByArticle = ((List) textIter.next()).iterator();
int j = 1;
while (textByArticle.hasNext())
{
TextPosition text = (TextPosition) textByArticle.next();
charPDF = text.getCharacter();
System.out.println("Char " + j + ": |" + charPDF +
"| X = " + text.getX() + ", Y = " + text.getY());
j++;
}
}
Thank you.
DeepDyve developers:
Alexander Shvartz,
Raza Mobin,
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (PDFBOX-540) New functionality for class inherited
from PDFTextStripperByArea class
Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PDFBOX-540?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jukka Zitting updated PDFBOX-540:
---------------------------------
Fix Version/s: (was: 0.7.3)
> New functionality for class inherited from PDFTextStripperByArea class
> ----------------------------------------------------------------------
>
> Key: PDFBOX-540
> URL: https://issues.apache.org/jira/browse/PDFBOX-540
> Project: PDFBox
> Issue Type: Improvement
> Components: PDFReader
> Affects Versions: 0.7.3
> Environment: Windows Vista
> Reporter: Alexander Shvartz
>
> New functionality for class inherited from PDFTextStripperByArea class
> We were working with org.apache.pdfbox.util.PDFTextStripperByArea class. Using Rectangle class and methods of PDFTextStripperByArea class, such as getTextForRegion() and others, we have received the text that was identified in that region (in our case specific PDF page).
> Our goal was to connect PDFTextStripperByArea class with TextPosition class which has methods to manage characters, such as getX(), getY() and many others. For this we supposed to use getCharactersByArticle() method. This is protected method from PDFTextStripper class, but we need this method in PDFTextStripperByArea class.
> For this reason we suggest to create a new class by name (for example) PDFTextStripperByAreaChar, inherited from PDFTextStripperByArea class, and add to the new class functionality with public getCharactersByArticle() method:
> //The class inherited from PDFTextStripperByArea with the additional
> //functionality - the method getCharactersByArticle() taken like example
> //from PDFTextStripper
> package org.apache.pdfbox.util;
> import java.io.IOException;
> import java.util.List;
> public class PDFTextStripperByAreaChar extends PDFTextStripperByArea
> {
> public PDFTextStripperByAreaChar() throws IOException
> {
> super();
>
> }
>
> public List getCharactersByArticle()
> {
> return charactersByArticle;
> }
> }
> The example is:
> PDFTextStripperByAreaChar stripperText = new PDFTextStripperByAreaChar();
> //By idea originally taken from getTitle() method of //org.apache.pdfbox.util.PDFText2HTML class we can run the code to get X and Y coordinates of the special character:
> Iterator textIter = stripperText.getCharactersByArticle().iterator();
> String charPDF;
> while (textIter.hasNext())
> {
> Iterator textByArticle = ((List) textIter.next()).iterator();
> int j = 1;
> while (textByArticle.hasNext())
> {
> TextPosition text = (TextPosition) textByArticle.next();
>
> charPDF = text.getCharacter();
>
> System.out.println("Char " + j + ": |" + charPDF +
> "| X = " + text.getX() + ", Y = " + text.getY());
>
> j++;
> }
> }
> Thank you.
> DeepDyve developers:
> Alexander Shvartz,
> Raza Mobin,
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.