|
|
If data files are actually placed in tessdata folder, then the last parameter of renderer.Create method must be ends with "tessdata\". Code:
using (var renderer = OcrPdfRenderer.Create("Template_pdf_file", @"~\DigiSync\DigiSync.Manager\TemplateOutput\tessdata\"))
|
|
|
Thanks Paul for the help, it worked. But I have two more queries 1.How to render Annotations on PDF and to save the PDF with that annotations? 2.I am not able to convert multiple images to a single PDF. Bellow is written code for it- Code:
public void PdfCreationFromImage(List<string> imagePathList)
{
OcrApi.LicenseKey = ConfigurationManager.AppSettings["LicenseKeyOcr"];
using (var api = OcrApi.Create())
{
api.Init(Languages.English);
//Create the renderer to PDF file output. The extension will be added automatically
using (var renderer = OcrPdfRenderer.Create("Template_pdf_file", @"~\DigiSync\DigiSync.Manager\TemplateOutput\"))
{
renderer.BeginDocument("Title");
//imagePathList is a list of image path which i want to combine to form a single PDF
foreach (var item in imagePathList)
{
api.ProcessPages(item, null, 0, renderer);
}
renderer.EndDocument();
}
}
}
i have tried the following link provided by you to convert image to PDF but didn't work. https://tesseract.patagames.com/
|
|
|
|
|
|
Quote 1: Selected region means Rectangle selected by using MouseDown,MouseMove,MoveUp and Paint events of pdfViewer to get the coordinates. I have tried to get coordinates by using windows canvas method, but I am not able to get the exact coordinates of Selected rectangle considering the PDF document. Can you please provide me code to draw Coordinates of rectangle selected by us on PDF document in PDFViewer. Quote 2: The output of bellow code is not the same region data of which I have given the coordinates,I am getting data which is not selected. I am not able to get the exact data from the rectangle drawn over PDF. Code is bellow: Code:
foreach (var itemdata in pdflist)
{
Ocr ocr = new Ocr();
InitWebApp();
using (var doc = PdfDocument.Load(itemdata))
{
using (var page = doc.Pages[0])
{
templateId = Convert.ToInt32(cmbSelTemplate.SelectedValue);
List<Ocr> tempMetadata = mapperController.GetOcrMetadata(templateId);//templateMetadata gets the list of coordinates i.e. left,top,right,bottom
//delcare a dict with key and value string key-name
Dictionary<string, string> ocrTemp = new Dictionary<string, string>();
foreach (var item in tempMetadata)
{
var textInfo = page.Text.GetBoundedText(Convert.ToInt32(item.Left ), Convert.ToInt32(item.Top), Convert.ToInt32((item.Right - item.Left) ), Convert.ToInt32((item.Bottom - item.Top) ));
ocrTemp.Add(item.Name, textInfo);
}
CreateXML(itemdata, ocrTemp);
}
}
}
Quote 3: The output of bellow code is not in appropriate Human readable language,it is combination of characters,numbers and symbols.I am not able to get the exact data from the rectangle drawn over PDF. Code is bellow: Code:
OcrApi.LicenseKey = ConfigurationManager.AppSettings["LicenseKeyOcr"];
using (var api = OcrApi.Create())
{
templateId = Convert.ToInt32(cmbSelTemplate.SelectedValue);
List<Ocr> tempMetadata = mapperController.GetOcrMetadata(templateId);
foreach (var item in tempMetadata)
{
api.Init(Languages.English);
var rect = new Rectangle(Convert.ToInt32(item.Left), Convert.ToInt32(item.Top), Convert.ToInt32((item.Right - item.Left)), Convert.ToInt32((item.Bottom - item.Top)));
string plainText = api.GetTextFromImage(filepath, rect.Location.X,rect.Location.Y,rect.Size.Width,rect.Size.Height);
ocrTemp.Add(item.Name, plainText);
}
return ocrTemp;
}
|
|
|
Originally Posted by: Akshara  1) I am not able to get coordinates of selected region in PDF using Pdfium pdf viewer What exactly you mean when you say "selected region"? Quote: 2) I am not able to extract data from respective selected coordinate using "GetBoundedText(float left, float top, float right, float bottom)" function
Please let me see your code. Quote: 3) I am no able to extract data from selected region in image by passing coordinates to function "GetTextFromImage(filepath, rect.Location.X,rect.Location.Y,rect.Size.Width,rect.Size.Height)".
Pdfium has now any methods named "GetTextFromImage"
|
|
|
1) I am not able to get coordinates of selected region in PDF using Pdfium pdf viewer 2) I am not able to extract data from respective selected coordinate using "GetBoundedText(float left, float top, float right, float bottom)" function 3) I am no able to extract data from selected region in image by passing coordinates to function "GetTextFromImage(filepath, rect.Location.X,rect.Location.Y,rect.Size.Width,rect.Size.Height)".
above are my issues please provide me with solution.
|