Home / Support / Tutorials / Getting Started with PDFTextStream

Getting Started with PDFTextStream

This is a simple facade class that will allow your application to retrieve the text content of any PDF file with single call to the getPDFText(File) method:

import java.io.*; import com.snowtide.pdf.PDFTextStream; public class PDFTextStreamFacade { public StringBuffer getPDFText (File pdfFile) throws IOException { PDFTextStream stream = new PDFTextStream(pdfFile); StringBuffer sb = new StringBuffer(1024); // get OutputTarget configured to pipe text to the provided StringBuffer OutputTarget tgt = OutputTarget.forBuffer(sb); stream.pipe(tgt); stream.close(); return sb; } }

There's much, much more that can be done to enhance this class and provide better performance and better access to the features that PDFTextStream provides. However, this class, as is, will get you up and running very quickly.

What's your PDF problem?