Link Annotation are not clickable (PDFTron for Windows / C#)

76 views
Skip to first unread message

Frederick Münch

unread,
Jul 31, 2018, 2:12:36 PM7/31/18
to PDFTron PDFNet SDK
Hi,

i am using Pdf-Tron in a WPF-Application (PDFViewWpf) with C# and i am having trouble to get link annotations (goto page) working.

I managed to write a minimal app, that shows a pdf document. But clicking the links does not trigger the goto action.

I am sure that the document contains valid links, because i can iterate over them and trigger their goto action programmatically.

I even added annotations programmatically by using the methods of the annotation sample: https://www.pdftron.com/documentation/samples/cs/AnnotationTest?platforms=windows
They appear on the document, but are not clickable.

I was skimming through the api and the documentation for hours, but is not really helpful for me.
I am a beginner in developing wpf applications, btw. and may be i am missing a few concepts. I hope you can help me.


That is my minimal application:

MainWindow.xaml:

<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:pdf="clr-namespace:pdftron.PDF;assembly=PDFNet"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<DockPanel>
<pdf:PDFViewWPF x:Name="PdfViewer" />
</DockPanel>
</Grid>
</Window>


MainWindow.xaml.cs:

namespace WpfApplication1
{
public partial class MainWindow
{

public const string PdfTronWindowsLicenseKey =
"MY LICENSE KEY";

public MainWindow()
{
InitializePdfTron();
InitializeComponent();

PDFViewCtrl viewCtrl = new PDFViewCtrl();

PdfViewer.CurrentPagePresentationMode = PDFViewWPF.PagePresentationMode.e_single_continuous;
PdfViewer.CurrentPageViewMode = PDFViewWPF.PageViewMode.e_fit_width;
var doc = new PDFDoc("C:\\PATH\\TO\\PDF\\test.pdf");
AnnotationHighLevelAPI(doc);
PdfViewer.CurrentDocument = doc;
PdfViewer.UseURLExtraction = true;
PdfViewer.DrawAnnotations = true;
PdfViewer.SetCurrentPage(1);
}

private static void InitializePdfTron()
{
try
{
PDFNet.Initialize(PdfTronWindowsLicenseKey);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}

private static void AnnotationHighLevelAPI(PDFDoc doc)
{
// copy from annotation example
// see: https://www.pdftron.com/documentation/samples/cs/AnnotationTest?platforms=windows
}
}
}

Ryan

unread,
Jul 31, 2018, 3:51:50 PM7/31/18
to PDFTron PDFNet SDK
All of the user interaction logic is in the PDFViewWPFTools project, for which there is an API and all the source code.

Please see the PDFViewSimpleTest SDK sample project, for a simplistic sample.

Essentially, add the PDFViewWPFTools project as a reference/dependency and then add 

_toolManager = new ToolManager(PDFViewWPF);

to your project and that should give you the functionality that you need. See MainWindow.xaml.cs for more detail.

If you are still having issues, please confirm if our PDFViewSimpleTest sample project works for you or not.
Message has been deleted

Frederick Münch

unread,
Aug 3, 2018, 12:50:14 PM8/3/18
to PDFTron PDFNet SDK
Thank you very much Ryan!

It works now.
Reply all
Reply to author
Forward
0 new messages