如何使用PdfSharp将注释从一个pdf添加到另一个pdf

问题描述 投票:0回答:1

这里我检查源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); 

                                    }
                                }
                            }
c# model-view-controller pdfsharp
1个回答
0
投票

您从一个文档中获取注释,然后尝试将其添加到新文档中。

© www.soinside.com 2019 - 2024. All rights reserved.