我在我的 Windows 商店应用程序项目中使用 PDFTron PDF 注释库。有时,当我尝试将以前完成的注释(另存为单独的文件)加载到 PDFView 控件中时,它会抛出 AccessViolationException。请帮忙。
在我的页面上,这是代码:
await ImportAnnotations(param.Doc, agendaItem);
this.PDFViewCtrl.Update(); //this is where the exception throws
这是 ImportAnnotations 函数。
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;
}