How to insert invisible text into a PDF?

☆樱花仙子☆ 提交于 2019-11-29 15:30:54

3 options.

  1. Text render mode 3: "No stroke, no fill". myPdfContentByte.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_INVISIBLE);
  2. Draw the text behind something. You've presumably got scanned images of the pages. iText's myPdfStamper.getUnderContent(pageNum) will let you draw the text under the scan.
  3. Draw the text outside the page's media or crop box. If you just want some random PDF-savvy search engine to turn up your page this will work, but if you want people looking at the PDF to see the appropriate text selection box... not so much.

This shows how to create a PDF document containing text and this shows how to add an image. Add the text first and then add the image on top of it - the text will become 'invisible' to the end user but will remain searchable by search engines. This may also be useful.

You do not have to render the text invisible. Just render them in the appropriate place but overlay the scanned image on the text. Or, you could render the text over the image and set alpha value of the color of the the stroke and brush to zero.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!