itext

iTextSharp need to repeat table rows with textfield dynamically

半腔热情 提交于 2020-01-16 04:04:29
问题 I am reading and filling a dynamic pdf template(having dynamic table with textfields in each cell) below way using iTextSharp [assuming I would be getting a single product info from source]: FileStream fs = new FileStream("C:\\ABC\\DestinationFile.pdf", FileMode.Create); PdfReader reader = new PdfReader("C:\\ABC\\SourceTemplateFile.pdf"); PdfStamper stamper = new PdfStamper(reader, fs); xfa = stamper.AcroFields.Xfa; string[] strProductList = productInfo.Product.Split('|'); string dName=

JZOS and iText on z/OS

折月煮酒 提交于 2020-01-15 14:26:57
问题 I am trying to create a PDF on z/OS using JZOS and iText. I have tried so many combinations for the font as well as the DefaultPlatformEncoding but I just don't seem to be able to get the Arabic characters to display in the PDF. They display as Latin characters. When I turn the PDF compression off and display the hex characters, I see the EBCDIC hex codes. The input file on z/OS is IBM-420 and the output PDF should have Cp1256 or Windows-1256 for display on Windows. Here is the snippet of the

Why is data added to the PDF content stream?

一笑奈何 提交于 2020-01-15 10:43:09
问题 When using this code (Removing Watermark from PDF iTextSharp) to simply read and re-write the content stream for an identical PDF, I get additional operations added to the content stream for this file. Before Content Stream q q /I0 Do Q Q q 10 0 0 10 0 0 cm 0.1 0 0 0.1 0 0 cm /QuickPDFXO6d1c5c37 Do Q After Content Stream q 0 -1 1 0 0 1224 cm q q /I0 Do Q Q q 10 0 0 10 0 0 cm 0.1 0 0 0.1 0 0 cm /QuickPDFXO6d1c5c37 Do Q Q Any idea why this was appended to my content stream? q 0 -1 1 0 0 1224 cm

Why is data added to the PDF content stream?

自古美人都是妖i 提交于 2020-01-15 10:43:09
问题 When using this code (Removing Watermark from PDF iTextSharp) to simply read and re-write the content stream for an identical PDF, I get additional operations added to the content stream for this file. Before Content Stream q q /I0 Do Q Q q 10 0 0 10 0 0 cm 0.1 0 0 0.1 0 0 cm /QuickPDFXO6d1c5c37 Do Q After Content Stream q 0 -1 1 0 0 1224 cm q q /I0 Do Q Q q 10 0 0 10 0 0 cm 0.1 0 0 0.1 0 0 cm /QuickPDFXO6d1c5c37 Do Q Q Any idea why this was appended to my content stream? q 0 -1 1 0 0 1224 cm

Image transparency in PDF using iTextSharp

匆匆过客 提交于 2020-01-15 05:23:58
问题 I have an incoming jpg file, that I can set a colour to transparent. When I add the image to another image, this works perfectly. I am trying to add the same image to a PDF using iTextSharp, but I cannot get the transparency to work. I have tried two ways, but neither is working. The first way was to open the image in a Bitmap, set transparency, then use that Bitmap object in the PDF. The second way (shown here) was saving the Bitmap to disk and opening the file into the iTextSharp image.

iText setEncryption error

一曲冷凌霜 提交于 2020-01-14 14:40:13
问题 I've recently had to upgrade to iText, but I'm having problems getting setEncryption to work. I'm using iText 5.5.6. document = new Document(PageSize.LETTER, 36, 36, 72, 72); writer = PdfWriter.getInstance(document, out); writer.setEncryption(null, OWNER_PASSWORD.getBytes(), writer.AllowPrinting|writer.AllowCopy, PdfWriter.STANDARD_ENCRYPTION_128); gets me the following error: java.lang.SecurityException: class "org.bouncycastle.asn1.ASN1Primitive"'s signer information does not match signer

Compress pdf with large images in Android

大城市里の小女人 提交于 2020-01-14 09:48:07
问题 This question compress pdf with large images via java gives the code to compress a PDF with iText in Java. Since in Android there are no Graphics2D, AffineTransform, BufferedImage and ImageIO, I thought of adapting this code by using the Bitmap class. UPDATE: Thanks to @TilmanHausherr, I modified the compression to JPEG and got the following working code. public static void manipulatePdf(String src, String dest) throws IOException, DocumentException { // Read the file PdfReader reader = new

iText- ColumnText set text fit size in Rectangle

坚强是说给别人听的谎言 提交于 2020-01-14 08:44:28
问题 I want to add text into a rectangle(x,y,w,h). Text should be fitted size of rectangle (mean it has a maximum size but it still contains in rectangle). I tried to measure the text size base on BaseFont.getWidthPoint() The problem is the final text size can't fit the rect. It looks like this: Here is my try: PdfContentByte cb = writer.getDirectContent(); cb.saveState(); ColumnText ct = new ColumnText(writer.getDirectContent()); Font font = new Font(BaseFont.createFont()); int rectWidth = 80;

Add space between two tables in iTextSharp

守給你的承諾、 提交于 2020-01-14 08:20:49
问题 Just as the title says, I'm using iTextSharp to generate a report. And I want to add a space between two tables, but I don't know how. this is my code: var boldFont = FontFactory.GetFont(FontFactory.HELVETICA_BOLD, 12); PdfPTable table1 = new PdfPTable(2); table1.WidthPercentage = 25; table1.HorizontalAlignment = Element.ALIGN_LEFT; table1.AddCell(new PdfPCell(new Paragraph("Factura No: "))); table1.AddCell(new PdfPCell(new Paragraph("#1"))); table1.AddCell(new PdfPCell(new Paragraph("Tipo

Converting a PDF into multiple JPGs with iText or other

别来无恙 提交于 2020-01-14 06:56:28
问题 I have the need to convert any multipage PDF file into a set of JPGs. Since the PDF files are supposed to come from a scanner, we can assume each page just contains a graphic object to extract, but I cannot be 100% sure of that. So, I need to convert any renderable content from each page into a single JPEG file. How can I do this with iText? If I can't do this with iText, what Java library can achieve this? Thanks. 回答1: ICEpdf - http://www.icepdf.org/ - has an open source entry version which