public virtual void ImageRendererAddByIDTest() { DocumentRenderer documentRenderer = new DocumentRenderer(null); ImageRenderer imageRenderer = new ImageRenderer(new Image(ImageDataFactory.CreateRawImage(new byte[] { 50, 21 }))); imageRenderer.SetParent(documentRenderer); String id = "id6"; imageRenderer.SetProperty(Property.ID, id); LayoutContext layoutContext = new LayoutContext(new LayoutArea(4, new Rectangle(50, 50))); imageRenderer.Layout(layoutContext); documentRenderer.GetTargetCounterHandler().PrepareHandlerToRelayout(); NUnit.Framework.Assert.AreEqual((int?)4, TargetCounterHandler.GetPageByID(imageRenderer, id)); }
public virtual void BackgroundImageClipOriginNoRepeatTest() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream())); byte[] bytes = new byte[] { 54, 25, 47, 15, 2, 2, 2, 44, 55, 77, 86, 24 }; PdfXObject rawImage = new _PdfImageXObject_544(ImageDataFactory.CreateRawImage(bytes)); PdfCanvas pdfCanvas = new _PdfCanvas_555(rawImage, pdfDocument.AddNewPage()); DrawContext drawContext = new DrawContext(pdfDocument, pdfCanvas); AbstractRenderer renderer = new DivRenderer(new Div().SetPadding(20).SetBorder(new DashedBorder(10))); renderer.occupiedArea = new LayoutArea(1, new Rectangle(100f, 200f, 300f, 400f)); BackgroundImage backgroundImage = new BackgroundImage.Builder().SetImage(rawImage).SetBackgroundRepeat(new BackgroundRepeat(BackgroundRepeat.BackgroundRepeatValue.NO_REPEAT)).SetBackgroundClip(BackgroundBox.CONTENT_BOX ).SetBackgroundOrigin(BackgroundBox.BORDER_BOX).Build(); renderer.SetProperty(Property.BACKGROUND_IMAGE, backgroundImage); renderer.DrawBackground(drawContext); }
public virtual void DrawBackgroundImageTest() { AbstractRenderer renderer = new _DivRenderer_118(new Div()); byte[] bytes = new byte[] { 54, 25, 47, 15, 2, 2, 2, 44, 55, 77, 86, 24 }; int[] counter = new int[] { 0 }; PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream())); document.AddNewPage(); DrawContext context = new DrawContext(document, new _PdfCanvas_128(counter, bytes, document, 1)); renderer.SetProperty(Property.BACKGROUND_IMAGE, new BackgroundImage.Builder().SetImage(new _PdfImageXObject_145 (ImageDataFactory.CreateRawImage(bytes))).Build()); renderer.DrawBackground(context); NUnit.Framework.Assert.AreEqual(50, counter[0]); }
public virtual void DrawBackgroundImagesWithPositionsTest() { AbstractRenderer renderer = new _DivRenderer_458(new Div()); IList <byte[]> listBytes = JavaUtil.ArraysAsList(new byte[] { 54, 25, 47, 15, 2, 2, 2, 44, 55, 77, 86, 24 } , new byte[] { 4, 15, 41, 23, 3, 2, 7, 14, 55, 27, 46, 12, 14, 14, 7, 7, 24, 25 }); float widthHeight = 10.0f; IList <Rectangle> listRectangles = JavaUtil.ArraysAsList(new Rectangle(81, 20, widthHeight, widthHeight), new Rectangle(0, 40, widthHeight, widthHeight)); int[] counter = new int[] { 0 }; PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream())); document.AddNewPage(); DrawContext context = new DrawContext(document, new _PdfCanvas_475(listBytes, counter, listRectangles, document , 1)); renderer.SetProperty(Property.BACKGROUND_IMAGE, JavaUtil.ArraysAsList((BackgroundImage) new BackgroundImage.Builder ().SetImage(new _PdfImageXObject_493(widthHeight, ImageDataFactory.CreateRawImage(listBytes[1]))).Build (), (BackgroundImage) new BackgroundImage.Builder().SetImage(new _PdfImageXObject_504(widthHeight, ImageDataFactory .CreateRawImage(listBytes[0]))).SetBackgroundPosition(new BackgroundPosition().SetPositionX(BackgroundPosition.PositionX .RIGHT).SetPositionY(BackgroundPosition.PositionY.CENTER).SetXShift(new UnitValue(UnitValue.PERCENT, 10 ))).Build())); renderer.DrawBackground(context); NUnit.Framework.Assert.AreEqual(listBytes.Count, counter[0]); }
public virtual void DrawBackgroundImagesTest() { AbstractRenderer renderer = new _DivRenderer_402(new Div()); IList <byte[]> listBytes = JavaUtil.ArraysAsList(new byte[] { 54, 25, 47, 15, 2, 2, 2, 44, 55, 77, 86, 24 } , new byte[] { 4, 15, 41, 23, 3, 2, 7, 14, 55, 27, 46, 12, 14, 14, 7, 7, 24, 25 }); int[] counter = new int[] { 0 }; PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream())); document.AddNewPage(); DrawContext context = new DrawContext(document, new _PdfCanvas_414(listBytes, counter, document, 1)); renderer.SetProperty(Property.BACKGROUND_IMAGE, JavaUtil.ArraysAsList((BackgroundImage) new BackgroundImage.Builder ().SetImage(new _PdfImageXObject_430(ImageDataFactory.CreateRawImage(listBytes[1]))).Build(), (BackgroundImage ) new BackgroundImage.Builder().SetImage(new _PdfImageXObject_441(ImageDataFactory.CreateRawImage(listBytes [0]))).Build())); renderer.DrawBackground(context); NUnit.Framework.Assert.AreEqual(listBytes.Count, counter[0]); }
public virtual void DrawBackgroundImageWithPositionTest() { AbstractRenderer renderer = new _DivRenderer_295(new Div()); byte[] bytes = new byte[] { 54, 25, 47, 15, 2, 2, 2, 44, 55, 77, 86, 24 }; PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream())); document.AddNewPage(); DrawContext context = new DrawContext(document, new _PdfCanvas_304(bytes, document, 1)); renderer.SetProperty(Property.BACKGROUND_IMAGE, new BackgroundImage.Builder().SetImage(new _PdfImageXObject_322 (ImageDataFactory.CreateRawImage(bytes))).SetBackgroundPosition(new BackgroundPosition().SetXShift(new UnitValue(UnitValue.PERCENT, 30))).Build()); renderer.DrawBackground(context); }