示例#1
0
        public virtual void SvgCssResolverBasicAttributeTest()
        {
            iText.StyledXmlParser.Jsoup.Nodes.Element jsoupCircle = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag
                                                                                                                  .ValueOf("circle"), "");
            Attributes circleAttributes = jsoupCircle.Attributes();

            circleAttributes.Put(new iText.StyledXmlParser.Jsoup.Nodes.Attribute("id", "circle1"));
            circleAttributes.Put(new iText.StyledXmlParser.Jsoup.Nodes.Attribute("cx", "95"));
            circleAttributes.Put(new iText.StyledXmlParser.Jsoup.Nodes.Attribute("cy", "95"));
            circleAttributes.Put(new iText.StyledXmlParser.Jsoup.Nodes.Attribute("rx", "53"));
            circleAttributes.Put(new iText.StyledXmlParser.Jsoup.Nodes.Attribute("ry", "53"));
            circleAttributes.Put(new iText.StyledXmlParser.Jsoup.Nodes.Attribute("style", "stroke-width:1.5;stroke:#da0000;"
                                                                                 ));
            AbstractCssContext cssContext = new SvgCssContext();
            INode circle = new JsoupElementNode(jsoupCircle);
            SvgProcessorContext          context  = new SvgProcessorContext(new SvgConverterProperties());
            ICssResolver                 resolver = new SvgStyleResolver(circle, context);
            IDictionary <String, String> actual   = resolver.ResolveStyles(circle, cssContext);
            IDictionary <String, String> expected = new Dictionary <String, String>();

            expected.Put("id", "circle1");
            expected.Put("cx", "95");
            expected.Put("cy", "95");
            expected.Put("rx", "53");
            expected.Put("ry", "53");
            expected.Put("stroke-width", "1.5");
            expected.Put("stroke", "#da0000");
            NUnit.Framework.Assert.AreEqual(expected, actual);
        }
 /// <summary>Load in configuration, set initial processorState and create/fill-in context of the processor</summary>
 /// <param name="converterProps">that contains configuration properties and operations</param>
 internal virtual void PerformSetup(INode root, ISvgConverterProperties converterProps)
 {
     processorState = new ProcessorState();
     if (converterProps.GetRendererFactory() != null) {
         rendererFactory = converterProps.GetRendererFactory();
     }
     context = new SvgProcessorContext(converterProps);
     cssResolver = new SvgStyleResolver(root, context);
     new SvgFontProcessor(context).AddFontFaceFonts(cssResolver);
     //TODO RND-1042
     namedObjects = new Dictionary<String, ISvgNodeRenderer>();
     cssContext = new SvgCssContext();
 }
示例#3
0
        public virtual void SvgCssResolverStyleTagTest()
        {
            iText.StyledXmlParser.Jsoup.Nodes.Element styleTag = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag
                                                                                                               .ValueOf("style"), "");
            TextNode styleContents = new TextNode("\n" + "\tellipse{\n" + "\t\tstroke-width:1.76388889;\n" + "\t\tstroke:#da0000;\n"
                                                  + "\t\tstroke-opacity:1;\n" + "\t}\n" + "  ", "");
            JsoupElementNode jSoupStyle = new JsoupElementNode(styleTag);

            jSoupStyle.AddChild(new JsoupTextNode(styleContents));
            iText.StyledXmlParser.Jsoup.Nodes.Element ellipse = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag
                                                                                                              .ValueOf("ellipse"), "");
            JsoupElementNode             jSoupEllipse = new JsoupElementNode(ellipse);
            SvgProcessorContext          context      = new SvgProcessorContext(new SvgConverterProperties());
            SvgStyleResolver             resolver     = new SvgStyleResolver(jSoupStyle, context);
            AbstractCssContext           svgContext   = new SvgCssContext();
            IDictionary <String, String> actual       = resolver.ResolveStyles(jSoupEllipse, svgContext);
            IDictionary <String, String> expected     = new Dictionary <String, String>();

            expected.Put("stroke-width", "1.76388889");
            expected.Put("stroke", "#da0000");
            expected.Put("stroke-opacity", "1");
            NUnit.Framework.Assert.AreEqual(expected, actual);
        }