Example of using PDFBox to implement PDF text extraction and merge features

Source: Internet
Author: User
Tags function examples

  This article mainly introduces the use of PDFBox to achieve the PDF text extraction and Merging function examples, we refer to the use of the bar

Sometimes we need to do some processing of PDF files, extracting text, merging, and so on. Before we used the A-pdf Text extractor free tool, why not write one yourself??  now we can use PDFBox-0.7.3 this open source class library. After downloading the package reference:   Code as follows: Pdfbox-0.7.3.dll IKVM. Gnu. Classpath.dll     Create a new project, the code is simple: The code is as follows: public static string Parsetotxtstringusingpdfbox (string filename) { PDDocument doc = pddocument.load (filename); Pdftextstripper stripper = new Pdftextstripper (); Return Stripper.gettext (DOC);     Get this textstring, and then write them into a disk file, like this:   code as follows: public static void Writetotextfile (String str,string t Xtpath) {if (string). IsNullOrEmpty (Txtpath)) throw new ArgumentNullException ("Output file path should not is Null"); using (var txtwriter = new StreamWriter (Txtpath)) {txtwriter.write (str); Txtwriter.close ();}}     Other functions you can play by yourself. This class library currently supports:   PDF to text extraction Merge PDF Documents pdf Document encryption/decryption Lucene Search Engine Integr ation Fill in form data FDF and XFDF create a PDF from a-text file Create images from PDF pages Print a PDF  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.