使用 iText 7 在 pdf 中查找矩形

问题描述

我使用 Foxit 创建了一个 pdf,然后在 pdf 中添加一个形状(矩形)。 AllClientProxy<THub>

enter image description here

我正在使用 ILocationExtractionStrategy 来定位形状。

            using (var pdfReader = new PdfReader(fileName))
            {
                using (PdfDocument docToSign = new PdfDocument(pdfReader))
                {
                    var sf = new ShapeFilter();
                    new PdfCanvasProcessor(sf).ProcesspageContent(docToSign.GetFirstPage());
                }
            }

//ILocationExtractionStrategy implementation
    public class ShapeFilter : ILocationExtractionStrategy
    {
        public void EventOccurred(IEventData data,EventType type)
        {
            System.Console.WriteLine(type);
        }

        public ICollection<IPdfTextLocation> GetResultantLocations()
        {
            return null;
        }

        public ICollection<EventType> GetSupportedEvents()
        {
            return null;
        }
    }

对于我只包含一个矩形的简单测试文档,ILocationExtractionStrategy.EventOccurred 被调用了 3 次 (CLIP_PATH_CHANGED,RENDER_PATH,CLIP_PATH_CHANGED),但我无法找到形状的位置。

我已经使用 RUPS 来检查我应该寻找什么属性,但即使在那里我也找不到矩形。

enter image description here

pdf 可以从 onedrive 下载:

enter image description here

任何提示如何使用 iText 读取这样的矩形(它的位置)?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)