itextsharp

ItextSharp fit text to a page

柔情痞子 提交于 2019-12-11 06:54:41
问题 i'm italian and i'm sorry for my english. I'm trying to use itextSharp to convert a txt file into pdf file. this is my code: String l = file.ReadLine() + "\r\n"; while (l != null) { iTextSharp.text.Font contentFont = iTextSharp.text.FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL); //Chunk line = new Chunk(l, contentFont); Paragraph p2 = new Paragraph(l,contentFont); oDoc.Add(p2); oDoc.Add(Chunk.NEWLINE); l = file.ReadLine(); } oDoc.Close(); The text page is a multi page file, so

How to encode Chinese text in QR barcodes generated with iTextSharp?

落爺英雄遲暮 提交于 2019-12-11 06:51:43
问题 I'm trying to draw QR barcodes in a PDF file using iTextSharp. If I'm using English text the barcodes are fine, they are decoded properly, but if I'm using Chinese text, the barcode is decoded as question marks. For example this character '测' (\u6D4B) is decoded as '?'. I tried all supported character sets, but none of them helped. What combination of parameters should I use for the QR barcode in iTextSharp in order to encode correctly Chinese text? 回答1: iText and iTextSharp apparently don't

Text not fitting into form fields (iTextSharp)

倾然丶 夕夏残阳落幕 提交于 2019-12-11 06:25:26
问题 I created a .PDF file using Adobe Acrobat Pro. The file has several text fields. Using iTextSharp, I'm able to populate all the fields and mail out the .PDF. One thing is bugging me - some of the next will not "fit" in the textbox. In Adobe, if I type more that the allocated height, the scroll bar kicks in - this happens when font size is NOT set to auto and multi-line is allowed. However, when I attempt to set the following properties: //qSize is float and set to 15; //auto size of font is

Missing character in custom font

柔情痞子 提交于 2019-12-11 06:19:16
问题 We are using iTextSharp to create PDF's using a custom font and I am running into an issue with the unicode character 2120 (SM, Service Mark). The problem is the glyph is not in the custom font. Is there a way I can specify a fallback font for a field in a PDF? We tried adding a text field with Verdana so that the form had the secondary font embedded in it but that didn't seem to help. 回答1: First you need to find a font (ttf, otf,...) that has the character you need. Then you can use the

PDF generated with itext becomes 'corrupted' when using SetSimpleColumn()

不打扰是莪最后的温柔 提交于 2019-12-11 05:59:22
问题 First I would like to point out that stackowerflow helped me with many problems in the past, so thank you all. But now I have come to problem that I haven't fount a solution for yet and it's driving me crazy. I'm not native english speaker, so sorry for any language mistakes. So here it is: I'm generating pdf with itextsharp library(great library by the way). I'm starting with some kind of pdf form/template, to which i'm adding 'fill-out' data. I'm using PdfReader to read template pdf and by

iTextSharp jbig2 encoder

Deadly 提交于 2019-12-11 05:51:35
问题 string imgfile = @"C:\users\me\desktop\test.jpg"; Bitmap bmp = new Bitmap(imgfile); Bitmap bw = ConvertTo1Bpp(bmp); //make b+w Document doc = new Document(new iTextSharp.text.Rectangle(bmp.Width, bmp.Height)); PdfWriter.GetInstance(doc, new System.IO.FileStream( @"C:\users\me\desktop\test.pdf", System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite)); iTextSharp.text.ImgJBIG2 i = ((iTextSharp.text.ImgJBIG2)iTextSharp.text.ImgJBIG2.GetInstance( bmp, System.Drawing.Imaging.ImageFormat.Bmp));

How to get the header and footer of a page

六月ゝ 毕业季﹏ 提交于 2019-12-11 05:14:38
问题 How do I get code in the header and footer of a PDF file using C # 2012 (asp.net) + iTextSharp (v5.4.5.0)? At the moment I can extratir the pages but I need to separate the headers and footers of your content. Below is my code to get the page: PdfReader pdfreader = new PdfReader(nmfile); ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy(); for (int page = 1; page <= pdfreader.NumberOfPages; page++) { extractText = PdfTextExtractor.GetTextFromPage(pdfreader, page, strategy);

Check if “Continued” or “New” page

落爺英雄遲暮 提交于 2019-12-11 05:07:03
问题 I would like to know if there is a way to check if the "New Page" happened because of exceeded table or programmatically (by using doc.NewPage(); )? If the new page caused because of exceeded table or text, I need to hide the header table and show a text instead, else if the new page caused programmatically I need to display the header table normally. I tried to find a flag or something like this in the "OnStartPage" event that show me if the page exceeded or not, but I found nothing. I hope

Setting AcroField Position using iTextSharp

 ̄綄美尐妖づ 提交于 2019-12-11 04:53:20
问题 The iTextSharp AcroFields class has a GetFieldPosition method. I am attempting to modify a field's position programmatically. I'm wondering why there is no corresponding SetFieldPosition , or is there another way of changing a field's size or position? 回答1: See this for part of the reason. There isn't actually a singular GetFieldPosition but instead a plural GetFieldPositions since you can technically have multiple fields with the same name. So a theoretical SetFieldPositions would need to

Does iTextSharp rely upon COM interop at any point

青春壹個敷衍的年華 提交于 2019-12-11 04:49:43
问题 Our IIS7.5 website needs to inject some data into a PDF (filling in form fields) immediately before the PDF is downloaded by the user. The users are employees of our customers, and we know which company they work for, and a program on our server would be injecting company-specific data into several fields. iTextSharp might be just the ticket. Is it 100% native CLR code, or does it rely at any point upon COM interop? 回答1: iTextSharp core is 100% managed code with no COM Interop and no