We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Draw image in background

Hi

I'm just wondering how to draw an image in the background of the PDF?

when i use this code then the image is on top of header and footer in my PDF:

               
                var bgGraphics = page.Graphics;
               
                string bgImagePath = ResolveApplicationImagePath("kvrBackground.jpg");
                PdfImage bgImage = new PdfBitmap(bgImagePath);
               
                bgGraphics.DrawImage(bgImage, 0, 0, pdfDocument.PageSettings.Width, pdfDocument.PageSettings.Height);

have a nice day :-)


1 Reply

KC Karthikeyan Chandrasekar Syncfusion Team December 9, 2013 03:54 AM UTC

Hi Jacob,

Thank you for using Syncfusion Products.

 

We can able to set the image as background, please use the below code snippet:

 

            PdfLoadedDocument ldDoc = new PdfLoadedDocument("Input.pdf");

            PdfDocument doc = new PdfDocument();

 

            for (int i = 0, count = ldDoc.Pages.Count; i < count; ++i)

            {

                PdfPageBase page = doc.Pages.Add();

                PdfGraphics g = page.Graphics;

 

                PdfPageBase lpage = ldDoc.Pages[i];

                PdfTemplate template =  lpage.CreateTemplate();

 

                PdfImage img = new PdfBitmap("Image.gif");

                g.DrawImage(img, new PointF());

                g.DrawPdfTemplate(template, PointF.Empty, page.Size);

            }

 

            doc.Save("Output.pdf");

 

Please let us know if you need any further assistance.

Thanks,

Karthikeyan.C


Loader.
Live Chat Icon For mobile
Up arrow icon