1
Tesseractを使用してJPG画像をスキャンすることができます。ITextSharpを使用して通常のPDFをスキャンし、それらのテキストを取得できます。しかし、拡張子が.PDFのスキャンされたPDFからテキストを取得する方法や、PDFをイメージに変換してTesseractでスキャンする方法はありません。私が紛失しているオプションはありますか?ありがとう!スキャンしたPDFを画像に変換する
Tesseractを使用してJPG画像をスキャンすることができます。ITextSharpを使用して通常のPDFをスキャンし、それらのテキストを取得できます。しかし、拡張子が.PDFのスキャンされたPDFからテキストを取得する方法や、PDFをイメージに変換してTesseractでスキャンする方法はありません。私が紛失しているオプションはありますか?ありがとう!スキャンしたPDFを画像に変換する
PDFドキュメントをスキャンしたと仮定します。第二に、PDF文書内にテキストだけがあると仮定します。あなたは、以下の方法からテキストから画像を生成することができる
private Image DrawText(String text, Font font, Color textColor, Color backColor)
{
//first, create a dummy bitmap just to get a graphics object
Image img = new Bitmap(1, 1);
Graphics drawing = Graphics.FromImage(img);
//measure the string to see how big the image needs to be
SizeF textSize = drawing.MeasureString(text, font);
//free up the dummy image and old graphics object
img.Dispose();
drawing.Dispose();
//create a new image of the right size
img = new Bitmap((int) textSize.Width, (int)textSize.Height);
drawing = Graphics.FromImage(img);
//paint the background
drawing.Clear(backColor);
//create a brush for the text
Brush textBrush = new SolidBrush(textColor);
drawing.DrawString(text, font, textBrush, 0, 0);
drawing.Save();
textBrush.Dispose();
drawing.Dispose();
return img;
}