We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding a Link to PDF using Builder

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,


Thanks for contacting support.

As per my understanding you are using some other third party library to create links in PDF file. However the same behavior of adding links to external files can be accomplished using Aspose.Pdf. The following code snippet shows how to update a link in a PDF file and set its target to another PDF file.

VB

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)

If you still face issues or you have different requirement as per my understanding then please share more details.

We are sorry for this inconvenience.

Best Regards,