PDF Xpress for .NET - User Guide > How To > Modify PDF Document Content > Add Watermark to a PDF document |
You can add source-based watermarks and text watermarks to a PDF. Source-based means the source of the watermark is another PDF.
To add a source-based watermark to a PDF, do the following:
C# Example |
Copy Code
|
---|---|
using System; using Accusoft.PdfXpressSdk; namespace PDFWatermark { class Watermark { static void Main(string[] args) { using (PdfXpress pdf = new PdfXpress()) { pdf.Initialize(@"C:\Users\Public\Documents\Accusoft\PDFXpress\v7.0\Support\Font", @"C:\Users\Public\Documents\Accusoft\PDFXpress\v7.0\Support\CMap"); using (Document doc = new Document(pdf, "C:\\myfile.pdf")) { using (Document sourceDoc = new Document(pdf, "C:\\source.pdf")) { //create the page artifact options PageArtifactOptions po = new PageArtifactOptions(); po.ArtifactType = TypeOfArtifact.SourceWatermark; po.Opacity = .5; PageRange pageRange = new PageRange(); pageRange.PageCount = 1; pageRange.StartPageNumber = 0; PageList pageList = new PageList(); pageList.Add(pageRange); po.PageList = pageList; po.SourceDocument = sourceDoc; po.SourcePageNumber = 0; //add the watermark doc.AddWatermark(po); //set the save options SaveOptions so = new SaveOptions(); so.Filename = "C:\\watermarked.pdf"; so.Overwrite = true; so.Linearized = true; //save the document doc.Save(so); } } } } } } |