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.
Unfortunately, activation email could not send to your email. Please try again.

Draw image in background

Thread ID:

Created:

Updated:

Platform:

Replies:

114649 Nov 29,2013 02:04 AM Dec 8,2013 10:54 PM ASP.NET MVC (Classic) 1
loading
Tags: PDF
Jacob Saugmann
Asked On November 29, 2013 02:04 AM

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 :-)


KarthikeyanC [Syncfusion]
Replied On December 8, 2013 10:54 PM

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;