itextpdf

How to display indian rupee symbol in iText PDF in MVC3

寵の児 提交于 2019-12-01 19:52:38
I want to display Special Character India Rupee Symbol in iTextPDf, My Code: Font fontRupee = FontFactory.GetFont("Arial", "₹", true, 12); Chunk chunkRupee = new Chunk(" ₹ 5410", font3); It's never a good idea to store a Unicode character such as ₹ in your source code. Plenty of things can go wrong if you do so: Somebody can save the file using an encoding different from Unicode, for instance, the double-byte rupee character can be interpreted as two separate bytes representing two different characters. Even if your file is stored correctly, maybe your compiler will read it using the wrong

How can I use regular and bold in a single String?

家住魔仙堡 提交于 2019-12-01 19:28:43
I have a String that consists of a constant part and a variable part. I want the variable to be formatted using a regular font within the text paragraph, whereas I want the constant part to be bold. This is my code: String cc_cust_name = request.getParameter("CC_CUST_NAME"); document.add(new Paragraph(" NAME " + cc_cust_name, fontsmallbold)); My code for a cell in a table looks like this: cell1 = new PdfPCell(new Phrase("Date of Birth" + cc_cust_dob ,fontsmallbold)); In both cases, the first part ( " NAME " and "Date of Birth" ) should be bold and the variable part ( cc_cust_name and cc_cust

Signing PDF - memory consumption

和自甴很熟 提交于 2019-12-01 05:50:45
问题 I tried some utilities for digital PDF signing based on iText v1 or v2 and found out that it seems whole PDF is loaded into memory (for 60M PDF process can take up to 300-400MB of memory). Can recent iText versions sign PDF without load it into memory? Updates I tested Bruno's example with itextpdf 5.5.6 PdfReader constructor doesn't matter - it can be (src) or (src, null, true), or (src, null, false) - result the same. what matters is new File(tmp) in createSignature. But memory consumption

How to convert iTextPDF Document to Byte Array

ぃ、小莉子 提交于 2019-11-30 03:18:52
问题 I need to convert iTextPDF Document file to byte[] after it's created in memory . I have already tested that I've no problem with creating PDF properly. The problem is how to convert it to byte array to store in DB. Here's my code: Document generatedDocument = reportService.generateRequestForm(scdUser, jsonObject, 0, null); reportService.generateRequestForm(scdUser, jsonObject, 0, null); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter pdfWriter = PdfWriter.getInstance

How to choose the optimal size for a font?

北城余情 提交于 2019-11-29 15:44:10
I'm creating a pdf document with a grid table based on the PdfPTable in itextpdf. The input data arrives as a java String[][] with all the cells filled. For each column, I iterate over all the rows to identify the maximum columns required to display the data for that column. That becomes the column width. All of the column widths are summed to determine the maximum number of columns for the entire table. At this point, my intent is to calculate the optimum point size for a monospace font to fully occupy the width of the columns. The objective is maximum readability in the face of very dynamic

itext7 pdf to image

你离开我真会死。 提交于 2019-11-29 00:30:27
I am using iText7(java) and am looking for a way to convert a pdf page to image. In older iText versions you could do this : PdfImportedPage page = writer.getImportedPage(reader, 1); Image image = Image.getInstance(page); But iText7 does not have PdfImportedPage . My use case, I have a one page pdf file. I need to add a table and resize the pdf contents to fit a single page. In old iText I would create a page , add table, convert existing pdf page to image, resize image and add that resized image to new page. Is there a new way to do this in iText7. Thanks to Bruno's answer I got this working

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

社会主义新天地 提交于 2019-11-28 13:02:49
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 Document( pageSize ); But when I move to 3rd page using document.newpage() , the page is still in blue. I

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

纵饮孤独 提交于 2019-11-28 10:08:10
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 that row in page 1 so save one extra page with all blanks. I tried using setExtendLastRow() , but its

How to choose the optimal size for a font?

爱⌒轻易说出口 提交于 2019-11-28 09:22:07
问题 I'm creating a pdf document with a grid table based on the PdfPTable in itextpdf. The input data arrives as a java String[][] with all the cells filled. For each column, I iterate over all the rows to identify the maximum columns required to display the data for that column. That becomes the column width. All of the column widths are summed to determine the maximum number of columns for the entire table. At this point, my intent is to calculate the optimum point size for a monospace font to

PDF Page re-ordering using itext

爱⌒轻易说出口 提交于 2019-11-27 09:48:16
i am using itext pdf library. can any one know how can i move pages in existing pdf? Actually i want to move few last pages at beginning of file. It is something like below but i don't understand how it work. reader = new PdfReader(baos.toByteArray()); n = reader.getNumberOfPages(); reader.selectPages(String.format("%d, 1-%d", n, n-1)); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(filename)); stamper.close(); Can any one explain in detail? The selectPages() method is explained in chapter 6 of my book (see page 164). In the context of code snippet 6.3 and 6.11, it is used to