这里我检查源pdf文件是否包含注解,然后尝试通过循环获取每个注解,并尝试将其添加到新的pdf页面中……但是它表明无法使用pdfsharp修改文件的错误,我可以从一个pdf页面写注释到另一页
这是我的代码:
PdfDocument DocumentReader_Po = new PdfDocument();
pdfPage_Po = Pdocument.AddPage();
pdfPage_Po = Pdocument.AddPage();
pdfPage_Po.Width = PageSizeConverter.ToSize(PdfSharp.PageSize.Letter).Width;
pdfPage_Po.Height = PageSizeConverter.ToSize(PdfSharp.PageSize.Letter).Height;
form = XPdfForm.FromFile(sourceFile);
if (form.Page.HasAnnotations)
{
for (int j = 0; j < form.Page.Annotations.Count; j++)
{
var annot = form.Page.Annotations[j];
var subType = annot.Elements.GetString(PdfAnnotation.Keys.Subtype);
if (subType == "/Text")
{
pdfPage_Po.Annotations.Add(annot);
}
}
}
您从一个文档中获取注释,然后尝试将其添加到新文档中。