itextpdf

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

試著忘記壹切 提交于 2019-12-31 00:47:21
问题 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

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

大兔子大兔子 提交于 2019-12-31 00:47:02
问题 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

itext7 pdf to image

本小妞迷上赌 提交于 2019-12-29 04:55:11
问题 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

Pagination in ItextPdf

人走茶凉 提交于 2019-12-25 19:06:06
问题 we use itextpdf and xmlworker APIs ( itextpdf-5.1.1.jar, Xmlworker-1.1.0.jar) for PDF generation tasks in our application. We generate HTML content from XML-XSLT conversion and then use the HTML content to create pdf document. When we trying to implement pagination ( as 1 of 3, 2 of 3..), we learnt from itextpdf online samples that we always need to create a resultant pdf document apart from the PDF document that we create in order to stamp the page number on the each page content. This

itextpdf: how to insert a new page when a table splits?

笑着哭i 提交于 2019-12-25 07:39:37
问题 I'm using iTextPdf 5.4.1. I have a table with many rows in it, and when the table auto-splits to the next page, I want to insert an Image and then another page break to continue the table's rows. For example: say a table will take up 2 pages based on the number of rows it has. The final output should be: page 1: table rows that fit on first page page 2: image page 3: remaining table rows. So, each time the table splits, i want to insert an image and then a page break. I'm trying to use the

Using iTextPDF to trim a page's whitespace

本秂侑毒 提交于 2019-12-25 06:38:46
问题 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

iText7 scaling rotated document with links

亡梦爱人 提交于 2019-12-25 06:35:26
问题 I am using iText7(java) and trying to scale a portrait document to landscape. The document contains links and has rotation set to 270. Setting mediabox and cropbox on document does not work due to rotation. The solution mentioned in iText Examples does not work properly and hyperlinks in document stop working. There might be loss of other metadata as well . Is there any way to scale the document without using copyAsFormXObject. Following method in itext7 to manipulate documents works very

iText7 scaling rotated document with links

喜夏-厌秋 提交于 2019-12-25 06:35:18
问题 I am using iText7(java) and trying to scale a portrait document to landscape. The document contains links and has rotation set to 270. Setting mediabox and cropbox on document does not work due to rotation. The solution mentioned in iText Examples does not work properly and hyperlinks in document stop working. There might be loss of other metadata as well . Is there any way to scale the document without using copyAsFormXObject. Following method in itext7 to manipulate documents works very

itextpdf acrofields format as Percentage

谁说我不能喝 提交于 2019-12-24 10:52:05
问题 I use ITextPdf feom c# code. I use acrofields to populate a form with data. I am losing my formatting. Stream os = new FileStream(PDFPath, FileMode.CreateNew); PdfReader reader = new PdfReader(memIO); PdfStamper stamper = new PdfStamper(reader, os, '9', true); AcroFields fields = stamper.AcroFields; fields.SetField("Pgo", 1.0 "Percentage"); What am I doing wrong? 回答1: You say you are losing all your formatting. This leads to the assumption that your form contains JavaScript that formats

Itextpdf : set image in middle of text

为君一笑 提交于 2019-12-23 23:06:52
问题 I have a text in paragraph I want set an image in the middle of text : public void createPdf(String dest, String imgSource) throws IOException, DocumentException { Document doc = new Document (); PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(dest)); doc.open (); Paragraph p = new Paragraph(); Image image1 = Image.getInstance(imgSource); p.add(new Chunk("This is my photo : ")); p.add (image1); p.add(new Chunk(" so beautifull :)")); doc.add(p); doc.close(); } it is a small