Programmatically add stamp layer to PDF document
We user MigraDoc,
http://www.pdfsharp.net/MigraDocOverview.ashx?AspxAutoDetectCookieSupport=1
More specifically the PdfSharp library in PdfSharp.dll,
PdfDocument doc = PdfReader.Open(pdf1Point4FileDataStream, PdfDocumentOpenMode.Modify)
foreach (PdfPage page in doc.Pages)
{
page.Orientation = PdfSharp.PageOrientation.Portrait;
var gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Append, XPageDirection.Downwards);
gfx.DrawString(approvalWatermark, approvalFont, watermarkBrush, new XPoint((page.Width - maxWidth + approvalDiff) / 2 - space - moveLeft, page.Height / 2 - height1 - space), format);
}
Just a bit of code taken from our project, so it is a bit incomplete. Take a look at the library and classes, there will be some documentation around.
Jasper
Keen on developing webapplications in a service oriented manner. Also trying to develop more skills in managing projects, people and overall professional software development. Specialties - MCPD and MCITP in SharePoint 2010 - Certified in Designing and Developing Windows Azure applications - Certified ASP.NET developer - ASP.NET MVC Advanced user of Visual Studio, Microsoft SQL Server and numerous tools.
Updated on June 17, 2022Comments
-
Jasper almost 2 years
I'm looking for a way to add an extra layer to a PDF document. The layer should be on top of existing layers and should display a text I want to put on there, kind of like a watermark. At the moment we have a way of doing this, but this just adds the text onto the picture embedded in the PDF, that's not what I want. Anyone has any ideas if there are libraries (free ones would be great) which do this?