当我有坐标时,pdfbox 是否提供一些实用程序来突出显示文本?
文本的边界是已知的。
我知道还有其他库提供与 pdfclown 等相同的功能。但是 pdfbox 是否提供类似的功能?
最佳答案
好吧,我发现了这一点。很简单。
PDDocument doc = PDDocument.load(/*path to the file*/);
PDPage page = (PDPage)doc.getDocumentCatalog.getAllPages.get(i);
List annots = page.getAnnotations;
PDAnnotationTextMarkup markup = new PDAnnotationTextMarkup(PDAnnotationTextMarkup.Su....);
markup.setRectangle(/*your PDRectangle*/);
markup.setQuads(/*float array of size eight with all the vertices of the PDRectangle in anticlockwise order*/);
annots.add(markup);
doc.save(/*path to the output file*/);
关于java - 当 pdf 中的位置已知时,使用 pdfbox 突出显示文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18463543/