public virtual void TestTextInfo() { String path = PdfHelper.GetDefaultImagePath(); IDictionary <int, IList <TextInfo> > result = new CustomOcrEngine().DoImageOcr(new FileInfo(path)); NUnit.Framework.Assert.AreEqual(1, result.Count); TextInfo textInfo = new TextInfo(); textInfo.SetText("text"); textInfo.SetBbox(JavaUtil.ArraysAsList(204.0f, 158.0f, 742.0f, 294.0f)); int page = 2; result.Put(page, JavaCollectionsUtil.SingletonList <TextInfo>(textInfo)); NUnit.Framework.Assert.AreEqual(2, result.Count); NUnit.Framework.Assert.AreEqual(textInfo.GetText(), result.Get(page)[0].GetText()); NUnit.Framework.Assert.AreEqual(textInfo.GetBbox().Count, result.Get(page)[0].GetBbox().Count); }
public virtual void TestPdfLayersWithDefaultNames() { String path = PdfHelper.GetDefaultImagePath(); FileInfo file = new FileInfo(path); OcrEngineProperties ocrEngineProperties = new OcrEngineProperties(); ocrEngineProperties.SetLanguages(JavaCollectionsUtil.SingletonList <String>("eng")); CustomOcrEngine engine = new CustomOcrEngine(ocrEngineProperties); OcrPdfCreator ocrPdfCreator = new OcrPdfCreator(engine); PdfDocument doc = ocrPdfCreator.CreatePdf(JavaCollectionsUtil.SingletonList <FileInfo>(file), PdfHelper.GetPdfWriter ()); NUnit.Framework.Assert.IsNotNull(doc); IList <PdfLayer> layers = doc.GetCatalog().GetOCProperties(true).GetLayers(); NUnit.Framework.Assert.AreEqual(0, layers.Count); doc.Close(); NUnit.Framework.Assert.AreEqual(engine, ocrPdfCreator.GetOcrEngine()); NUnit.Framework.Assert.AreEqual(1, engine.GetOcrEngineProperties().GetLanguages().Count); NUnit.Framework.Assert.AreEqual("eng", engine.GetOcrEngineProperties().GetLanguages()[0]); }