Esempio n. 1
0
        public virtual void ProcessDefsParentShouldBeNullTest()
        {
            INode parsedSvg = SvgConverter.Parse(new FileStream(sourceFolder + "onlyDefsWithOneChild.svg", FileMode.Open
                                                                , FileAccess.Read));
            ISvgProcessorResult result = new DefaultSvgProcessor().Process(parsedSvg);

            NUnit.Framework.Assert.IsNull(result.GetNamedObjects().Get("circle1").GetParent());
        }
Esempio n. 2
0
        public virtual void ProcessDefsNoChildrenTest()
        {
            INode parsedSvg = SvgConverter.Parse(new FileStream(sourceFolder + "onlyDefsWithNoChildren.svg", FileMode.Open
                                                                , FileAccess.Read));
            ISvgProcessorResult result = new DefaultSvgProcessor().Process(parsedSvg);

            NUnit.Framework.Assert.IsTrue(result.GetNamedObjects().IsEmpty());
        }
Esempio n. 3
0
        public virtual void ProcessDefsOneChildTest()
        {
            INode parsedSvg = SvgConverter.Parse(new FileStream(sourceFolder + "onlyDefsWithOneChild.svg", FileMode.Open
                                                                , FileAccess.Read));
            ISvgProcessorResult result = new DefaultSvgProcessor().Process(parsedSvg, null);

            NUnit.Framework.Assert.IsTrue(result.GetNamedObjects().Get("circle1") is CircleSvgNodeRenderer);
        }
Esempio n. 4
0
        public virtual void AddNamedObject()
        {
            INode parsedSvg = SvgConverter.Parse(new FileStream(iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
                                                                                                              .CurrentContext.TestDirectory) + "/resources/itext/svg/renderers/impl/NamedObjectsTest/names.svg", FileMode.Open
                                                                , FileAccess.Read));
            ISvgProcessorResult result = new DefaultSvgProcessor().Process(parsedSvg);

            NUnit.Framework.Assert.IsTrue(result.GetNamedObjects().Get("name_svg") is SvgTagSvgNodeRenderer);
            NUnit.Framework.Assert.IsTrue(result.GetNamedObjects().Get("name_rect") is RectangleSvgNodeRenderer);
        }
        public virtual void NamedObjectRectangleTest()
        {
            String              svgFile                   = sourceFolder + "namedObjectRectangleTest.svg";
            Stream              svg                       = new FileStream(svgFile, FileMode.Open, FileAccess.Read);
            JsoupXmlParser      xmlParser                 = new JsoupXmlParser();
            IDocumentNode       root                      = xmlParser.Parse(svg, null);
            ISvgProcessorResult processorResult           = new DefaultSvgProcessor().Process(root);
            IDictionary <String, ISvgNodeRenderer> actual = processorResult.GetNamedObjects();

            NUnit.Framework.Assert.AreEqual(1, actual.Count);
            NUnit.Framework.Assert.IsTrue(actual.ContainsKey("MyRect"));
        }
        public virtual void SmoothCurveTest3()
        {
            String      filename = "smoothCurveTest3.pdf";
            PdfDocument doc      = new PdfDocument(new PdfWriter(destinationFolder + filename));

            doc.AddNewPage();
            String                 svgFilename = "smoothCurveTest3.svg";
            Stream                 xmlStream   = new FileStream(sourceFolder + svgFilename, FileMode.Open, FileAccess.Read);
            IElementNode           rootTag     = new JsoupXmlParser().Parse(xmlStream, "ISO-8859-1");
            DefaultSvgProcessor    processor   = new DefaultSvgProcessor();
            IBranchSvgNodeRenderer root        = (IBranchSvgNodeRenderer)processor.Process(rootTag, null).GetRootRenderer();
            SvgDrawContext         context     = new SvgDrawContext(null, null);
            PdfCanvas              cv          = new PdfCanvas(doc, 1);

            context.PushCanvas(cv);
            NUnit.Framework.Assert.IsTrue(root.GetChildren()[0] is PathSvgNodeRenderer);
            root.GetChildren()[0].Draw(context);
            doc.Close();
        }