The following reading method may cause gibberish reading of some PDF files. If you have any other solutions, you can learn them together.
Winform code
First, download: product_box
By referencing two dll:
Ikvm. GNU. classpath. dll
PDFBox-0.7.3.dll
Put the two DLL files in the bin directory of the project:
FontBox-0.1.0-dev.dll
Ikvm. runtime. dll
// The referenced space, which can be used only after the dynamic DLL consumed by the Project
Using orgdomainbox. pdmodel;
Using orgdomainbox. util;
// Code in the button event
Private void button2_click (Object sender, system. eventargs E)
{
Pddocument txttmp = pddocument. Load (physical file path)
Extends textstripper extends stripper = new extends textstripper ();
Textbox1.text = javasstripper. gettext (txttmp );
Textbox1.text + = textbox1.text. length;
/* For future reference
Dialogresult DR = folderdialog. showdialog ();
If (Dr! = Dialogresult. OK)
{
Return;
}
// Select the file path
Folderpath = folderdialog. selectedpath;
Directoryinfo dirpdf = new directoryinfo (folderpath );
If (! Dirpdf. exists)
{
MessageBox. Show ("the file path you entered is incorrect. Please verify it! ");
Return;
}
Fileinfo [] fileoldsystem = dirpdf. getfiles ("*. pdf ");
If (fileoldsystem. Length = 0)
{
MessageBox. Show ("the file path you selected does not have a PDF file. Please verify it! ");
Return;
}
Foreach (fileinfo file in fileoldsystem)
{
Pddocument txttmp = pddocument. Load (file. fullname. tolower ());
Extends textstripper extends stripper = new extends textstripper ();
Textbox1.text = javasstripper. gettext (txttmp );
Textbox1.text + = textbox1.text. length;
Streamwriter Sw = file. appendtext (file. fullname. tolower (). Replace (". pdf", ". txt "));
Sw. Write (textbox1.text );
Sw. Flush ();
Sw. Close ();
}
*/
}