http://www.cnblogs.com/q149072205/archive/2011/05/20/2051708.html
http://www.cnblogs.com/blodfox777/archive/2009/03/11/1408568.html
http://www.51aspx.com/SMore/%E5%85%B3%E9%94%AE%E8%AF%8D%E6%8F%90%E5%8F%96.html
Aspose.OCR for .NET实现从PDF文件中提取文本和图片(2011-07-21 11:29:00)
然而,Aspose.OCR for .NET的出现消除了该限制。在这篇文章中,通过分享一些细节来阐述如何一起使用Aspose.OCR for .NET和Aspose.Pdf for .NET这两款组件,以提取PDF文件中的所有文字。
目前, Aspose.OCR for .NET允许你提取TIFF和BMP图像中的文字。它支持Arial和Times New Roman字体,以及16pt/32pt号字体。在Aspose.OCR for .NET以后的版本中,会不断添加新字体和其他属性的支持。
为了从PDF文件和图像中完整地提取文字,你必须要经过以下三个步骤:
* Extract Text from the PDF File
* Extract Images from the PDF File
* Extract Text from the Images
使用Facades中的PdfExtractor或者DOM API,可将文字从PDF文件中提取出来。请参阅以下题目中的代码示例,以便了解从PDF文件中提取文字的相关操作:
*
提取图像也有两种方法: Facades or DOM API. 查看下列题目中的内容可进一步了解详情
:
*
一旦使用上述两种方法之一成功提取图像,接下来就应该从这些图像中提取文字。下面的代码片断可以帮助您从图像中提取文字:
//initialize OcrEngine
OcrEngine ocrEngine = new OcrEngine();
//set the image
ocrEngine.Image = ImageStream.FromFile(“image.bmp”);
//add language and other attributes
ocrEngine.Languages.AddLanguage(Language.Load(“english”));
ocrEngine.Config.NeedRotationCorrection = false;
ocrEngine.Config.UseDefaultDictionaries = true;
//load the resource file
ocrEngine.Resource = new FileStream(“2011.07.02 v1.0 Aspose.OCR.Resouces.zip”, FileMode.Open);
//process the whole image
if (ocrEngine.Process())
{
Console.WriteLine(“Text :{0}”,ocrEngine.Text);
}
有关从图像中提取文字和以上示例所涉及的源文件的更多详情,请参考:
* Extract Text from PDF using Facades Extract Images from PDF using DOM API
* Extract Images from PDF using Facades Perform OCR on Image
* Extract Images from the PDF File
* Extract Text from the Images
* Extract Text from PDF using Facades
:
* Extract Images from PDF using Facades
OcrEngine ocrEngine = new OcrEngine();
//set the image
ocrEngine.Image = ImageStream.FromFile(“image.bmp”);
ocrEngine.Languages.AddLanguage(Language.Load(“english”));
ocrEngine.Config.NeedRotationCorrection = false;
ocrEngine.Config.UseDefaultDictionaries = true;
ocrEngine.Resource = new FileStream(“2011.07.02 v1.0 Aspose.OCR.Resouces.zip”, FileMode.Open);
if (ocrEngine.Process())
{
Console.WriteLine(“Text :{0}”,ocrEngine.Text);
}
有关从图像中提取文字和以上示例所涉及的源文件的更多详情,请参考:Perform OCR on Image