Esempio n. 1
0
        public virtual void BackgroundColorClipTest()
        {
            PdfDocument      pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()));
            PdfCanvas        pdfCanvas   = new _PdfCanvas_523(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));
            renderer.SetProperty(Property.BACKGROUND, new Background(new DeviceRgb(), 1, BackgroundBox.CONTENT_BOX));
            renderer.DrawBackground(drawContext);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        public virtual void BackgroundLinearGradientClipOriginNoRepeatTest()
        {
            PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new ByteArrayOutputStream()));

            byte[]           bytes       = new byte[] { 54, 25, 47, 15, 2, 2, 2, 44, 55, 77, 86, 24 };
            PdfCanvas        pdfCanvas   = new _PdfCanvas_589(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));
            Rectangle targetBoundingBox = new Rectangle(50f, 150f, 300f, 300f);
            AbstractLinearGradientBuilder gradientBuilder = new LinearGradientBuilder().SetGradientVector(targetBoundingBox
                                                                                                          .GetLeft() + 100f, targetBoundingBox.GetBottom() + 100f, targetBoundingBox.GetRight() - 100f, targetBoundingBox
                                                                                                          .GetTop() - 100f).SetSpreadMethod(GradientSpreadMethod.PAD).AddColorStop(new GradientColorStop(ColorConstants
                                                                                                                                                                                                         .RED.GetColorValue(), 0d, GradientColorStop.OffsetType.RELATIVE)).AddColorStop(new GradientColorStop(ColorConstants
                                                                                                                                                                                                                                                                                                              .BLUE.GetColorValue(), 1d, GradientColorStop.OffsetType.RELATIVE));
            BackgroundImage backgroundImage = new BackgroundImage.Builder().SetLinearGradientBuilder(gradientBuilder).
                                              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);
        }