예제 #1
0
        public virtual void SvgCssResolverInvalidNameStylesheetTest()
        {
            iText.StyledXmlParser.Jsoup.Nodes.Element jsoupLink = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag
                                                                                                                .ValueOf(SvgConstants.Tags.LINK), "");
            iText.StyledXmlParser.Jsoup.Nodes.Attributes linkAttributes = jsoupLink.Attributes();
            linkAttributes.Put(new iText.StyledXmlParser.Jsoup.Nodes.Attribute(SvgConstants.Attributes.XMLNS, "http://www.w3.org/1999/xhtml"
                                                                               ));
            linkAttributes.Put(new iText.StyledXmlParser.Jsoup.Nodes.Attribute(SvgConstants.Attributes.REL, SvgConstants.Attributes
                                                                               .STYLESHEET));
            linkAttributes.Put(new iText.StyledXmlParser.Jsoup.Nodes.Attribute(SvgConstants.Attributes.HREF, "!invalid name!externalSheet.css"
                                                                               ));
            linkAttributes.Put(new iText.StyledXmlParser.Jsoup.Nodes.Attribute("type", "text/css"));
            JsoupElementNode       node = new JsoupElementNode(jsoupLink);
            SvgConverterProperties scp  = new SvgConverterProperties();

            scp.SetBaseUri(baseUri);
            SvgProcessorContext          processorContext = new SvgProcessorContext(scp);
            SvgStyleResolver             sr           = new SvgStyleResolver(node, processorContext);
            IDictionary <String, String> attr         = sr.ResolveStyles(node, new SvgCssContext());
            IDictionary <String, String> expectedAttr = new Dictionary <String, String>();

            expectedAttr.Put(SvgConstants.Attributes.XMLNS, "http://www.w3.org/1999/xhtml");
            expectedAttr.Put(SvgConstants.Attributes.REL, SvgConstants.Attributes.STYLESHEET);
            expectedAttr.Put(SvgConstants.Attributes.HREF, "!invalid name!externalSheet.css");
            expectedAttr.Put("type", "text/css");
            NUnit.Framework.Assert.AreEqual(expectedAttr, attr);
        }
예제 #2
0
        public virtual void SvgCssResolveMalformedXlinkTest()
        {
            iText.StyledXmlParser.Jsoup.Nodes.Element jsoupImage = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag
                                                                                                                 .ValueOf("image"), "");
            iText.StyledXmlParser.Jsoup.Nodes.Attributes imageAttributes = jsoupImage.Attributes();
            imageAttributes.Put(new iText.StyledXmlParser.Jsoup.Nodes.Attribute("xlink:href", "htt://are/"));
            JsoupElementNode             node = new JsoupElementNode(jsoupImage);
            SvgStyleResolver             sr   = new SvgStyleResolver();
            IDictionary <String, String> attr = sr.ResolveStyles(node, new SvgCssContext());

            NUnit.Framework.Assert.AreEqual("htt://are/", attr.Get("xlink:href"));
        }
예제 #3
0
        public virtual void SvgCssResolveHashXlinkTest()
        {
            iText.StyledXmlParser.Jsoup.Nodes.Element jsoupImage = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag
                                                                                                                 .ValueOf("image"), "");
            iText.StyledXmlParser.Jsoup.Nodes.Attributes imageAttributes = jsoupImage.Attributes();
            imageAttributes.Put(new iText.StyledXmlParser.Jsoup.Nodes.Attribute("xlink:href", "#testid"));
            JsoupElementNode       node = new JsoupElementNode(jsoupImage);
            SvgConverterProperties scp  = new SvgConverterProperties();

            scp.SetBaseUri(baseUri);
            SvgProcessorContext          processorContext = new SvgProcessorContext(scp);
            SvgStyleResolver             sr   = new SvgStyleResolver(node, processorContext);
            IDictionary <String, String> attr = sr.ResolveStyles(node, new SvgCssContext());

            NUnit.Framework.Assert.AreEqual("#testid", attr.Get("xlink:href"));
        }
예제 #4
0
        public virtual void SvgCssResolverXlinkTest()
        {
            iText.StyledXmlParser.Jsoup.Nodes.Element jsoupImage = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag
                                                                                                                 .ValueOf("image"), "");
            iText.StyledXmlParser.Jsoup.Nodes.Attributes imageAttributes = jsoupImage.Attributes();
            imageAttributes.Put(new iText.StyledXmlParser.Jsoup.Nodes.Attribute("xlink:href", "itis.jpg"));
            JsoupElementNode       node = new JsoupElementNode(jsoupImage);
            SvgConverterProperties scp  = new SvgConverterProperties();

            scp.SetBaseUri(baseUri);
            SvgProcessorContext          processorContext = new SvgProcessorContext(scp);
            SvgStyleResolver             sr   = new SvgStyleResolver(node, processorContext);
            IDictionary <String, String> attr = sr.ResolveStyles(node, new SvgCssContext());
            String fileName    = baseUri + "itis.jpg";
            String expectedURL = UrlUtil.ToNormalizedURI(fileName).ToString();

            NUnit.Framework.Assert.AreEqual(expectedURL, attr.Get("xlink:href"));
        }