itext

Merge pdf files within folder java

不羁的心 提交于 2021-02-19 07:52:27
问题 I have searched a few solutions but cannot really find an answer. Within my app i save reports to pdf using IText, but now i would like to merge all the files within the folder as I complete the report. The issue is each folder contains different number of files so I cannot just hardcode them in. Any advice will be appreciated. 回答1: Here is a working example. I have used ITEXT Dependencies : <dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.5.10<

Remove Footer from PDF using IText5.0

Deadly 提交于 2021-02-19 04:48:07
问题 I need to be able to add this code ... I want to modify to this code to add/edit/remove headers and footers from the PDF. public void onEndPage(PdfWriter writer, Document document) { PdfContentByte cb = writer.getDirectContent(); if (document.getPageNumber() > 1) { ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, header, (document.right() - document .left()) / 2 + document.leftMargin(), document.top() + 10, 0); } footer.writeSelectedRows(0, -1, (document.right() - document.left() - 300) /

How to get a landscape orientation for only some pages while converting html to pdf in itext 7?

早过忘川 提交于 2021-02-17 01:51:33
问题 I convert HTML to PDF using iText7 with the convertToPDF() method of pdfHTML. I would like to change the page orientation for a few specific pages in my PDF document. The content of these pages is dynamic, and we cannot guess how many pages that should be in landscape (i.e. content of dynamic table could take more than one page) Current situation: I create a custom worker (implements ITagWorker ) which landscape the page that following the tag <landscape/> public byte[] generatePDF(String

How to get a landscape orientation for only some pages while converting html to pdf in itext 7?

一笑奈何 提交于 2021-02-17 01:50:24
问题 I convert HTML to PDF using iText7 with the convertToPDF() method of pdfHTML. I would like to change the page orientation for a few specific pages in my PDF document. The content of these pages is dynamic, and we cannot guess how many pages that should be in landscape (i.e. content of dynamic table could take more than one page) Current situation: I create a custom worker (implements ITagWorker ) which landscape the page that following the tag <landscape/> public byte[] generatePDF(String

How to get a landscape orientation for only some pages while converting html to pdf in itext 7?

痞子三分冷 提交于 2021-02-17 01:49:54
问题 I convert HTML to PDF using iText7 with the convertToPDF() method of pdfHTML. I would like to change the page orientation for a few specific pages in my PDF document. The content of these pages is dynamic, and we cannot guess how many pages that should be in landscape (i.e. content of dynamic table could take more than one page) Current situation: I create a custom worker (implements ITagWorker ) which landscape the page that following the tag <landscape/> public byte[] generatePDF(String

java使用Freemarker、Flying sauser生成pdf,中文不显示、设置页眉、换页、红色中文字体不能加粗显示、中文不能换行解决

微笑、不失礼 提交于 2021-02-13 21:40:52
因为做这个很坑,花了几天时间,终于爬出来了,为了实现功能,借鉴了很多代码,找起来很麻烦,现整合一下,方便使用,所以记录下。 首先上两个效果图: 需求图1: demo图2: 做了个demo导出pdf,demo的看不出换行,懒得去加数据了,所以把自己用的图发出来。 本人使用的jar包: freemarker-2.3.22.jar,flying-saucer-core-9.1.16.jar,flying-saucer-pdf-9.1.16.jar,itext-4.2.0.jar, serializer-2.7.1.jar(遇到java.lang.NoClassDefFoundError: org/apache/xml/serializer/TreeWalker,丢失这个jar,可以加上去) jar包地址: maven repository 下载 因为工作上需要,第一次做导出pdf,word,然后入了Freemarker的坑。开始做pdf导出,由于项目中已经有了类似导出,我就用itextpdf来导出生成pdf,后面又需要生成word,在系统上没有发现类似功能,一直复制别人写的代码早就想练练手了,所以查阅了下生成word的几种方式,后面选了Freemarker,这是最简单的方式,也是很快就把word生成了。后面用户说这个pdf样式不合格,被怼了回来, 完成的比较匆忙,可能有很多itext

iText version 4.2.1 redirected in maven central repository

点点圈 提交于 2021-02-13 12:05:57
问题 We're using iText in one of our projects to generate PDF reports, precisely the version 4.2.1 because it is the last free version. <dependency> <groupId>com.lowagie</groupId> <artifactId>itext</artifactId> <version>4.2.1</version> </dependency> When I cloned the repository on an new machine this morning, I faced a lot of compiler errors, because maven redirects to version 5.5.6 and the imports are failing. On our research, we found out, that the pom-file in maven central was changed last week

iText version 4.2.1 redirected in maven central repository

ⅰ亾dé卋堺 提交于 2021-02-13 12:02:28
问题 We're using iText in one of our projects to generate PDF reports, precisely the version 4.2.1 because it is the last free version. <dependency> <groupId>com.lowagie</groupId> <artifactId>itext</artifactId> <version>4.2.1</version> </dependency> When I cloned the repository on an new machine this morning, I faced a lot of compiler errors, because maven redirects to version 5.5.6 and the imports are failing. On our research, we found out, that the pom-file in maven central was changed last week

How can I export the stamp annotation from image to an image file?

痴心易碎 提交于 2021-02-11 14:49:27
问题 How can I export the “stamp annotation from image” to an image file? I have a pdf which contains stamp annotions (in fact it's an image), I want to export all these kinds of images to file and get the x/y position. I am new to pdf. Any idea or code will be appreciated. [--- Edited on 2019/08/08 ---] private void btnExtractAnnotaion_Click(object sender, EventArgs e) { PdfReader reader = new PdfReader(this.txtPdf.Text); PdfDictionary pageDict = reader.GetPageN(reader.NumberOfPages); PdfArray

How to use Fonts in iText PDF

天涯浪子 提交于 2021-02-11 14:25:27
问题 I have a java application where i have to use "Bodoni MT Black" font using FontFactory in itextPdf how should i modify my code? This is my code, Font base = FontFactory.getFont(FontFactory.TIMES_ROMAN, 6); how to change font to "Bodoni MT Black" (Not supported in FontFactory) instead of TIMES_ROMAN? please help. 回答1: The code in your question is code that uses iText 5. However, iText 5 is no longer supported. The current version of iText is iText 7.1.2: If you are working on a new project,