itext

How to get number of pages of Portable Collection Pdf using IText or any function using Java

强颜欢笑 提交于 2019-12-26 16:02:47
问题 PdfReader reader = new PdfReader(pdfFile, new byte[0]); pages = reader.getNumberOfPages(); Suppose there are two pdfs(Each pdf contains 2 pages) inside portable collection. When i try to get number of pages it returns just 1. I think it is considering cover page of the portable collection document. Is there any way to get number of pages of portable colletion ? I am using Java 11 and IText 5.5 version. 回答1: I found solution for this but i think it is unnecessary to check the below things and

How to get number of pages of Portable Collection Pdf using IText or any function using Java

孤街醉人 提交于 2019-12-26 16:02:26
问题 PdfReader reader = new PdfReader(pdfFile, new byte[0]); pages = reader.getNumberOfPages(); Suppose there are two pdfs(Each pdf contains 2 pages) inside portable collection. When i try to get number of pages it returns just 1. I think it is considering cover page of the portable collection document. Is there any way to get number of pages of portable colletion ? I am using Java 11 and IText 5.5 version. 回答1: I found solution for this but i think it is unnecessary to check the below things and

【iText5 生成PDF】纯Java代码实现生成PDF(自定义表格、文本水印、单元格样式)

情到浓时终转凉″ 提交于 2019-12-25 22:34:55
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> ​ 工作中遇到需要生成PDF。最终选择了iText。其他也有通过html再生成。感觉不太适合就用了代码实现。 使用iText 5.5.13.1版本。纯Java代码实现 1.自定义表格合并指定行列完成数据填充 2.自定义单元格显示 3.文本内容水平垂直居中显示 4.中文显示 5.图片增加(三角雷达图,基于JFreeChart 可参考另一篇博文) 先看个效果图 Maven项目引入iText <!-- itextpdf --> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.5.13.1</version> </dependency> <!-- itext-asian --> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itext-asian</artifactId> <version>5.2.0</version> </dependency> <!-- itextpdf-tool-xmlworker --> <dependency> <groupId>com.itextpdf.tool</groupId>

iText生成pdf显示中文

大憨熊 提交于 2019-12-25 22:23:03
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 最近项目中需要使用iText生成pdf文件,为了支持中文显示,百度了一下,用下面这行代码就可以,应该是iText内置的中文字体吧,实际用了也可行。 PdfFont chineseFont = PdfFontFactory.createFont("STSong-Light", "UniGB-UCS2-H", true); 但是接下来就发现,生成pdf时若遇到字符串中包含换行符、tab、生僻字等字符时会报错。为了解决这个问题,我用宋体字体文件simsun.ttf(可自行百度下载)代替内置字体,发现不会报错了。 PdfFont chineseFont = PdfFontFactory.createFont("fonts/simsun.ttf", PdfEncodings.IDENTITY_H, true); //fonts/simsun.ttf为文件地址 虽然用字体文件不会报错,但有一次遇到导出的pdf中“㭎”这个字显示为空白,也就是说使用字体文件遇到识别不了的字符不会报错,但是直接跳过这个字符了。不知道有没有解决这个问题的方法? 来源: oschina 链接: https://my.oschina.net/u/3245427/blog/3147434

iText can not verify signed PDF document was edited by nitro pro 10/11 [duplicate]

十年热恋 提交于 2019-12-25 19:09:20
问题 This question already has an answer here : PDF/A signed with iText7 allows changing attached documents without breaking a signature (1 answer) Closed last year . I used nitro pro 10/11 to edit a signed PDF document. Adobe reader can recognize the docs content has been modified, but integrity check is ok by iText (V5.5.6/V7.0.2). How can i check whether the integrity is correct using iText? 回答1: iText offers an API to validate each integrated signature and to check whether it covers the whole

Convert PDF to Excel in Java [closed]

為{幸葍}努か 提交于 2019-12-25 18:48:24
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . How to convert PDF file to Excel using Java. We have generate PDF file using itext. Now we want to convert it to excel. we want sample code to convert pdf to excel. or kindly Suggest API. 回答1: You can convert a PDF document to an Excel workbook with Aspose.PDF API by using below code snippet. Please ensure using

How do I get the checkbox to show as checked in the generated PDF for this specific situation? [duplicate]

。_饼干妹妹 提交于 2019-12-25 18:35:18
问题 This question already has answers here : How to display ✔ in PDF using iTextSharp? (2 answers) Closed 2 years ago . I am using iTextSharp v5.5.11 and I want to amend the following code to display a checked checkbox (may not necessarily need a checkbox control; an equivalent checked checkbox icon or similar would do) in the PDF that is generated. The code I have so far produced a checkbox which is not checked on PDF generation. As hinted, there may be better way to do this. Here is the code I

Merging of pdf with digital signature with itext 5.4.0 or greatest gives error

血红的双手。 提交于 2019-12-25 18:22:11
问题 I have a big problem in trying to merge some pdf, created with itext, with digital signature. This is the code: ByteArrayOutputStream bos = new ByteArrayOutputStream(); Document document = new Document(); PdfCopy writer = new PdfCopy(document, bos); writer.setMergeFields(); document.addTitle(""); document.open(); PdfReader reader = null; for (int i = 0; i < iss.length; i++) { reader = new PdfReader(iss[i]); writer.addDocument(reader); reader.close(); } document.close(); bos.close(); On