itextsharp

itextsharp: how do i add a new page and write to it?

老子叫甜甜 提交于 2019-12-29 06:55:32
问题 in vb.net i filled up the first page of a pdf document, how do i start from the second page? 回答1: Document document = new Document(PageSize.A4, 0, 0, 50, 50); System.IO.MemoryStream msReport = new System.IO.MemoryStream(); try { // creation of the different writers PdfWriter writer = PdfWriter.GetInstance(document, msReport); // we add some meta information to the document document.AddTitle("My Title"); document.AddAuthor("Me"); document.Open(); for (int i = 1; i <= 5; i++) { document.NewPage

Using Fonts in System with iTextSharp

家住魔仙堡 提交于 2019-12-29 06:03:31
问题 I want to use iTextSharp to write some text. I'm using this method: var font = BaseFont.CreateFont(BaseFont.TIMES_BOLD, BaseFont.WINANSI, BaseFont.EMBEDDED); My question is: does iTextSharp support all fonts in the system fonts directory? Say I have a font called 'mycoolfont' selected by the user in the font chooser dialog. Can I create a new iTextSharp font like this? var font = BaseFont.CreateFont("mycoolfont", BaseFont.WINANSI, BaseFont.EMBEDDED); overContent.SetFontAndSize(font, fontSize)

Get the export value of a checkbox using iTextSharp

北城以北 提交于 2019-12-28 17:49:08
问题 I'm working on dynamically filling in the fields on a pdf document using ITextSharp. I'd like to be able to determine the "export value" of the checkbox is from the codebehind in order to determine what value to send to this checkbox if it should be checked. Most of the documents I've worked with in the past had the same export value for every check box but the one I'm currently working with varies from checkbox to checkbox. I could go through all of the text boxes and make them consistent

ITextSharp - text field in PdfPCell

﹥>﹥吖頭↗ 提交于 2019-12-28 16:04:44
问题 I'm using iTextSharp to create a PDF, how can I add a textField into PdfPCell? 回答1: You wouldn't really add a 'text field' to a PdfPCell, you'd create a PdfPCell and add text (or other stuff) to that. mikesdotnetting.com might have the clearest example and there's always the iTextSharp tutorial. 回答2: Give this a try. It works for me. Document doc = new Document(PageSize.LETTER, 18f, 18f, 18f, 18f); MemoryStream ms = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(doc, ms); doc

ITextSharp - text field in PdfPCell

╄→尐↘猪︶ㄣ 提交于 2019-12-28 16:03:12
问题 I'm using iTextSharp to create a PDF, how can I add a textField into PdfPCell? 回答1: You wouldn't really add a 'text field' to a PdfPCell, you'd create a PdfPCell and add text (or other stuff) to that. mikesdotnetting.com might have the clearest example and there's always the iTextSharp tutorial. 回答2: Give this a try. It works for me. Document doc = new Document(PageSize.LETTER, 18f, 18f, 18f, 18f); MemoryStream ms = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(doc, ms); doc

Bold a single word within a sentence with iTextSharp

▼魔方 西西 提交于 2019-12-28 13:04:26
问题 Is it possible to bold a single word within a sentence with iTextSharp? I am trying to bold several individual words without having to break the string into individual phrases. I want to this type of out put Eg: REASON(S) FOR CANCELLATION: See Statutory reason(s) designated by Code No(s) 1 on the reverse side hereof. My actual output is below Eg:REASON(S) FOR CANCELLATION: See Statutory reason(s) designated by Code No(s) 1 on the reverse side hereof. Code pdftb4 = new PdfPTable(1); pdftb4

iTextSharp XMLWorker parsing really slow

£可爱£侵袭症+ 提交于 2019-12-28 06:36:09
问题 I am parsing HTML string using iTextSharp XMLWorker in my WPF application using the below code: var css = ""; using (var htmlMS = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(html))) { //Create a stream to read our CSS using (var cssMS = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(css))) { //Get an instance of the generic XMLWorker var xmlWorker = XMLWorkerHelper.GetInstance(); //Parse our HTML using everything setup above xmlWorker.ParseXHtml(writer, doc, htmlMS, cssMS, System

How to add a rich Textbox (HTML) to a table cell?

北城以北 提交于 2019-12-28 04:31:08
问题 I have a rich text box named:”DocumentContent” which I’m going to add its content to pdf using the below code: iTextSharp.text.Font font = FontFactory.GetFont(@"C:\Windows\Fonts\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 12f, Font.NORMAL, BaseColor.BLACK); DocumentContent = System.Web.HttpUtility.HtmlDecode(DocumentContent); Chunk chunkContent = new Chunk(DocumentContent); chunkContent.Font = font; Phrase PhraseContent = new Phrase(chunkContent); PhraseContent.Font = font; PdfPTable

Sign PDF with iTextSharp 5.3.3 and USB token

我们两清 提交于 2019-12-28 03:51:09
问题 I'm new to iTextSharp (and StackOverFlow). I'm trying to sign a PDF in C# using external USB token. I try using the follow code I've digged from the internet. Org.BouncyCastle.X509.X509CertificateParser cp = new Org.BouncyCastle.X509.X509CertificateParser(); //Get Sertifiacte X509Certificate2 certClient = null; X509Store st = new X509Store(StoreName.My, StoreLocation.CurrentUser); st.Open(OpenFlags.MaxAllowed); X509Certificate2Collection collection = X509Certificate2UI.SelectFromCollection(st

Returning iTextSharp PDF as memorystream causes StreamNotSupported

我们两清 提交于 2019-12-28 02:16:55
问题 I'm creating a PDF file using the PdfStamper in iTextSharp and return the PDF as a memorystream object to the calling function, that is then used to display the PDF in Teleriks PDF Viewer Component for WinForms. That's the objective. Right now, creating the PDF works as it should, and it returns the data to the Calling function, and in the Calling function, should I write the memorystream contents to a file stream and then open it in Adobe Reader Everything looks just fine. However, if I