Product_box can onley select text from PDF?

Source: Internet
Author: User

Java

Import orgdomainbox. pdmodel. pddocument.
Import org.w.boxw.parser. extends parser;
Import java. Io. * ;
Import orgdomainbox. util. extends textstripper;
Import java. util. date;
/**/ /**
* <P> title: PDF extraction </P>
* <P> Description: Email: chris@matrix.org.cn </P>
* <P> copyright: matrix copyright (c) 2003 </P>
* <P> company: matrix.org.cn </P>
* @ Author Chris
* @ Version 1.0, who use this example PLS remain the declare
 */

Public   Class Pdfextracter {

Public Extends extracter () {
}
Public String gettextfrompdf (string filename) throws exception
{
String temp = Null ;
Pddocument. nbsp1_document. Null ;
Fileinputstream Is = New Fileinputstream (filename );
Pdfparser parser =   New Pdfparser ( Is );
Parser. parse ();
Invalid document. nbsp = Parser. getpddocument .);
Bytearrayoutputstream Out   =   New Bytearrayoutputstream ();
Outputstreamwriter writer =   New Outputstreamwriter ( Out );
Pdftextstripper Stripper =   New Extends textstripper ();
Stripper. writetext (invalid document. getdocument.), writer );
Writer. Close ();
Byte [] Contents =   Out . Tobytearray ();

String TS = New String (contents );
System. Out . Println ( " The string length is " + Contents. Length + " \ N " );
Return TS;
}
Public   Static   Void Main (string ARGs [])
{
Pdfextracter pf = New Extends extracter ();
Pddocument. nbsp1_document. nbsp =   Null ;

Try {
String TS=PF. gettextfrompdf ("C: \ a.pdf");
System.Out. Println (TS );
}
Catch (Exception E)
{
E. printstacktrace ();
}
}

}

At the same time, CSHARP is as follows:
Reference some classes

Pddocument Doc = pddocument. Load ("4.20 ");
// Doc. getdocument ();
Extends textstripper extends stripper = new extends textstripper ();


Required textstripper stripper = new required textstripper ();
Stripper. gettext (DOC );
Doc. Close ();

the latest version of the local data flow operation
reference: http://pdfhome.hope.com.cn/

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.