My goal is to create a custom link and the annotation display in highlight color base on user preferences.
I recently tried about PDFView sample, but I haven’t make it work on adding a new annotation by using Custom Link Create Tool. The code for creating annotation has never run because the pg is not nothing.
if I changed the If pg is nothing from true to false on onMouseUp function on MyPDFview then the code of the If block can run. I added the code to make a rectangle on the top as like the code on the Annotation Test project. The saved file didn’t show the rectangle. I debug the code and found that the value of _start_pt.Y and pt_arr(1).Y is same for creating the rect. Also it is the same value for pt_arr(0).X and pt_arr(1).X. Therefore I assigned the value of the PointF then the rectangle show on the saved file, not the doc on the screen. Also I can click the annotation to goto another page on the saved file.
My question are:
-
How can I get the right position onMouseUp and show on the opening document?
-
I know there is highlight annotation in PDFSDK, how can I assign the action on it; goto another page or hyperlink as creating the link in code. If the highlight annotation doesn’t accept the action, would you tell what I should do in order to fit my goal?
There is my code snippet on OnMouseUp function
If Not (action Is Nothing) Then
’ Create link annotation position rectangle in PDF page coordinate system.
Dim screen2page As Matrix = GetDeviceTransform(_cur_page)
screen2page.Invert()
Dim pt_arr As PointF() = {_start_pt, _end_pt}
screen2page.TransformPoints(pt_arr)
Dim pos As Rect = New Rect(pt_arr(0).Y, pt_arr(0).X, pt_arr(1).Y + 50, pt_arr(1).X + 300)
pos.Normalize()
Dim link As Link = link.Create(doc.GetSDFDoc, pos, action)
’ Todo?
’ Create link appearances based on user preferences.
Dim s As Annot.BorderStyle.Style = Annot.BorderStyle.Style.e_solid
Dim bs As Annot.BorderStyle = New Annot.BorderStyle(s, 1)
link.SetBorderStyle(bs)
link.SetColor(New ColorPt(0.145, 0.2509, 0.3803))
’ Create other annotation and action types…
’ …
link.RefreshAppearance()
pg.AnnotPushBack(link)
Dim output_path As String = “C:\Test”
doc.Save(output_path + “annotation_Sept18_1.pdf”, SDF.SDFDoc.SaveOptions.e_linearized)
End If
Thanks in advance.