예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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));
        }
예제 #5
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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));
        }