我有一个 PDF,需要查找和替换一些文本。我知道如何创建叠加层和添加文本,但我无法确定如何定位当前文本坐标。这是我在 bytescout 网站上找到的示例 -
// Create Bytescout.PDFExtractor.TextExtractor instance
TextExtractor extractor = new TextExtractor();
extractor.RegistrationName = "";
extractor.RegistrationKey = "";
/////find text
// Load sample PDF document
extractor.LoadDocumentFromFile(@"myPdf.pdf");
int pageCount = extractor.GetPageCount();
RectangleF location;
for (int i = 0; i < pageCount; i++)
{
// Search each page for string
if (extractor.Find(i, "OPTION 2", false, out location))
{
do
{
Console.WriteLine("Found on page " + i + " at location " + location.ToString());
}
while (extractor.FindNext(out location));
}
}
Console.WriteLine();
Console.WriteLine("Press any key to continue...");
Console.ReadLine();
}
}
但它不起作用,因为没有采用 4 个参数的重载 Find 方法。我不喜欢使用 Bytescout 从 pdf 中查找文本坐标,但我的公司有许可证。如果 Bytescout 无法完成我想要做的事情,是否有一种免费的方法可以在 pdf 上查找文本坐标?