View previous topic :: View next topic |
Author |
Message |
Shanthi
Joined: 02 May 2009 Posts: 4
|
Posted: Sat May 23, 2009 11:48 am Post subject: Need to include a logo into a pdf as watermark in backgroud |
|
|
I Need to include a logo into a pdf
as a background
how can i perform this
pls help,
Regards
Shanthi _________________ Shanthi |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Mon May 25, 2009 7:52 am Post subject: |
|
|
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 |
|
Back to top |
|
|
Shanthi
Joined: 02 May 2009 Posts: 4
|
Posted: Thu May 28, 2009 4:12 am Post subject: |
|
|
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 |
|
Back to top |
|
|
|