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
}
}
}