itextsharp

How to Merge two memory streams containing PDF file's data into one

纵饮孤独 提交于 2019-12-22 05:16:10
问题 I am trying to read two PDF files into two memory streams and then return a stream that will have both stream's data. But I don't seem to understand what's wrong with my code. Sample Code: string file1Path = "Sampl1.pdf"; string file2Path = "Sample2.pdf"; MemoryStream stream1 = new MemoryStream(File.ReadAllBytes(file1Path)); MemoryStream stream2 = new MemoryStream(File.ReadAllBytes(file2Path)); stream1.Position = 0; stream1.Copyto(stream2); return stream2; /*supposed to be containing data of

How can I set a PDF paragraph's font using iTextSharp?

℡╲_俬逩灬. 提交于 2019-12-22 04:57:09
问题 Trying to follow the example here, I added the following code to create the title of a PDF doc: using (var doc = new Document(PageSize.A4, 50, 50, 25, 25)) { using (var writer = PdfWriter.GetInstance(doc, ms)) { doc.Open(); var docTitle = new Paragraph("UCSC Direct - Direct Payment Form"); var titleFont = FontFactory.GetFont("Lucida Sans", 18, Font.Bold); doc.Add(docTitle); However, the attempt to create titleFont wouldn't compile (" The best overloaded method match for 'iTextSharp.text

.NET version or port of Flying Saucer

可紊 提交于 2019-12-22 04:26:11
问题 Is there any open source .NET project (or port) similar to the Flying Saucer project which renders HTML to PDF using iText? 回答1: I always recommend wkHTMLtoPDF for web->PDF conversions. It's web kit based though I'm not sure what PDF library it's sitting on. At any rate, you'll be hard pressed to find something that will render your HTML more accurately (it'll even run script, set innerHtml and so forth). 回答2: For a quick-and-dirty solution you could try using IKVM to compile the Java to .NET

how to apply font properties on <span> while passing html to pdf using itextsharp

杀马特。学长 韩版系。学妹 提交于 2019-12-22 00:33:13
问题 I am converting html to pdf using itextsharp and I want to set the font size for tags. How can I do this? Currently I am using: StyleSheet styles = new StyleSheet(); styles.LoadTagStyle(HtmlTags.SPAN, HtmlTags.FONTSIZE, "9f"); string contents = File.ReadAllText(Server.MapPath("~/PDF TEMPLATES/DeliveryNote.html")); List parsedHtmlElements = HTMLWorker.ParseToList(new StringReader(contents), styles); But it didn't work. 回答1: The constants listed in HtmlTags are actually a hodgepodge of HTML

Changing font size in itextsharp table

怎甘沉沦 提交于 2019-12-21 21:31:14
问题 Im attempting to view a table in a PDF file using iTextSharp. I've figured out how to add the table, and make the PDF file open off a button click, but the table font is too big, and words are wrapped making them hard to read. I've entered this code, but nothing happens to the tables font. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data

Creating multiple page pdf using iTextSharp

雨燕双飞 提交于 2019-12-21 19:52:34
问题 I am trying to create pdf with multiple pages using iTextSharp Document document = new Document(PageSize.A4, 2, 2, 10, 10); private PdfContentByte _pcb; try { PdfWriter writer = PdfWriter.GetInstance(document, output); document.Open(); document.NewPage(); _pcb = writer.DirectContent; _pcb.BeginText(); _pcb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, text, x, y, 0); _pcb.EndText(); writer.Flush(); } catch(e) { } finally { document.Close(); } This is working fine for me. When I am trying to add

itextsharp place Pdfptable at desired position

可紊 提交于 2019-12-21 17:13:06
问题 Header Content and Pdftable is overlapping How can I place PdfPTable at any position in the pdf page using (x, y) positioning like (100, 200) or (15, 100) at any place on the pdf page? Header Table using PdfEventHelper public override void OnEndPage(PdfWriter writer, Document document) { AddHeader(writer, document); } public void AddHeader(PdfWriter writer, Document document) { // set no of rows PdfPTable headerTable = new PdfPTable(1); // set the width headerTable.TotalWidth = document

Is there a way to replace a text in a PDF file with itextsharp?

点点圈 提交于 2019-12-21 12:25:28
问题 I'm using itextsharp to generate the PDFs, but I need to change some text dynamically. I know that it's possible to change if there's any AcroField, but my PDF doen's have any of it. It just has some pure texts and I need to change some of them. Does anyone know how to do it? 回答1: Actually, I have a blog post on how to do it! But like IanGilham said, it depends on whether you have control over the original PDF. The basic idea is you setup a form on the page and replace the form fields with

iTextSharp - How to add a PDFPRow to a PDFPTable?

折月煮酒 提交于 2019-12-21 10:32:33
问题 I would like to add an array of PDFPCells to a PDFPRow, then add the PDFPRow to a PDFPTable, but I can't seem to find a method within PDFPTable for this. There is however a PDFPTable.AddCell Any ideas? 回答1: Check out the PdfPTable 's Rows.Add() method which takes a PdfPRow, which you can construct using an array of PdfPCells . Example: // ... PdfPTable table = new PdfPTable(5); PdfPCell[] cells = new PdfPCell[] { new PdfPCell(GetCell("c1")), new PdfPCell(GetCell("c2")), new PdfPCell(GetCell(

table width not set in iTextSharp when converting html to PDF

家住魔仙堡 提交于 2019-12-21 06:18:24
问题 I am trying to convert an html to pdf but the problem i face is that the html table tags width is not getting set correctly.. This is my html <table cellpadding='4' cellspacing='4' border='0' width='100%' style='width:100%'> <tr style='background-color:#000000'> <td colspan='2' align='center' valign='middle' width='100%'> <font face='Calibri' size='6' color='#FFFFFF'>Retail Natural Gas Deal Sheet</font> </td> </tr> <tr> <td colspan='2' width='100%'> </td> </tr> <tr> <td width='90%' style=