itextsharp

Applying color to Strings in Paragraph using Itext

狂风中的少年 提交于 2019-12-24 02:09:14
问题 I am combining 2 strings to Paragraph this way, String str2=""; String str1=""; ColumnText ct = new ColumnText(cb); ct.setSimpleColumn(36, 600, 600, 800); ct.addElement(new Paragraph(str1 + str2)); int status1 = ct.go(); The problem is I am getting same font color for both str1 & str2. I want to have different font color and size for str1 & str2.. How Can i do that on ColumnText/Paragraph? Can someone help me in this... 回答1: When you combine text into a Paragraph like this: Paragraph p = new

iTextSharp XmlWorker: right-to-left

元气小坏坏 提交于 2019-12-24 01:53:52
问题 After a long time of struggling with this not-so-friendly API, I am finally making progress, but now I've come to a really nasty issue.. I have placed "dir" attributes in various places in my html with the value being "rtl".. but the XMLWorker doesn't seem to respect that at all. Does anyone know of a workaround? Here's my method: public static void Generate<TModel>(string templateFile, TModel model, string outputFile, IEnumerable<string> fonts) { string template = System.IO.File.ReadAllText

TextBox controls are not Working with Export To PDF(iTextSharp)

▼魔方 西西 提交于 2019-12-24 01:47:33
问题 I have an HTML form, which contains lables and textboxes. After filling this form, it is exported to PDF. All the label Texts are exported. But the textbox text is not exported to PDF. Code protected void btnExportPDF_Click(object sender, EventArgs e) { Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=DecForm.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new

Adding listchoices to Pdfform with c# code

徘徊边缘 提交于 2019-12-24 01:44:58
问题 I'm trying to add choices to a List-field within a pdf form via C# and the itextsharp library. But i cant find a way to do this. The form already exists, i created it with Acrobat. I would like that the Listfield choices from the PDF are the same as in my program. Therefore I want to create the options in the list-fields via itextsharp to reduce the maintenance. But I cant find away to do this. With the PDFstamper from the library I am able to fill the Fields from the form. And Color some

Apply custom font to html in itextsharp

和自甴很熟 提交于 2019-12-24 00:33:43
问题 I have code FontFactory.Register(Server.MapPath("includes/fonts/Rockwell-Light.ttf")); StyleSheet style = new StyleSheet(); style.LoadTagStyle("div", "face", "customfont"); style.LoadTagStyle("div","encoding",BaseFont.CP1250); foreach (IElement element in HTMLWorker.ParseToList(new StringReader("<div>" + getProductDescription((this.Product.Description != null) ? this.Product.Description : "") + "</div>"), style)) { productDescCell.AddElement(element); } my issue is could not apply font to

Croatian letters in iTextSharp

我是研究僧i 提交于 2019-12-24 00:17:06
问题 I'm still a beginner in C# and I want to know is there an option of writing slavic letters č,ć,š,ž in PDF using iTextSharp. I was reading other posts about it but I can't apply their solution to my problem, maybe it's a bit to complicate to me as a beginner. This is my code: SaveFileDialog pdfFile = new SaveFileDialog(); pdfFile.Filter = "PDF|*.pdf"; pdfFile.Title = "Spremi PDF"; pdfFile.FileName = "Ispit"; if (pdfFile.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Document document

Print PDF Created in iTextSharp and then Return Control to Browser

折月煮酒 提交于 2019-12-23 22:16:06
问题 This is somewhat of a return to my 2012 question - Is it possible to fire a keypress event for an iframe that has been used to load a PDF file, I think I may have been mistaken accepting the answer there. The current situation is this - The document of the main page has an onkeypress event attached to it which will load a PDF into an object when the user scans a particular barcode. The PDF is created using iTextSharp and has the open action set - writer.SetOpenAction(new PdfAction(PdfAction

Save PDF to DISC

江枫思渺然 提交于 2019-12-23 22:03:24
问题 Following Code streams PDF file to the Browser, however I want to SAVE it to the disk (c:\myfile.pdf)... Dim FilePath As String = Server.MapPath("/docs/templates/page_1_cover.pdf") Dim reader As New PdfReader(FilePath) Dim output As MemoryStream = New MemoryStream() Dim stamper As PdfStamper = New PdfStamper(reader, output) stamper.AcroFields.SetField("APPLICANT NAME", "KnowlegeZone") reader.Close() stamper.Close() Response.AddHeader("Content-Disposition", "attachment; filename=YourPDF_I9.pdf

Why is my PDF being generated as blank?

吃可爱长大的小学妹 提交于 2019-12-23 20:12:38
问题 I am using ItextSharp and c#, asp.net MVC to generate a PDF report. However, when I generate the report the PDF comes back as blank (apart from a header which is working fine). I would love your input. The code that generates the report is as follows: using (var writer = PdfWriter.GetInstance(doc, ms)) { // This sorts out the Header and Footer parts. var headerFooter = new ReportHeaderFooter(reportsAccessor); writer.PageEvent = headerFooter; var rootPath = ConfigurationManager.AppSettings[

Adding Rich Text to an AcroField in iTextSharp

余生颓废 提交于 2019-12-23 18:37:33
问题 I need to add some formatted text to a PDF form field using iTextSharp and I can't seem to figure it out. This is how I'm currently setting the fields, but certain portions of the inserted text will need to be bold or have other formatting. stamper.AcroFields.SetField("fieldName", "fieldValue") stamper.FormFlattening = True I've seen elsewhere that I should be able to insert some xml that includes formatting information instead, but I have no idea what this xml should look like. Here's the