/// <summary> /// Applies the first page of the PDF file located at waterMarkImagePdfPath as a watermark /// to each page of the PDF file located at inputFilePath /// </summary> /// <param name="inputFilePath">File path of document to be watermarked</param> /// <param name="waterMarkImagePdfPath">File path of watermark template</param> public void AddWatermark(string inputFilePath, string waterMarkImagePdfPath) { var temp = inputFilePath + ".watermark"; var watermarkImage = this.ConvertSinglePdfPageToJpegImage(waterMarkImagePdfPath, 1); using (var doc = new Doc()) { doc.Read(inputFilePath); int theCount = doc.PageCount; int theID = 0; for (int i = 1; i <= theCount; i++) { doc.PageNumber = i; doc.Layer = doc.LayerCount + 1; if (i == 1) { theID = doc.AddImageFile(watermarkImage.FullName, 1); } else { doc.AddImageCopy(theID); } } doc.Save(temp); doc.Clear(); doc.Dispose(); } File.Delete(inputFilePath); File.Move(temp, inputFilePath); File.Delete(watermarkImage.FullName); }