public virtual void DummyProcessingTestCorrectNested() { //Setup nodes iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGRoot = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("svg"), ""); iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGCircle = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("circle"), ""); iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGPath = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("path"), ""); INode root = new JsoupElementNode(jsoupSVGRoot); root.AddChild(new JsoupElementNode(jsoupSVGCircle)); root.AddChild(new JsoupElementNode(jsoupSVGPath)); INode nestedSvg = new JsoupElementNode(jsoupSVGRoot); nestedSvg.AddChild(new JsoupElementNode(jsoupSVGCircle)); nestedSvg.AddChild(new JsoupElementNode(jsoupSVGCircle)); root.AddChild(nestedSvg); //Run DefaultSvgProcessor processor = new DefaultSvgProcessor(); ISvgConverterProperties props = new DummySvgConverterProperties(); ISvgNodeRenderer rootActual = processor.Process(root, props).GetRootRenderer(); //setup expected IBranchSvgNodeRenderer rootExpected = new DummyBranchSvgNodeRenderer("svg"); rootExpected.AddChild(new DummySvgNodeRenderer("circle")); rootExpected.AddChild(new DummySvgNodeRenderer("path")); IBranchSvgNodeRenderer nestedSvgRend = new DummyBranchSvgNodeRenderer("svg"); nestedSvgRend.AddChild(new DummySvgNodeRenderer("circle")); nestedSvgRend.AddChild(new DummySvgNodeRenderer("circle")); rootExpected.AddChild(nestedSvgRend); //Compare NUnit.Framework.Assert.AreEqual(rootActual, rootExpected); }
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); }
public virtual void ProcessPropsNullTest() { INode svg = new JsoupElementNode(new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("svg"), "")); SvgConverter.Process(svg, null); }
public virtual void LangAttrInDisplayTableForTaggedPdfTest() { Attributes attributes = new Attributes(); attributes.Put(AttributeConstants.LANG, "en"); iText.StyledXmlParser.Jsoup.Nodes.Element element = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf(TagConstants.DIV), TagConstants.DIV, attributes); JsoupElementNode node = new JsoupElementNode(element); IDictionary <String, String> styles = new Dictionary <String, String>(); styles.Put(CssConstants.WHITE_SPACE, CssConstants.NORMAL); styles.Put(CssConstants.TEXT_TRANSFORM, CssConstants.LOWERCASE); styles.Put(CssConstants.DISPLAY, CssConstants.TABLE); node.SetStyles(styles); ProcessorContext processorContext = new ProcessorContext(new ConverterProperties()); DisplayTableTagWorker tagWorker = new DisplayTableTagWorker(node, processorContext); tagWorker.ProcessEnd(node, processorContext); IPropertyContainer propertyContainer = tagWorker.GetElementResult(); NUnit.Framework.Assert.IsTrue(propertyContainer is Table); String lang = ((IAccessibleElement)propertyContainer).GetAccessibilityProperties().GetLanguage(); NUnit.Framework.Assert.AreEqual("en", lang); }
public virtual void CustomDestinationPrefixTest() { IDictionary <String, int?> priorityMappings = new Dictionary <String, int?>(); priorityMappings.Put("p", 1); OutlineHandler outlineHandler = new OutlineHandler().PutAllTagPriorityMappings(priorityMappings); outlineHandler.SetDestinationNamePrefix("prefix-"); NUnit.Framework.Assert.AreEqual("prefix-", outlineHandler.GetDestinationNamePrefix()); ProcessorContext context = new ProcessorContext(new ConverterProperties().SetOutlineHandler(outlineHandler )); context.Reset(new PdfDocument(new PdfWriter(new MemoryStream()))); IElementNode elementNode = new JsoupElementNode(new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf(TagConstants.P), TagConstants.P)); IDictionary <String, String> styles = new Dictionary <String, String>(); styles.Put(CssConstants.WHITE_SPACE, CssConstants.NORMAL); styles.Put(CssConstants.TEXT_TRANSFORM, CssConstants.LOWERCASE); // Styles are required in the constructor of the PTagWorker class elementNode.SetStyles(styles); outlineHandler.AddOutlineAndDestToDocument(new PTagWorker(elementNode, context), elementNode, context); PdfOutline pdfOutline = context.GetPdfDocument().GetOutlines(false).GetAllChildren()[0]; NUnit.Framework.Assert.AreEqual("p1", pdfOutline.GetTitle()); PdfString pdfStringDest = (PdfString)pdfOutline.GetDestination().GetPdfObject(); NUnit.Framework.Assert.AreEqual("prefix-1", pdfStringDest.ToUnicodeString()); }
public virtual void SvgCssResolverStylesheetTest() { iText.StyledXmlParser.Jsoup.Nodes.Element jsoupLink = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf(SvgConstants.Tags.LINK), ""); 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, "styleSheetWithLinkStyle.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, "styleSheetWithLinkStyle.css"); expectedAttr.Put("type", "text/css"); // Attribute from external stylesheet expectedAttr.Put(SvgConstants.Attributes.FILL, "black"); NUnit.Framework.Assert.AreEqual(expectedAttr, attr); }
public virtual void DefaultProcessingCorrectlyNestedRenderersTest() { //Setup nodes iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGRoot = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("svg"), ""); iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGCircle = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("circle"), ""); iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGPath = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("path"), ""); INode root = new JsoupElementNode(jsoupSVGRoot); root.AddChild(new JsoupElementNode(jsoupSVGCircle)); root.AddChild(new JsoupElementNode(jsoupSVGPath)); //Run DefaultSvgProcessor processor = new DefaultSvgProcessor(); SvgConverterProperties convProps = new SvgConverterProperties(); ISvgNodeRenderer rootRenderer = processor.Process(root, convProps).GetRootRenderer(); NUnit.Framework.Assert.IsTrue(rootRenderer is SvgTagSvgNodeRenderer); IList <ISvgNodeRenderer> children = ((SvgTagSvgNodeRenderer)rootRenderer).GetChildren(); NUnit.Framework.Assert.AreEqual(2, children.Count); NUnit.Framework.Assert.IsTrue(children[0] is CircleSvgNodeRenderer); NUnit.Framework.Assert.IsTrue(children[1] is PathSvgNodeRenderer); }
public virtual void Test06() { String htmlFileName = sourceFolder + "html06.html"; String cssFileName = sourceFolder + "css06.css"; IXmlParser htmlParser = new JsoupHtmlParser(); IDocumentNode document = htmlParser.Parse(new FileStream(htmlFileName, FileMode.Open, FileAccess.Read), "UTF-8" ); CssStyleSheet css = CssStyleSheetParser.Parse(new FileStream(cssFileName, FileMode.Open, FileAccess.Read)); IElementNode element = new JsoupElementNode(((JsoupDocumentNode)document).GetDocument().GetElementsByTag("p" ).First()); MediaDeviceDescription deviceDescription1 = new MediaDeviceDescription(MediaType.PRINT).SetBitsPerComponent (2); MediaDeviceDescription deviceDescription2 = new MediaDeviceDescription(MediaType.HANDHELD).SetBitsPerComponent (2); MediaDeviceDescription deviceDescription3 = new MediaDeviceDescription(MediaType.SCREEN).SetBitsPerComponent (1); IList <CssDeclaration> declarations1 = css.GetCssDeclarations(element, deviceDescription1); IList <CssDeclaration> declarations2 = css.GetCssDeclarations(element, deviceDescription2); IList <CssDeclaration> declarations3 = css.GetCssDeclarations(element, deviceDescription3); NUnit.Framework.Assert.IsTrue(Enumerable.SequenceEqual(declarations1, declarations2)); NUnit.Framework.Assert.AreEqual(0, declarations3.Count); NUnit.Framework.Assert.AreEqual(1, declarations1.Count); NUnit.Framework.Assert.AreEqual("color: red", declarations1[0].ToString()); }
public virtual void NonExistingTagTest() { iText.StyledXmlParser.Jsoup.Nodes.Element nonExistingElement = new iText.StyledXmlParser.Jsoup.Nodes.Element (iText.StyledXmlParser.Jsoup.Parser.Tag.ValueOf("notAnExistingTag"), ""); IElementNode tag = new JsoupElementNode(nonExistingElement); fact.CreateSvgNodeRendererForTag(tag, null); }
public virtual void HasBeforeElementTest() { iText.StyledXmlParser.Jsoup.Nodes.Element element = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("before"), ""); IElementNode node = new JsoupElementNode(element); NUnit.Framework.Assert.IsTrue(CssPseudoElementUtil.HasBeforeAfterElements(node)); }
/// <summary> /// Wraps JSoup nodes into pdfHTML /// <see cref="iText.StyledXmlParser.Node.INode"/> /// classes. /// </summary> /// <param name="jsoupNode">the JSoup node instance</param> /// <returns> /// the /// <see cref="iText.StyledXmlParser.Node.INode"/> /// instance /// </returns> private INode WrapJsoupHierarchy(iText.StyledXmlParser.Jsoup.Nodes.Node jsoupNode) { INode resultNode = null; if (jsoupNode is Document) { resultNode = new JsoupDocumentNode((Document)jsoupNode); } else { if (jsoupNode is TextNode) { resultNode = new JsoupTextNode((TextNode)jsoupNode); } else { if (jsoupNode is iText.StyledXmlParser.Jsoup.Nodes.Element) { resultNode = new JsoupElementNode((iText.StyledXmlParser.Jsoup.Nodes.Element)jsoupNode); } else { if (jsoupNode is DataNode) { resultNode = new JsoupDataNode((DataNode)jsoupNode); } else { if (jsoupNode is DocumentType) { resultNode = new JsoupDocumentTypeNode((DocumentType)jsoupNode); } else { if (jsoupNode is Comment || jsoupNode is XmlDeclaration) { } else { // Ignore. We should do this to avoid redundant log message logger.Error(MessageFormatUtil.Format(iText.StyledXmlParser.LogMessageConstant.ERROR_PARSING_COULD_NOT_MAP_NODE , jsoupNode.GetType())); } } } } } } foreach (iText.StyledXmlParser.Jsoup.Nodes.Node node in jsoupNode.ChildNodes()) { INode childNode = WrapJsoupHierarchy(node); if (childNode != null) { resultNode.AddChild(childNode); } } return(resultNode); }
public virtual void TestMessageAddingChild() { iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGRoot = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("svg"), ""); INode root = new JsoupElementNode(jsoupSVGRoot); root.AddChild(null); NUnit.Framework.Assert.AreEqual(0, root.ChildNodes().Count); }
public virtual void ElementNodeAttributeIsNotStylesheet() { iText.StyledXmlParser.Jsoup.Nodes.Element element = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("link"), ""); element.Attr(CommonAttributeConstants.REL, ""); JsoupElementNode elementNode = new JsoupElementNode(element); NUnit.Framework.Assert.IsFalse(CssUtils.IsStyleSheetLink(elementNode)); }
public virtual void RootTagTest() { iText.StyledXmlParser.Jsoup.Nodes.Element element = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("dummy"), ""); IElementNode tag = new JsoupElementNode(element); ISvgNodeRenderer childRenderer = fact.CreateSvgNodeRendererForTag(tag, null); NUnit.Framework.Assert.IsTrue(childRenderer is DummySvgNodeRenderer); }
/// <summary> /// Wraps JSoup nodes into pdfHTML /// <see cref="iText.StyledXmlParser.Node.INode"/> /// classes. /// </summary> /// <param name="jsoupNode">the JSoup node instance</param> /// <returns> /// the /// <see cref="iText.StyledXmlParser.Node.INode"/> /// instance /// </returns> private INode WrapJsoupHierarchy(iText.StyledXmlParser.Jsoup.Nodes.Node jsoupNode) { INode resultNode = null; if (jsoupNode is Document) { resultNode = new JsoupDocumentNode((Document)jsoupNode); } else { if (jsoupNode is TextNode) { resultNode = new JsoupTextNode((TextNode)jsoupNode); } else { if (jsoupNode is iText.StyledXmlParser.Jsoup.Nodes.Element) { resultNode = new JsoupElementNode((iText.StyledXmlParser.Jsoup.Nodes.Element)jsoupNode); } else { if (jsoupNode is DataNode) { resultNode = new JsoupDataNode((DataNode)jsoupNode); } else { if (jsoupNode is DocumentType) { resultNode = new JsoupDocumentTypeNode((DocumentType)jsoupNode); } else { if (jsoupNode is Comment) { } else { logger.Error(MessageFormatUtil.Format("Could not map node type: {0}", jsoupNode.GetType())); } } } } } } foreach (iText.StyledXmlParser.Jsoup.Nodes.Node node in jsoupNode.ChildNodes()) { INode childNode = WrapJsoupHierarchy(node); if (childNode != null) { resultNode.AddChild(childNode); } } return(resultNode); }
public virtual void ParseStreamWithProps() { INode actual = SvgConverter.Parse(@is, new DummySvgConverterProperties()); NUnit.Framework.Assert.AreEqual(1, actual.ChildNodes().Count); JsoupElementNode node = (JsoupElementNode)actual.ChildNodes()[0]; NUnit.Framework.Assert.AreEqual("svg", node.Name()); NUnit.Framework.Assert.AreEqual(0, node.ChildNodes().Count); }
public virtual void CustomMapperTest() { fact = new DefaultSvgNodeRendererFactory(new DefaultSvgNodeRendererFactoryTest.LocalTestMapper()); iText.StyledXmlParser.Jsoup.Nodes.Element element = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("test"), ""); IElementNode tag = new JsoupElementNode(element); ISvgNodeRenderer rend = fact.CreateSvgNodeRendererForTag(tag, null); NUnit.Framework.Assert.IsTrue(rend is DummyProcessableSvgNodeRenderer); }
public virtual void ProcessNode() { INode svg = new JsoupElementNode(new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("svg"), "")); IBranchSvgNodeRenderer node = (IBranchSvgNodeRenderer)SvgConverter.Process(svg).GetRootRenderer(); NUnit.Framework.Assert.IsTrue(node is SvgTagSvgNodeRenderer); NUnit.Framework.Assert.AreEqual(0, node.GetChildren().Count); NUnit.Framework.Assert.IsNull(node.GetParent()); }
public virtual void ParseString() { INode actual = SvgConverter.Parse(content); NUnit.Framework.Assert.AreEqual(1, actual.ChildNodes().Count); JsoupElementNode node = (JsoupElementNode)actual.ChildNodes()[0]; NUnit.Framework.Assert.AreEqual("svg", node.Name()); NUnit.Framework.Assert.AreEqual(0, node.ChildNodes().Count); }
public virtual void EmptyStreamTest() { ICssResolver styleResolver = new SvgStyleResolver(new MemoryStream(new byte[] { })); iText.StyledXmlParser.Jsoup.Nodes.Element svg = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("svg"), ""); INode svgNode = new JsoupElementNode(svg); IDictionary <String, String> resolvedStyles = styleResolver.ResolveStyles(svgNode, null); NUnit.Framework.Assert.AreEqual(0, resolvedStyles.Count); }
public virtual void ParseStreamWithOtherEncoding() { @is = new MemoryStream(content.GetBytes(Encoding.Unicode)); INode actual = SvgConverter.Parse(@is, new SvgConverterUnitTest.OtherCharsetDummySvgConverterProperties()); NUnit.Framework.Assert.AreEqual(1, actual.ChildNodes().Count); JsoupElementNode node = (JsoupElementNode)actual.ChildNodes()[0]; NUnit.Framework.Assert.AreEqual("svg", node.Name()); NUnit.Framework.Assert.AreEqual(0, node.ChildNodes().Count); }
public virtual void CompareIsStyleSheetLinkResult() { iText.StyledXmlParser.Jsoup.Nodes.Element element = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("link"), ""); element.Attr(CommonAttributeConstants.REL, CommonAttributeConstants.STYLESHEET); JsoupElementNode elementNode = new JsoupElementNode(element); bool expected = CssUtils.IsStyleSheetLink(elementNode); bool actual = HtmlUtils.IsStyleSheetLink(elementNode); NUnit.Framework.Assert.AreEqual(actual, expected); }
public virtual void ProtectedConstructorTest() { NUnit.Framework.Assert.That(() => { iText.StyledXmlParser.Jsoup.Nodes.Element protectedElement = new iText.StyledXmlParser.Jsoup.Nodes.Element (iText.StyledXmlParser.Jsoup.Parser.Tag.ValueOf("protected"), ""); IElementNode tag = new JsoupElementNode(protectedElement); fact.CreateSvgNodeRendererForTag(tag, null); } , NUnit.Framework.Throws.InstanceOf <SvgProcessingException>()) ; }
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")); }
public virtual void OverrideDefaultStyleTest() { ICssResolver styleResolver = new SvgStyleResolver(new SvgProcessorContext(new SvgConverterProperties())); iText.StyledXmlParser.Jsoup.Nodes.Element svg = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("svg"), ""); svg.Attributes().Put(SvgConstants.Attributes.STROKE, "white"); INode svgNode = new JsoupElementNode(svg); IDictionary <String, String> resolvedStyles = styleResolver.ResolveStyles(svgNode, null); NUnit.Framework.Assert.AreEqual("white", resolvedStyles.Get(SvgConstants.Attributes.STROKE)); }
public virtual void CheckDefaultFontValuesTest() { ICssResolver styleResolver = new SvgStyleResolver(new SvgProcessorContext(new SvgConverterProperties())); iText.StyledXmlParser.Jsoup.Nodes.Element svg = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("svg"), ""); INode svgNode = new JsoupElementNode(svg); IDictionary <String, String> resolvedStyles = styleResolver.ResolveStyles(svgNode, null); NUnit.Framework.Assert.AreEqual("helvetica", resolvedStyles.Get(SvgConstants.Attributes.FONT_FAMILY)); NUnit.Framework.Assert.AreEqual("12px", resolvedStyles.Get(SvgConstants.Attributes.FONT_SIZE)); }
public virtual void ProcessWithNullPropertiesTest() { DefaultSvgProcessor processor = new DefaultSvgProcessor(); iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGRoot = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("svg"), ""); INode root = new JsoupElementNode(jsoupSVGRoot); ISvgProcessorResult actual = processor.Process(root, null); ISvgProcessorResult expected = processor.Process(root); NUnit.Framework.Assert.AreEqual(expected.GetRootRenderer(), actual.GetRootRenderer()); }
public virtual void DepthFirstNullRendererTest() { iText.StyledXmlParser.Jsoup.Nodes.Element jsoupNonExistingElement = new iText.StyledXmlParser.Jsoup.Nodes.Element (iText.StyledXmlParser.Jsoup.Parser.Tag.ValueOf("nonExisting"), ""); INode root = new JsoupElementNode(jsoupNonExistingElement); DefaultSvgProcessor dsp = new DefaultSvgProcessor(); ISvgConverterProperties scp = new SvgConverterProperties(); dsp.PerformSetup(root, scp); // below method must not throw a NullPointerException dsp.ExecuteDepthFirstTraversal(root); }
public virtual void BasicProcessedRendererTest() { iText.StyledXmlParser.Jsoup.Nodes.Element element = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("processable"), ""); IElementNode tag = new JsoupElementNode(element); ISvgNodeRenderer renderer = fact.CreateSvgNodeRendererForTag(tag, null); NUnit.Framework.Assert.IsTrue(renderer is DummyProcessableSvgNodeRenderer); renderer.Draw(new SvgDrawContext(null, null)); DummyProcessableSvgNodeRenderer processed = (DummyProcessableSvgNodeRenderer)renderer; NUnit.Framework.Assert.IsTrue(processed.IsProcessed()); }
private INode CreateSvgContainingImage() { iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGRoot = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("svg"), ""); iText.StyledXmlParser.Jsoup.Nodes.Attributes attr = new iText.StyledXmlParser.Jsoup.Nodes.Attributes(); attr.Put(SvgConstants.Attributes.XLINK_HREF, "img.png"); iText.StyledXmlParser.Jsoup.Nodes.Element jsoupSVGImage = new iText.StyledXmlParser.Jsoup.Nodes.Element(iText.StyledXmlParser.Jsoup.Parser.Tag .ValueOf("image"), "", attr); INode root = new JsoupElementNode(jsoupSVGRoot); root.AddChild(new JsoupElementNode(jsoupSVGImage)); return(root); }