itextsharp

Passing a parameter to an overridden OnEndPage method

大兔子大兔子 提交于 2019-12-01 21:54:22
问题 I need to pass a parameter to an overridden version of the "OnEndPage" method, when i declare the parameter i don't get any error but when i call the method it tells me that "cannot implicitly convert void to itextsharp.text.pdf.ipdfpageevent" This is my OnEndPage method: public class pdfPage : iTextSharp.text.pdf.PdfPageEventHelper { public override void OnEndPage(PdfWriter writer, Document doc, int parametro) { PdfPTable headerTbl = new PdfPTable(1); headerTbl.TotalWidth = doc.PageSize

c# How to return a byte array from pdf using iTextsharp

余生颓废 提交于 2019-12-01 21:33:25
All, i created the following method to take in a tiff byte array with multiple tiff page document i need to convert this to pdf, then return a pdf byte array i have 2 problems with this code 1 - i want to RETURN a byte []. 2 - the pdf generated is repeating the pages. public void convertImage(byte[] documentContent) { Document document = new Document(PageSize.LETTER, 0, 0, 0, 0); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(@"C:\Data\Output.pdf", FileMode.Create)); --for testing purposes Bitmap oldImage; using (var ms = new MemoryStream(documentContent)) { oldImage = new

iTextSharp Textfield setting the font to Bold

馋奶兔 提交于 2019-12-01 21:27:53
For a textfield object, I would like to change the style to bold. I have already created the arial font since it is not a default font for the BaseFont object. Apparently the TextField object only takes the BaseFont as a valid font. I was wondering how would I change the style of the font that I have assigned to my textfield to bold. Is there a way to do this? here is my code that I have thus far TextField txtNewField = new TextField(stamp.Writer, new Rectangle(1, 1, 75, 25), "TxtField"); BaseFont arial = BaseFont.CreateFont(@"c:\windows\fonts\arial.ttf", BaseFont.CP1252, BaseFont.NOT_EMBEDDED

Creating a fillable PDF form with ITextSharp

余生颓废 提交于 2019-12-01 21:24:03
问题 I have created a PDF file using Acrobat Adobe 8 that contains fillable fields. Can that be programmed with ITextSharp instead of Adobe? Note: I am not referring to filling out the PDF with ITextSharp, instead I would like to create the fillable fields on the PDF file using ITextSharp. Any code would be appreciated. thank you for your time! 回答1: You can create PDFs that contain fillable fields with iText[Sharp], but they won't look as nice as Adobe Acrobat, which is a much better design tool.

iTextSharp XMLWorkerHelper and Images for HTML to PDF

不羁岁月 提交于 2019-12-01 20:59:48
Bottom line is I'm using iTextSharp to write out HTML to a PDF -- with an image . Right now, I'm at the latest version of iTextSharp which is 5.5.5.0. I have access to Bruno's book, and I'm using the methodology spelled out by demo.iTextSupport.com for the conversion. Unfortunately, the book doesn't appear to have any reference to XMLWorkerHelper , which is what I'm using to create the PDF from the HTML. Here's the method I finally got working that successfully generates a PDF from a well-formed HTML string: private string createPDFFromHtml(string htmlString, string outputFileName) { string

Creating a fillable PDF form with ITextSharp

∥☆過路亽.° 提交于 2019-12-01 20:56:36
I have created a PDF file using Acrobat Adobe 8 that contains fillable fields. Can that be programmed with ITextSharp instead of Adobe? Note: I am not referring to filling out the PDF with ITextSharp, instead I would like to create the fillable fields on the PDF file using ITextSharp. Any code would be appreciated. thank you for your time! You can create PDFs that contain fillable fields with iText[Sharp], but they won't look as nice as Adobe Acrobat, which is a much better design tool. By fillable fields, I'm guessing you mean a TextField . Here's a link with some simple example code from the

Passing a parameter to an overridden OnEndPage method

懵懂的女人 提交于 2019-12-01 20:37:53
I need to pass a parameter to an overridden version of the "OnEndPage" method, when i declare the parameter i don't get any error but when i call the method it tells me that "cannot implicitly convert void to itextsharp.text.pdf.ipdfpageevent" This is my OnEndPage method: public class pdfPage : iTextSharp.text.pdf.PdfPageEventHelper { public override void OnEndPage(PdfWriter writer, Document doc, int parametro) { PdfPTable headerTbl = new PdfPTable(1); headerTbl.TotalWidth = doc.PageSize.Width; Image logo = Image.GetInstance("logo.png"); logo.ScalePercent(42); PdfPCell cell = new PdfPCell(logo

iTextSharp - Text overlapping image

扶醉桌前 提交于 2019-12-01 20:35:46
I'm using iTextSharpText to build a PDF. I was asked to add some dynamic text over an image. I've already tried some examples that I found on this forum and other websites, but I can't seem to get this right, and it's really driving me nuts. I followed this thread ( iTextSharp Adding Text plus Barcode in a single cell? ), and tried both answers. First I tried: var img_operacao = Image.GetInstance(String.Format("{0}{1}", Settings.Default.SiteRootURL, "/PublishingImages/PDF_operacao.png")); img_operacao.ScaleToFit(150, 41); img_operacao.Alignment = Image.UNDERLYING; var ph0 = new Phrase(title0,

How to display chinese characters in pdf file created with iTextSharp

懵懂的女人 提交于 2019-12-01 20:16:52
I have string data which contains some english characters and some chinese characters. I m creating a pdf file with this data using iTextSharp. After pdf file is created, when i open it, pdf contains only english characters. It is not showing chinese characters. Can you please tell me how to display chinese characters in pdf file?. Please note that the string data that i m writing to pdf contains dynamic language characters i.e sometimes english, somethimes chinese, sometimes japanese and so on. This is explained in the iText(Sharp) documentation. When you have a String with glyphs from

iTextSharp.tool.xml.XMLWorkerHelper.GetInstance().ParseXHtml not working

隐身守侯 提交于 2019-12-01 20:12:45
I'm using iTextSharp version: 5.5.6; iTextSharp XML Worker version: 5.5.6 I got some code from Here , but after I run the code, the PDF file will never open :The file is damaged and could not be repaired. Local\EWHvxm9t5++ htmltext="\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n Item \r\n Description\r\n LotNo\r\n Revision\r\n NamePlatSN\r\n DateCreated\r\n CreatedBy\r\n \r\n \r\n \r\n \r\n 100-817412-001\r\n X500-G02 - ENV DWG \r\n 15020008\r\n B \r\n testing123\r\n 4/9/2015 12:00:00 AM\r\n ULTRATCS\xma\r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n" The HTML string (better formatted)