itextpdf

Change the color of pdf pages alternatively using iText pdf in java

时间秒杀一切 提交于 2019-11-27 07:24:57
问题 I'm creating report based on client activity. I'm creating this report with the help of the iText PDF library. I want to create the first two pages with a blue background color (for product name and disclaimer notes) and the remaining pages in white (without a background color). I colored two pages at the very beginning of report with blue using following code. Rectangle pageSize = new Rectangle(PageSize.A4); pageSize.setBackgroundColor(new BaseColor(84, 141, 212)); Document document = new

How should I interpret the coordinates of a rectangle in PDF?

人走茶凉 提交于 2019-11-27 06:19:45
问题 I would like to know more about the coordinates of a Rectangle, in particular: lower left X lower left Y upper right X upper right Y Every time, I get confused about how to make dimensions based on these coordinates to draw rectangle. If possible, can I get a graphical representation briefly about these coordinates positions? 回答1: Before someone can explain what the lower-left X, lower-left Y, upper-right X and upper-right Y of a rectangle are about, you need to know about the coordinate

Create Index File(TOC) for merged pdf using itext library in java

那年仲夏 提交于 2019-11-27 04:56:22
I am using iText to create a single PDF by merging a number of PDFs using PDFCopy . I need to create a TOC (not bookmarks) at the beginning of this document with clickable links to the first pages of each of the source PDFs. Code to merge pdf Document PDFJoinInJava = new Document(); PdfCopy PDFCombiner = new PdfCopy(PDFJoinInJava, outputStream); PdfCopy.PageStamp stamp; PDFJoinInJava.open(); PdfReader ReadInputPDF; List<InputStream> pdfs = streamOfPDFFiles; List<PdfReader> readers = new ArrayList<PdfReader>(); int totalPages = 0; Iterator<InputStream> iteratorPDFs = pdfs.iterator(); for (;

iText - avoid last row not to cut tables on page split to next page

别说谁变了你拦得住时间么 提交于 2019-11-27 03:25:21
问题 I am working on itext 5 using java. I have pages with mutiple tables with dynamic rows. In some instances, the table last row is splitted into next page with the folowing header. I am using setHeaderRows() and setSkipFirstHeader() to manage continuation of next page. The last row has enough space to fit on earlier page. I would like to fit that last row in same page instead of next page. For example, on page 1, the last row is splitted into first row of next page. Instead I would like to fit

How to adjust the page height to the content height?

我们两清 提交于 2019-11-26 23:19:49
I'm using iTextPDF + FreeMarker for my project. Basically I load and fill an HTML template with FreeMarker and then render it to pdf with iTextPDF's XMLWorker . The template is: <html> <body style="font-family; ${fontName}"> <table> <tr> <td style="text-align: right">${timestampLabel} </td> <td><b>${timestampValue}</b></td> </tr> <tr> <td style="text-align: right">${errorIdLabel} </td> <td><b>${errorIdValue}</b></td> </tr> <tr> <td style="text-align: right">${systemIdLabel} </td> <td><b>${systemIdValue}</b></td> </tr> <tr> <td style="text-align: right">${descriptionLabel} </td> <td><b>$

Using iTextPDF to trim a page&#39;s whitespace

≯℡__Kan透↙ 提交于 2019-11-26 11:56:22
I have a pdf which comprises of some data, followed by some whitespace. I don't know how large the data is, but I'd like to trim off the whitespace following the data PdfReader reader = new PdfReader(PDFLOCATION); Rectangle rect = new Rectangle(700, 2000); Document document = new Document(rect); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(SAVELCATION)); document.open(); int n = reader.getNumberOfPages(); PdfImportedPage page; for (int i = 1; i <= n; i++) { document.newPage(); page = writer.getImportedPage(reader, i); Image instance = Image.getInstance(page);

Create Index File(TOC) for merged pdf using itext library in java

浪子不回头ぞ 提交于 2019-11-26 11:25:34
问题 I am using iText to create a single PDF by merging a number of PDFs using PDFCopy . I need to create a TOC (not bookmarks) at the beginning of this document with clickable links to the first pages of each of the source PDFs. Code to merge pdf Document PDFJoinInJava = new Document(); PdfCopy PDFCombiner = new PdfCopy(PDFJoinInJava, outputStream); PdfCopy.PageStamp stamp; PDFJoinInJava.open(); PdfReader ReadInputPDF; List<InputStream> pdfs = streamOfPDFFiles; List<PdfReader> readers = new

How to adjust the page height to the content height?

為{幸葍}努か 提交于 2019-11-26 08:38:22
问题 I\'m using iTextPDF + FreeMarker for my project. Basically I load and fill an HTML template with FreeMarker and then render it to pdf with iTextPDF\'s XMLWorker . The template is: <html> <body style=\"font-family; ${fontName}\"> <table> <tr> <td style=\"text-align: right\">${timestampLabel} </td> <td><b>${timestampValue}</b></td> </tr> <tr> <td style=\"text-align: right\">${errorIdLabel} </td> <td><b>${errorIdValue}</b></td> </tr> <tr> <td style=\"text-align: right\">${systemIdLabel} </td>