pdfbox

OpenHTMLToPDF: Embed a custom font into PDF created out of HTML

拜拜、爱过 提交于 2020-08-05 07:19:33
问题 I create a PDF from HTML with Jsoup and OpenHTMLToPDF. I have to use a different font in my PDF to have non-latin glyphcs covered (see here). How can I embed my font correctly? Simplified program reproducing the issue: src/main/resources/test.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Font Test</title> <style> @font-face { font-family: 'source-sans'; font-style: normal; font-weight: 400; src: url(fonts/SourceSansPro-Regular.ttf); } </style> </head> <body> <p style=

java中根据模板生成pdf文件

筅森魡賤 提交于 2020-08-05 04:21:10
简介 本文使用java引入apache提供的pdf操作工具生成pdf文件,主要是根据需求开发了一个util类,记录一下学习和开发过程。 业务需求 因为业务需要,对于不同的用户要生成一个不同的pdf文件,记录了保险用户的疾病信息和结算信息等,根据pdf模板,从数据库中获取用户的基本和结算信息,然后生成该用户的结算文件。 根据这个需求,写了一个工具类,主要功能就是根据模板生成pdf文件,并保存到服务器指定位置。 引入jar包 pdfBox是apache提供的免费,开源的pdf操作工具,这个jar里面囊括了所有的pdfbox操作工具类,导入这一个就够了 ,使用起来很方便。 这里使用maven引入jar包: <!-- https: // mvnrepository.com/artifact/org.apache.pdfbox/pdfbox --> <dependency> <groupId>org.apache.pdfbox</groupId> <artifactId>pdfbox</artifactId> <version>2.0.13</version> </dependency> pdf模板文件与方法参数 工具类有两个必须的元素:pdf模板文件和从数据库中抽出的数据。 pdf模板文件放在指定的路径,下图为部分pdf模板文件: 模板文件可以有多张,这里只截取一张当做参考。 入参和返回值

PDFBox U+00A0 is not available in this font's encoding

≯℡__Kan透↙ 提交于 2020-08-04 04:24:57
问题 I am facing a problem when invoking the setValue method of a PDField and trying to set a value which contains special characters. field.setValue("TEST-BY (TEST)") In detail, if my value contains characters as U+00A0 i am getting the following exception: Caused by: java.lang.IllegalArgumentException: U+00A0 is not available in this font's encoding: WinAnsiEncoding A complete stracktrace can be found here: Stacktrace I currently have set PDType1Font.TIMES_ROMAN as font. In order to solve this

PDFBox U+00A0 is not available in this font's encoding

倾然丶 夕夏残阳落幕 提交于 2020-08-04 04:24:51
问题 I am facing a problem when invoking the setValue method of a PDField and trying to set a value which contains special characters. field.setValue("TEST-BY (TEST)") In detail, if my value contains characters as U+00A0 i am getting the following exception: Caused by: java.lang.IllegalArgumentException: U+00A0 is not available in this font's encoding: WinAnsiEncoding A complete stracktrace can be found here: Stacktrace I currently have set PDType1Font.TIMES_ROMAN as font. In order to solve this

Search texts and get position in pdf with java

安稳与你 提交于 2020-07-23 06:55:06
问题 How can I search for text and get position in pdf with java ? I tried with apache pdfbox and pdfclown but whenever the text goes down or start a new paragraph, it doesn't work. I want to get the same result like in the picture below. Thank you. Desired result 回答1: You referred to one of my earlier answers as an example for PDFBox which did not work for you. Indeed, as already explained in that answer it was a surprise to see that code match anything beyond single words as the callers of the

Search texts and get position in pdf with java

自作多情 提交于 2020-07-23 06:54:06
问题 How can I search for text and get position in pdf with java ? I tried with apache pdfbox and pdfclown but whenever the text goes down or start a new paragraph, it doesn't work. I want to get the same result like in the picture below. Thank you. Desired result 回答1: You referred to one of my earlier answers as an example for PDFBox which did not work for you. Indeed, as already explained in that answer it was a surprise to see that code match anything beyond single words as the callers of the

Search texts and get position in pdf with java

亡梦爱人 提交于 2020-07-23 06:53:12
问题 How can I search for text and get position in pdf with java ? I tried with apache pdfbox and pdfclown but whenever the text goes down or start a new paragraph, it doesn't work. I want to get the same result like in the picture below. Thank you. Desired result 回答1: You referred to one of my earlier answers as an example for PDFBox which did not work for you. Indeed, as already explained in that answer it was a surprise to see that code match anything beyond single words as the callers of the

₹ (Indian Rupee Symbol) symbol is printing as ? (question mark) in pdf using Apache PDFBOX

守給你的承諾、 提交于 2020-07-21 06:44:12
问题 I am trying to write a string in my pdf file creating using apache pdfbox. I have used ISO-8859-1 as encoding with UTF-8. but still, it is printing question mark. Tried a lot and looked for solutions on the internet(StackOverflow). Could someone please help. Thanks in advance public class TestClass { public static void main(String[] args) throws IOException{ PDDocument doc = new PDDocument(); PDPage page = new PDPage(); doc.addPage(page); PDPageContentStream cos= new PDPageContentStream(doc,

₹ (Indian Rupee Symbol) symbol is printing as ? (question mark) in pdf using Apache PDFBOX

妖精的绣舞 提交于 2020-07-21 06:43:59
问题 I am trying to write a string in my pdf file creating using apache pdfbox. I have used ISO-8859-1 as encoding with UTF-8. but still, it is printing question mark. Tried a lot and looked for solutions on the internet(StackOverflow). Could someone please help. Thanks in advance public class TestClass { public static void main(String[] args) throws IOException{ PDDocument doc = new PDDocument(); PDPage page = new PDPage(); doc.addPage(page); PDPageContentStream cos= new PDPageContentStream(doc,

PDFBox 2.0 create signature field and save incremental with already signed document

匆匆过客 提交于 2020-07-21 03:25:07
问题 I have read here about how saveIncremental is working, and my final result needs to be something like here , in the way that I have managed to create visible signature with multiple visualization based on the signature field itself (not like in the response, but the response helped me so much). To elaborate the title, my base task for now is to create an empty signature field on an already signed document without braking the existing signature. However, the example here is not working with