public virtual void TestScaleWidthMode() { String testName = "testScaleWidthMode"; String path = PdfHelper.GetDefaultImagePath(); String pdfPath = PdfHelper.GetTargetDirectory() + testName + ".pdf"; FileInfo file = new FileInfo(path); float pageWidthPt = 400f; float pageHeightPt = 400f; Rectangle pageSize = new Rectangle(pageWidthPt, pageHeightPt); OcrPdfCreatorProperties properties = new OcrPdfCreatorProperties(); properties.SetScaleMode(ScaleMode.SCALE_WIDTH); properties.SetPageSize(pageSize); PdfHelper.CreatePdf(pdfPath, file, properties); Rectangle rect = GetImageBBoxRectangleFromPdf(pdfPath); ImageData originalImageData = ImageDataFactory.Create(file.FullName); // page size should be equal to the result image size // result image height should be equal to the value that // was set as page height result image width should be scaled // proportionally according to the provided image height // and original image size NUnit.Framework.Assert.AreEqual(pageHeightPt, rect.GetHeight(), DELTA); NUnit.Framework.Assert.AreEqual(originalImageData.GetWidth() / originalImageData.GetHeight(), rect.GetWidth () / rect.GetHeight(), DELTA); }
public virtual void TestScaleHeightMode() { String testName = "testScaleHeightMode"; String path = PdfHelper.GetDefaultImagePath(); String pdfPath = PdfHelper.GetTargetDirectory() + testName + ".pdf"; FileInfo file = new FileInfo(path); float pageWidthPt = 400f; float pageHeightPt = 400f; Rectangle pageSize = new Rectangle(pageWidthPt, pageHeightPt); OcrPdfCreatorProperties properties = new OcrPdfCreatorProperties(); properties.SetScaleMode(ScaleMode.SCALE_HEIGHT); properties.SetPageSize(pageSize); PdfHelper.CreatePdf(pdfPath, file, properties); Rectangle rect = GetImageBBoxRectangleFromPdf(pdfPath); ImageData originalImageData = ImageDataFactory.Create(file.FullName); NUnit.Framework.Assert.AreEqual(pageWidthPt, rect.GetWidth(), DELTA); NUnit.Framework.Assert.AreEqual(originalImageData.GetWidth() / originalImageData.GetHeight(), rect.GetWidth () / rect.GetHeight(), DELTA); }