C # read PDF document content

Source: Internet
Author: User

First, download PDFBox

Visit URL http://sourceforge.net/projects/pdfbox/(This is definitely a good site)


Ii. referencing the dynamic link library

To extract the downloaded PDFBox, locate the bin directory in which the referenced DLL file needs to be added in the project:
IKVM. Gnu. Classpath.dll
Pdfbox-0.7.3.dll
Fontbox-0.1.0-dev.dll
IKVM. Runtime.dll


Reference the above 4 files to the project, you need to introduce the following 2 namespaces in the file:
Using Org.pdfbox.pdmodel;
Using Org.pdfbox.util;

Third, the use of the API method

usingSystem.IO;usingSystem.Text;usingOrg.pdfbox.pdmodel;usingOrg.pdfbox.util;namespacepdfreader{classProgram { Public Static voidPdf2txt (FileInfo pdffile, FileInfo txtfile) {pddocument doc=Pddocument.load (pdffile.            FullName); Pdftextstripper Pdfstripper=NewPdftextstripper (); stringText =Pdfstripper.gettext (DOC); StreamWriter Swpdfchange=NewStreamWriter (txtfile. FullName,false, Encoding.GetEncoding ("gb2312"));            Swpdfchange.write (text);        Swpdfchange.close (); }        Static voidMain (string[] args) {Pdf2txt (NewFileInfo (@"c:/users/susan/desktop/Full draft __ hurried that year _ Nine night anise. pdf"),NewFileInfo (@"c:/users/susan/desktop/Full draft __ hurried that year _ Nine night anise .")); }    }}

C # read PDF document content

Related Article

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.