Using the sample to place rubber stamps on PDF's the sample code in VB.Net is below and makes a black rectangle crossed out. the rubber stamp will display in PDFArchitect. Can point PDFSharp at the Reader XI (11)'s directory for Annotations? ( C:\Program Files (x86)\Adobe\Reader 11.0\Reader\plug_ins\Annotations\Stamps\ENU)?
'------------------ Dim document As PdfDocument = New PdfDocument document.Info.Title = "Created with PDFsharp" document.Version = 16 ' Create an empty page Dim page As PdfPage = document.AddPage
' Get an XGraphics object for drawing Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
' Draw crossing lines Dim pen As XPen = New XPen(XColor.FromArgb(255, 0, 0)) gfx.DrawLine(pen, New XPoint(0, 0), New XPoint(page.Width.Point, page.Height.Point)) gfx.DrawLine(pen, New XPoint(page.Width.Point, 0), New XPoint(0, page.Height.Point))
' Draw an ellipse gfx.DrawEllipse(pen, 3 * page.Width.Point / 10, 3 * page.Height.Point / 10, 2 * page.Width.Point / 5, 2 * page.Height.Point / 5)
' Create a font Dim font As XFont = New XFont("Verdana", 20, XFontStyle.Bold)
' Draw the text gfx.DrawString("Hello, World!", font, XBrushes.Black, _ New XRect(0, 0, page.Width.Point, page.Height.Point), XStringFormats.Center)
' Create a PDF text annotation Dim textAnnot As New PdfTextAnnotation() textAnnot.Title = "This is the title" textAnnot.Subject = "This is the subject" textAnnot.Contents = "This is the contents of the annotation." & vbCr & "This is the 2nd line." textAnnot.Icon = PdfTextAnnotationIcon.Note
gfx.DrawString("The first text annotation", font, XBrushes.Black, 30, 50, XStringFormats.[Default])
' Convert rectangle from world space to page space. This is necessary because the annotation is ' placed relative to the bottom left corner of the page with units measured in point. Dim rect As XRect = gfx.Transformer.WorldToDefaultPage(New XRect(New XPoint(30, 60), New XSize(30, 30))) textAnnot.Rectangle = New PdfRectangle(rect)
' Add the annotation to the page page.Annotations.Add(textAnnot)
' Create another PDF text annotation which is open and transparent textAnnot = New PdfTextAnnotation() textAnnot.Title = "Annotation 2 (title)" textAnnot.Subject = "Annotation 2 (subject)" textAnnot.Contents = "This is the contents of the 2nd annotation." textAnnot.Icon = PdfTextAnnotationIcon.Help textAnnot.Color = XColors.LimeGreen textAnnot.Opacity = 0.5 textAnnot.Open = True
gfx.DrawString("The second text annotation (opened)", font, XBrushes.Black, 30, 140, XStringFormats.[Default])
rect = gfx.Transformer.WorldToDefaultPage(New XRect(New XPoint(30, 150), New XSize(30, 30))) textAnnot.Rectangle = New PdfRectangle(rect)
' Add the 2nd annotation to the page page.Annotations.Add(textAnnot) '============================================================FAIL======================= ' Create a so called rubber stamp annotation. I'm not sure if it is useful, but at least ' it looks impressive... Dim rsAnnot As New PdfRubberStampAnnotation() rsAnnot.Icon = PdfRubberStampAnnotationIcon.Approved '============================================================FAIL=======================
rect = gfx.Transformer.WorldToDefaultPage(New XRect(New XPoint(100, 400), New XSize(350, 150))) rsAnnot.Rectangle = New PdfRectangle(rect)
' Add the rubber stamp annotation to the page page.Annotations.Add(rsAnnot) rect = gfx.Transformer.WorldToDefaultPage(New XRect(New XPoint(100, 400), New XSize(350, 150))) rsAnnot.Rectangle = New PdfRectangle(rect)
' Save the document... Dim filename As String = "HelloWorld.pdf" document.Save("C:\" & filename)
' ...and start a viewer. Process.Start(filename) '---------------------------------------
|