I'm using PDFTron PDF annotation library in my windows store app project. Sometimes when I tried to load previously done annotations (save as a separate file) into the PDFView Control it throws AccessViolationException. Please help.
On my page this is the code:
await ImportAnnotations(param.Doc, agendaItem);
this.PDFViewCtrl.Update(); //this is where the exception throws
This is ImportAnnotations function.
private async Task<PDFDoc> ImportAnnotations(PDFDoc doc, AgendaItem GlobalSelectdAgendaItem)
{
try
{
if (doc != null && GlobalSelectdAgendaItem != null)
{
StorageFolder documentsFolder = await StorageFolder.GetFolderFromPathAsync(Path.Combine(ApplicationData.Current.LocalFolder.Path, Global.UserId.ToString(), ApplicationConstants.PDF));
string annotationFileName = GlobalSelectdAgendaItem.ID + "_" + Global.UserId.ToString() + "_" + GlobalSelectdAgendaItem.VersionId + ".xfdf";
// load XFDF annotations
var anntotationFile = await documentsFolder.TryGetItemAsync(annotationFileName) as IStorageFile;
FDFDoc fdfDoc = null;
if (anntotationFile != null)
{
fdfDoc = await FDFDoc.CreateFromXFDFAsync(Path.Combine(documentsFolder.Path, annotationFileName));
}
else
{
return doc;
}
// load PDF with which to merge the annotations
doc.InitSecurityHandler();
// merge in the annotations
doc.FDFMerge(fdfDoc);
doc.RefreshFieldAppearances();
}
}
catch (Exception)
{
}
return doc;
}