tags:

views:

384

answers:

2

I can't seem to get PdfSharp to show a picture for this annotation. It doesn't have the PdfAnnotation.Icon property, so I can't set that.

XFont font = new XFont("Verdana", 10);
        PdfPage page = wDoc.Parent.Page;
        XGraphics gfx = wDoc.Parent.gfx;
        XRect rec = gfx.Transformer.WorldToDefaultPage(new XRect(new XPoint(30, 60), new XSize(30, 30)));
        PdfRectangle rect = new PdfRectangle(rec);
        PdfLinkAnnotation link = PdfLinkAnnotation.CreateFileLink(rect, wDoc.FileLocation);
        gfx.DrawString("These files were attached:", font, XBrushes.Black, 30, 50, XStringFormat.Default);
        gfx.
        link.Rectangle = new PdfRectangle(rec);
        page.Annotations.Add(link);

I've gotten it that far, and the annotation DOES exist, except it's a blank box! How do I go about making it say something, or even just show a picture?

A: 

I am not familiar with class PdfLinkAnnotation. You can use page.AddDocumentLink, page.AddWebLink, and page.AddFileLink to create links. If you use these methods, you can draw the icon as an image.

The best place to ask PDFsharp and MigraDoc Foundation related questions is the PDFsharp forum. The PDFsharp Team will not monitor stackoverflow.com on a regular basis.

PDFsharp Forum:
http://forum.pdfsharp.net/

PDFsharp Team
A: 

You need to use page.AddWebLink(AREArect) and then add the text area with gfx.drawstring(AREArect)

John