Xojo PDF Annotations

Var pdf As New PDFDocument
Var g As Graphics = pdf.Graphics
g.PenSize = 1
g.DrawLine(0, 50, g.width, 50)
g.drawline(50,0,50,g.height)
pdf.AddAnnotation("anno1",50,50)
//
g.DrawLine(0, 100, g.width, 100)

pdf.AddLinkArea("https://www.google.com",50,100,100,50)
Var f As FolderItem = SpecialFolder.Desktop.Child("Barchart.pdf")
pdf.Save(f)

Anyone know whats wrong?

  1. The Text annotation appears as a small yellow box with NO TEXT (ie…‘anno1’)
  2. the LINK annotation “works” but is invisible

I draw the lines to show where the upper left corner of each annotation should be

Seems Xojo defines the “annotation” (#1) as TEXT not FREETEXT (text gives a TextView, freeText gives a “label”)…

PDFDocument.AddLinkArea only defines the link and the “area”. This makes it possible to use all shapes you like to use for a link (text, rectangles, ovals etc.). PDFDocument.AddAnnotation is quite the same. You can set the x/y position to any point on your current page.

g.DrawRectangle(50, 100, 100, 50)

' Add annotation next to the rectangle
pdf.AddAnnotation("anno1", 50, 50)

' Click the rectangle to go to www.google.com
pdf.AddLinkArea("https://www.google.com", 50, 100, 100, 50)
  1. is not working as described here: New Additions to PDFDocument – Xojo Programming Blog
  2. if you need something ‘behind’ the Link Area, you need to draw it using g.DrawText