C # Read Pdf--pdfbox use

Source: Internet
Author: User

First, download PDFBox

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


Second, the reference dynamic link library

To extract the pdfbox of the download, locate the bin directory where you want to add the referenced DLL file to the project:
IKVM. Gnu. Classpath.dll
Pdfbox-0.7.3.dll
Fontbox-0.1.0-dev.dll
IKVM. Runtime.dll


Referring to 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

Using System.IO;

Using System.Text;

Using Org.pdfbox.pdmodel;

Using Org.pdfbox.util;

Namespace Pdfreader

{

Class Program

{

public static void Pdf2txt (FileInfo pdffile, FileInfo txtfile)

{

PDDocument doc = Pddocument.load (pdffile. FullName);

Pdftextstripper pdfstripper = new Pdftextstripper ();

string text = Pdfstripper.gettext (DOC);

StreamWriter swpdfchange = new StreamWriter (txtfile. FullName, False, Encoding.GetEncoding ("gb2312"));

Swpdfchange.write (text);

Swpdfchange.close ();

}

static void Main (string[] args)

{

Pdf2txt (The new FileInfo (@ "c:/users/susan/desktop/complete Manuscript __ The year _ Nine Night Anise"), New FileInfo (@ "c:/users/susan/desktop/full version __") Hurried that year _ Nine night anise.

}

}

Translating Chinese is no problem, cause you should know.

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.