使用PDFBOX当它在PDF位置是已知的高亮显示文本 [英] highlight text using pdfbox when it's location in the pdf is known

查看:1529
本文介绍了使用PDFBOX当它在PDF位置是已知的高亮显示文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问PDFBOX提供一些工具来突出显示文本时,我有它的坐标?

Does pdfbox provide some utility to highlight the text when i have it's co-ordinates?

文字的​​边界是已知的。

bounds of the text is known.

我知道有一些像提供pdfclown etc.But相同的功能并提供PDFBOX类似的东西,其他库?

i know there are other libraries that provide the same functionality like pdfclown etc.But does pdfbox provide something like that?

推荐答案

好吧,我发现了这一点。这是简单的。

well i found this out. it is simple.

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*/);

这篇关于使用PDFBOX当它在PDF位置是已知的高亮显示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆