I need to insert links to various files inside a PDF. I use IFieldMergingCallback_FieldMerging to get the fields and use builder to insert a link. The link does not open in a PDF. It sounds like I need to insert a Javascript function in order to open the link in a PDF. I attached the PDF. The file I want to open is “Who Do I Belong to?”. How do I add a link to a PDF using Builder so the file will open in a new window?
If Not e.FieldValue Is Nothing Then
If Not e.FieldValue Is DBNull.Value Then
tmpString = e.FieldValue
Dim builder As New DocumentBuilder(e.Document)
builder.MoveToMergeField(e.DocumentFieldName)
builder.InsertHtml(DirectCast(tmpString, String))
e.Text = “”
’ End If
End If
End If
Hi Jim,
Dim dataDir As String = RunExamples.GetDataDir_AsposePdf_LinksActions()
’ Load the PDF file
Dim document As New Document(dataDir & Convert.ToString(“UpdateLinks.pdf”))
Dim linkAnnot As LinkAnnotation = DirectCast(document.Pages(1).Annotations(1), LinkAnnotation)
Dim goToR As GoToRemoteAction = DirectCast(linkAnnot.Action, GoToRemoteAction)
’ Next line update destination, do not update file
goToR.Destination = New XYZExplicitDestination(2, 0, 0, 1.5)
’ Next line update file
goToR.File = New FileSpecification(dataDir & Convert.ToString(“input.pdf”))
dataDir = dataDir & Convert.ToString(“SetTargetLink_out.pdf”)
’ Save the document with updated link
document.Save(dataDir)