Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#


Bitmap original_image = new Bitmap(FileUpload1.FileContent);
string sWaterMark = (string)s1;
int fontsize = ((original_image.Width * 2) / (sWaterMark.Length * 3));
int x = original_image.Width / 2;
int y = original_image.Height * 9 / 20;
StringFormat drawFormat = new StringFormat();
drawFormat.Alignment = StringAlignment.Center;
drawFormat.FormatFlags = StringFormatFlags.NoWrap;
Graphics graphic = Graphics.FromImage(original_image);
graphic.DrawString(sWaterMark, new Font("Verdana", fontsize, FontStyle.Bold), new SolidBrush(Color.FromArgb(80, 255, 255, 255)), x, y, drawFormat);
original_image.Save(MapPath("~/" + newfolder + "\\") + FileUpload1.FileName);
if (original_image != null) original_image.Dispose();
if (graphic != null) graphic.Dispose();
Posted

1 solution

You'll need a 3rd party dll,such as pdfsharp[^] or iTextSharp[^] to watermark a pdf
 
Share this answer
 
Comments
Member 11026295 25-Aug-14 5:12am    
using "pdfsharp" how can insert watermark on upload pdf file

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900