public virtual void CalculateNestedViewportDifferentFromParentTest() { Rectangle expected = new Rectangle(0, 0, 500, 500); SvgDrawContext context = new SvgDrawContext(null, null); PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream(), new WriterProperties().SetCompressionLevel (0))); document.AddNewPage(); PdfFormXObject pdfForm = new PdfFormXObject(expected); PdfCanvas canvas = new PdfCanvas(pdfForm, document); context.PushCanvas(canvas); context.AddViewPort(expected); SvgTagSvgNodeRenderer parent = new SvgTagSvgNodeRenderer(); SvgTagSvgNodeRenderer renderer = new SvgTagSvgNodeRenderer(); PdfRootSvgNodeRenderer root = new PdfRootSvgNodeRenderer(parent); IDictionary <String, String> styles = new Dictionary <String, String>(); styles.Put("width", "500"); styles.Put("height", "500"); renderer.SetAttributesAndStyles(styles); renderer.SetParent(parent); Rectangle actual = root.CalculateViewPort(context); NUnit.Framework.Assert.IsTrue(expected.EqualsWithEpsilon(actual)); }
public virtual void CalculateOutermostViewportWithDifferentXYTest() { Rectangle expected = new Rectangle(10, 20, 600, 600); SvgDrawContext context = new SvgDrawContext(null, null); PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream(), new WriterProperties().SetCompressionLevel (0))); document.AddNewPage(); PdfFormXObject pdfForm = new PdfFormXObject(expected); PdfCanvas canvas = new PdfCanvas(pdfForm, document); context.PushCanvas(canvas); SvgTagSvgNodeRenderer renderer = new SvgTagSvgNodeRenderer(); PdfRootSvgNodeRenderer root = new PdfRootSvgNodeRenderer(renderer); Rectangle actual = root.CalculateViewPort(context); NUnit.Framework.Assert.IsTrue(expected.EqualsWithEpsilon(actual)); }
public virtual void CalculateOutermostTransformation() { AffineTransform expected = new AffineTransform(1d, 0d, 0d, -1d, 0d, 600d); SvgDrawContext context = new SvgDrawContext(null, null); PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream(), new WriterProperties().SetCompressionLevel (0))); document.AddNewPage(); PdfFormXObject pdfForm = new PdfFormXObject(new Rectangle(0, 0, 600, 600)); PdfCanvas canvas = new PdfCanvas(pdfForm, document); context.PushCanvas(canvas); SvgTagSvgNodeRenderer renderer = new SvgTagSvgNodeRenderer(); PdfRootSvgNodeRenderer root = new PdfRootSvgNodeRenderer(renderer); context.AddViewPort(root.CalculateViewPort(context)); AffineTransform actual = root.CalculateTransformation(context); NUnit.Framework.Assert.AreEqual(expected, actual); }