public virtual void AddAndGetPageByDestinationNullOccupiedAreaTest() { DocumentRenderer documentRenderer = new DocumentRenderer(null); String id = "id"; IRenderer renderer = new _TextRenderer_111(new Text("renderer")); renderer.SetParent(documentRenderer); renderer.SetProperty(Property.ID, id); TargetCounterHandler.AddPageByID(renderer); int?page = TargetCounterHandler.GetPageByID(renderer, id); NUnit.Framework.Assert.IsNull(page); }
public virtual void AddAndGetPageByDestinationNotDocumentRendererTest() { RootRenderer documentRenderer = new _RootRenderer_41(); String id = "id"; int expectedPage = 5; IRenderer renderer = new _TextRenderer_60(expectedPage, new Text("renderer")); renderer.SetParent(documentRenderer); renderer.SetProperty(Property.ID, id); TargetCounterHandler.AddPageByID(renderer); int?page = TargetCounterHandler.GetPageByID(renderer, id); NUnit.Framework.Assert.IsNull(page); }
public virtual void AddAndGetPageByDestinationDoubleAddDecreasedTest() { DocumentRenderer documentRenderer = new DocumentRenderer(null); String id = "id"; IRenderer renderer = new _TextRenderer_152(new Text("renderer")); renderer.SetParent(documentRenderer); renderer.SetProperty(Property.ID, id); TargetCounterHandler.AddPageByID(renderer); TargetCounterHandler.AddPageByID(renderer); documentRenderer.GetTargetCounterHandler().PrepareHandlerToRelayout(); int?page = TargetCounterHandler.GetPageByID(renderer, id); NUnit.Framework.Assert.AreEqual((int?)2, page); }
public virtual void ParagraphRendererAddByIDTest() { DocumentRenderer documentRenderer = new DocumentRenderer(null); ParagraphRenderer paragraphRenderer = new ParagraphRenderer(new Paragraph()); paragraphRenderer.SetParent(documentRenderer); String id = "id5"; paragraphRenderer.SetProperty(Property.ID, id); LayoutContext layoutContext = new LayoutContext(new LayoutArea(4, new Rectangle(50, 50))); paragraphRenderer.Layout(layoutContext); documentRenderer.GetTargetCounterHandler().PrepareHandlerToRelayout(); NUnit.Framework.Assert.AreEqual((int?)4, TargetCounterHandler.GetPageByID(paragraphRenderer, id)); }
public virtual void ImageRendererAddByIDTest() { DocumentRenderer documentRenderer = new DocumentRenderer(null); ImageRenderer imageRenderer = new ImageRenderer(new Image(ImageDataFactory.CreateRawImage(new byte[] { 50, 21 }))); imageRenderer.SetParent(documentRenderer); String id = "id6"; imageRenderer.SetProperty(Property.ID, id); LayoutContext layoutContext = new LayoutContext(new LayoutArea(4, new Rectangle(50, 50))); imageRenderer.Layout(layoutContext); documentRenderer.GetTargetCounterHandler().PrepareHandlerToRelayout(); NUnit.Framework.Assert.AreEqual((int?)4, TargetCounterHandler.GetPageByID(imageRenderer, id)); }
/// <summary><inheritDoc/></summary> public override LayoutResult Layout(LayoutContext layoutContext) { String previousText = GetText().ToString(); int? page = TargetCounterHandler.GetPageByID(this, target); if (page == null) { SetText(UNDEFINED_VALUE); } else { SetText(HtmlUtils.ConvertNumberAccordingToGlyphStyle(digitsGlyphStyle, (int)page)); } LayoutResult result = base.Layout(layoutContext); SetText(previousText); return(result); }
public virtual void AddAndGetPageByDestinationTest() { DocumentRenderer documentRenderer = new DocumentRenderer(null); String id = "id"; int expectedPage = 5; IRenderer renderer = new _TextRenderer_175(expectedPage, new Text("renderer")); renderer.SetParent(documentRenderer); renderer.SetProperty(Property.ID, id); TargetCounterHandler.AddPageByID(renderer); documentRenderer.GetTargetCounterHandler().PrepareHandlerToRelayout(); int?page = TargetCounterHandler.GetPageByID(renderer, id); NUnit.Framework.Assert.AreEqual((int?)expectedPage, page); IRenderer anotherRenderer = new TextRenderer(new Text("another_renderer")); anotherRenderer.SetParent(documentRenderer); page = TargetCounterHandler.GetPageByID(anotherRenderer, id); NUnit.Framework.Assert.AreEqual((int?)expectedPage, page); }
public virtual void TextRendererAddByIDTest() { DocumentRenderer documentRenderer = new DocumentRenderer(null); TextRenderer textRenderer = new TextRenderer(new Text("a")); textRenderer.SetProperty(Property.TEXT_RISE, 20F); textRenderer.SetProperty(Property.CHARACTER_SPACING, 20F); textRenderer.SetProperty(Property.WORD_SPACING, 20F); textRenderer.SetProperty(Property.FONT, PdfFontFactory.CreateFont(StandardFonts.HELVETICA)); textRenderer.SetProperty(Property.FONT_SIZE, new UnitValue(UnitValue.POINT, 20)); textRenderer.SetProperty(Property.SPLIT_CHARACTERS, new DefaultSplitCharacters()); textRenderer.SetParent(documentRenderer); String id = "id7"; textRenderer.SetProperty(Property.ID, id); LayoutContext layoutContext = new LayoutContext(new LayoutArea(4, new Rectangle(50, 50))); textRenderer.Layout(layoutContext); documentRenderer.GetTargetCounterHandler().PrepareHandlerToRelayout(); NUnit.Framework.Assert.AreEqual((int?)4, TargetCounterHandler.GetPageByID(textRenderer, id)); }