PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 6:18 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat May 23, 2009 11:48 am 
Offline

Joined: Sat May 02, 2009 9:47 am
Posts: 4
I Need to include a logo into a pdf
as a background

how can i perform this

pls help,

Regards
Shanthi

_________________
Shanthi


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 25, 2009 7:52 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
See Watermark sample on adding watermarks.
See Graphics sample on adding graphics.

Combine snippets from both samples and you're done.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu May 28, 2009 4:12 am 
Offline

Joined: Sat May 02, 2009 9:47 am
Posts: 4
Thanks for your guidance
I have used the below code to achieve my target

Code:
  // Add LOGO inside pdf
        string filename = Server.MapPath("~/Uploads/") + FileUpload1.FileName.ToString();
        FileUpload1.SaveAs(filename);
        PdfDocument document = PdfReader.Open(filename);
        // Set version to PDF 1.4 (Acrobat 5) because we use transparency.
        if (document.Version < 14)
            document.Version = 14;

        for (int idx = 0; idx < document.Pages.Count; idx++)
        {
            PdfPage page = document.Pages[idx];
            XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Prepend);

            string imgPath = System.Web.HttpContext.Current.Server.MapPath("Images/nals_logo.jpg");
            XImage image = XImage.FromFile(imgPath);
            gfx.DrawImage(image, 100, 200);
        }
        // Save the document...
        document.Save(filename);
        // ...and start a viewer
        Process.Start(filename);

_________________
Shanthi


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 371 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group