Top Description Fields Constructors Methods
org.apache.pdfbox.tools

public final Class ExtractText

Additional top-level classes in compilation unit: AngleCollector, FilteredTextStripper, FilteredText2Markdown, NullWriter.

extends Object
implements Callable<Integer>
Class Inheritance
All Implemented Interfaces
java.util.concurrent.Callable
Annotations
@Command
name:extracttext
header:Extracts the text from a PDF document
versionProvider:Version
mixinStandardHelpOptions:true
Imports
java.io.File, .FileOutputStream, .IOException, .OutputStreamWriter, .PrintStream, .PrintWriter, .Writer, java.util.Map, .Set, .TreeSet, java.util.concurrent.Callable, org.apache.commons.io.FilenameUtils, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.Loader, org.apache.pdfbox.cos.COSName, org.apache.pdfbox.io.RandomAccessReadBuffer, org.apache.pdfbox.pdmodel.PDDocument, .PDDocumentCatalog, .PDDocumentNameDictionary, .PDEmbeddedFilesNameTreeNode, .PDPage, .PDPageContentStream, org.apache.pdfbox.pdmodel.common.filespecification.PDComplexFileSpecification, .PDEmbeddedFile, org.apache.pdfbox.pdmodel.encryption.AccessPermission, org.apache.pdfbox.text.PDFTextStripper, .TextPosition, org.apache.pdfbox.util.Matrix, picocli.CommandLine, .CommandLine.Command, .CommandLine.Option

This is the main program that simply parses the pdf document and transforms it into text.
Authors
Ben Litchfield, Tilman Hausherr

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private boolean
private boolean
private String
private int
private boolean
private File
private static final Log
private File
private String
private boolean
private boolean
private int
private static final String
private final PrintStream
private final PrintStream
private boolean
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
public
ExtractText()

Constructor.

Method Summary

Modifier and TypeMethod and Description
public Integer
call()

Implements java.util.concurrent.Callable.call.

Starts the text extraction.

private Writer
private void
extractPages(int startPage, int endPage, PDFTextStripper stripper, PDDocument document, Writer output, boolean rotationMagic, boolean alwaysNext)

pack-priv static int
public static void
main(String[]
Command line arguments, should be one and a reference to a file.
args
)

Infamous main method.

private long
private void
stopProcessing(String message, long startTime)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addFileNameback to summary
private boolean addFileName
Annotations
@Option
names:-addFileName
description:Print PDF file name to the output text
alwaysNextback to summary
private boolean alwaysNext
Annotations
@Option
names:-alwaysNext
description:Process next page (if applicable) despite IOException (ignored when -html)
appendback to summary
private boolean append
Annotations
@Option
names:-append
description:Use append mode for output file
debugback to summary
private boolean debug
Annotations
@Option
names:-debug
description:Enables debug output about the time consumption of every stage
encodingback to summary
private String encoding
Annotations
@Option
names:-encoding
description:UTF-8 or ISO-8859-1, UTF-16BE, UTF-16LE, etc. (default: ${DEFAULT-VALUE})
endPageback to summary
private int endPage
Annotations
@Option
names:-endPage
description:The last page to extract (1 based, inclusive)
ignoreBeadsback to summary
private boolean ignoreBeads
Annotations
@Option
names:-ignoreBeads
description:Disables the separation by beads
infileback to summary
private File infile
Annotations
@Option
names:-i, --input
description:the PDF file
required:true
LOGback to summary
private static final Log LOG
outfileback to summary
private File outfile
Annotations
@Option
names:-o, --output
description:the exported text file
passwordback to summary
private String password
Annotations
@Option
names:-password
description:the password for the PDF or certificate in keystore.
arity:0..1
interactive:true
rotationMagicback to summary
private boolean rotationMagic
Annotations
@Option
names:-rotationMagic
description:Analyze each page for rotated/skewed text, rotate to 0° and extract separately (slower, and ignored when -html)
sortback to summary
private boolean sort
Annotations
@Option
names:-sort
description:Sort the text before writing of every stage
startPageback to summary
private int startPage
Annotations
@Option
names:-startPage
description:The first page to start extraction (1 based)
STD_ENCODINGback to summary
private static final String STD_ENCODING
SYSERRback to summary
private final PrintStream SYSERR
Annotations
@SuppressWarnings:squid:S106
SYSOUTback to summary
private final PrintStream SYSOUT
Annotations
@SuppressWarnings:squid:S106
toConsoleback to summary
private boolean toConsole
Annotations
@Option
names:-console
description:Send text to console instead of file
toHTMLback to summary
private boolean toHTML
Annotations
@Option
names:-html
description:Output in HTML format instead of raw text
toMDback to summary
private boolean toMD
Annotations
@Option
names:-md
description:Output in Markdown format instead of raw text

Constructor Detail

ExtractTextback to summary
public ExtractText()

Constructor.

Method Detail

callback to summary
public Integer call()

Implements java.util.concurrent.Callable.call.

Starts the text extraction.

Returns:Integer

Doc from java.util.concurrent.Callable.call.

computed result

createOutputWriterback to summary
private Writer createOutputWriter() throws IOException
extractPagesback to summary
private void extractPages(int startPage, int endPage, PDFTextStripper stripper, PDDocument document, Writer output, boolean rotationMagic, boolean alwaysNext) throws IOException
getAngleback to summary
pack-priv static int getAngle(TextPosition text)
mainback to summary
public static void main(String[] args)

Infamous main method.

Parameters
args:String[]

Command line arguments, should be one and a reference to a file.

startProcessingback to summary
private long startProcessing(String message)
stopProcessingback to summary
private void stopProcessing(String message, long startTime)