public virtual bool AttemptGoForwardToStoredNextState(RootRenderer rootRenderer) { if (storedNextArea != null) { rootRenderer.currentArea = storedNextArea; rootRenderer.currentPageNumber = storedNextArea.GetPageNumber(); rootRenderer.floatRendererAreas = storedNextFloatRenderAreas; storedNextArea = null; storedNextFloatRenderAreas = null; return(true); } else { return(false); } }
public virtual void OverflowWrapAnywhereProperty() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new MemoryStream())); pdfDoc.AddNewPage(); Document doc = new Document(pdfDoc); RootRenderer documentRenderer = doc.GetRenderer(); Text text = new Text("wow"); text.SetProperty(Property.OVERFLOW_WRAP, OverflowWrapPropertyValue.ANYWHERE); TextRenderer textRenderer = (TextRenderer)text.GetRenderer(); textRenderer.SetParent(documentRenderer); MinMaxWidth minMaxWidth = textRenderer.GetMinMaxWidth(); NUnit.Framework.Assert.IsTrue(minMaxWidth.GetMinWidth() < minMaxWidth.GetMaxWidth()); }
public virtual bool AttemptGoBackToStoredPreviousStateAndStoreNextState(RootRenderer rootRenderer) { bool result = false; if (storedPreviousArea != null) { storedNextArea = rootRenderer.currentArea; rootRenderer.currentArea = storedPreviousArea; rootRenderer.currentPageNumber = storedPreviousArea.GetPageNumber(); storedNextFloatRenderAreas = new List <Rectangle>(rootRenderer.floatRendererAreas); rootRenderer.floatRendererAreas = storedPreviousFloatRenderAreas; storedPreviousFloatRenderAreas = null; storedPreviousArea = null; result = true; } return(result); }
public virtual void OverflowWrapAnywhereItalicSimulationMaxWidth() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new MemoryStream())); pdfDoc.AddNewPage(); Document doc = new Document(pdfDoc); RootRenderer documentRenderer = doc.GetRenderer(); Text text = new Text("wow"); text.SetItalic(); TextRenderer textRenderer = (TextRenderer)text.GetRenderer(); textRenderer.SetParent(documentRenderer); float maxWidthNoOverflowWrap = textRenderer.GetMinMaxWidth().GetMaxWidth(); text.SetProperty(Property.OVERFLOW_WRAP, OverflowWrapPropertyValue.ANYWHERE); float maxWidthAndOverflowWrap = textRenderer.GetMinMaxWidth().GetMaxWidth(); NUnit.Framework.Assert.AreEqual(maxWidthAndOverflowWrap, maxWidthNoOverflowWrap, 0.0001); }
public virtual void NextRendererTest() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new MemoryStream())); pdfDoc.AddNewPage(); Document doc = new Document(pdfDoc); RootRenderer documentRenderer = doc.GetRenderer(); Text text = new Text("hello"); text.SetNextRenderer(new TextRenderer(text)); IRenderer textRenderer1 = text.GetRenderer().SetParent(documentRenderer); IRenderer textRenderer2 = text.GetRenderer().SetParent(documentRenderer); LayoutArea area = new LayoutArea(1, new Rectangle(100, 100, 100, 100)); LayoutContext layoutContext = new LayoutContext(area); doc.Close(); LayoutResult result1 = textRenderer1.Layout(layoutContext); LayoutResult result2 = textRenderer2.Layout(layoutContext); NUnit.Framework.Assert.AreEqual(result1.GetOccupiedArea(), result2.GetOccupiedArea()); }
public virtual void OverflowWrapBreakWordProperty() { PdfDocument pdfDoc = new PdfDocument(new PdfWriter(new MemoryStream())); pdfDoc.AddNewPage(); Document doc = new Document(pdfDoc); RootRenderer documentRenderer = doc.GetRenderer(); Text text = new Text("wooow"); TextRenderer textRenderer = (TextRenderer)text.GetRenderer(); textRenderer.SetParent(documentRenderer); // overflow is set here to mock LineRenderer#layout behavior documentRenderer.SetProperty(Property.OVERFLOW_X, OverflowPropertyValue.VISIBLE); float fullWordWidth = textRenderer.GetMinMaxWidth().GetMaxWidth(); LayoutArea layoutArea = new LayoutArea(1, new Rectangle(fullWordWidth / 2, AbstractRenderer.INF)); TextLayoutResult result = (TextLayoutResult)textRenderer.Layout(new LayoutContext(layoutArea)); NUnit.Framework.Assert.IsFalse(result.IsWordHasBeenSplit()); textRenderer.SetProperty(Property.OVERFLOW_WRAP, OverflowWrapPropertyValue.BREAK_WORD); result = (TextLayoutResult)textRenderer.Layout(new LayoutContext(layoutArea)); NUnit.Framework.Assert.IsTrue(result.IsWordHasBeenSplit()); }
public virtual RootRendererAreaStateHandler StorePreviousState(RootRenderer rootRenderer) { storedPreviousArea = rootRenderer.currentArea; storedPreviousFloatRenderAreas = new List <Rectangle>(rootRenderer.floatRendererAreas); return(this); }