itextsharp

How to set only vertical line of a table in pdf using itext sharp?

早过忘川 提交于 2019-12-08 17:37:39
问题 I have a table with vertical and horizontal lines. But I do not want horizontal line.I want only Vertical lines.How can I set it. My expected o/p is My Table code PdfPTable table = new PdfPTable(5); table.TotalWidth = 510f;//table size table.LockedWidth = true; table.HorizontalAlignment = 0; table.SpacingBefore = 10f;//both are used to mention the space from heading table.DefaultCell.HorizontalAlignment = Element.ALIGN_LEFT; table.AddCell(new Phrase(new Phrase(" SL.NO", font1))); table

set new page in HTML using iTextSharp HTMLWorker (html to pdf)

女生的网名这么多〃 提交于 2019-12-08 16:49:13
问题 I using iTextSharp (V 5.4.2.0) to convert a html page to pdf. But I would like to be able to set a new page. I've tried this: <div style="page-break-before:always"> </div> and the tag <newpage /> But it doesn't work. What is the best way, to create a html page, including new page tags (or something) to be able to convert it correctly using iTextSharp? Kind regards, Matthijs 回答1: Use the iTextSharp XML Worker library and then use this HTML: <div style="page-break-before:always"> </div> 回答2: A

ItextSharp (Itext) - set custom font for paragraph

被刻印的时光 ゝ 提交于 2019-12-08 16:41:56
问题 I am trying to set custom font to Paragraph, but I can't make it work. I tried setting .Font= , but it only works size-wise, but it ignores font. Could you please assist? Paragraph T = new Paragraph(newTempLine); iTextSharp.text.Font contentFont = iTextSharp.text.FontFactory.GetFont("Webdings", 12, iTextSharp.text.Font.NORMAL); T.Font = contentFont; myDocument.Add(T); 回答1: Set it in the constructor: Font contentFont = FontFactory.GetFont(…); Paragraph para = new Paragraph(newTempLine,

Get list of supported fonts in ITextSharp

亡梦爱人 提交于 2019-12-08 16:16:43
问题 I'm working with ITextSharp for a project and am looking for a reasonable way to get a string list of different fonts it has available for use. I thought maybe I could just use reflection and loop over a class of available fonts, but there does not seem to be an easy way to do this. What I really want to do is provide a drop down of available/supported fonts for my users to select from Does anyone have any thoughts on how I might accomplish this? 回答1: This webpage has a great reference for

How to draw watermark text whose outline color is red and inner color is gray using iTextSharp

陌路散爱 提交于 2019-12-08 14:07:01
问题 How to draw watermark text whose outline color is red and inner color is gray using iTextSharp 回答1: If you are using a watermark I'm assuming that you are talking about a PdfStamper . If so, once you've got a raw PdfContentByte using either GetOverContent() or GetUnderContent() there's just a couple of properties that you need to set. PdfContentByte.SetLineWidth(single) - set the stroke thickness PdfContentByte.SetColorFill(BaseColor.GRAY) - set the fill color. You can also use any of the

iTextSharp - SelectPages Method Flattening Form

筅森魡賤 提交于 2019-12-08 13:26:50
问题 I've written an application to process a big load of PDF's by parsing data from a CSV file. The problem I've got is that I want to save the first page of the PDF and the first page only. When I use PdfReader's reader.SelectPages("1") it causes the form fields to be flattened. If I comment it out, everything works fine. Any ideas why this method would cause all form fields to be flattened? It exports the one page correctly however. Here's a small extract: PdfReader reader = new PdfReader

Trying to read callouts, how to get value of /IT from PdfDictionary in iTextSharp?

徘徊边缘 提交于 2019-12-08 13:15:17
问题 I want to read the callout text boxes in a PDF. I'm using iTextSharp to iterate through all the annotations as follows: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using iTextSharp.text; using iTextSharp.text.pdf; using System.IO; namespace PDFAnnotationReader { class Program { static void Main(string[] args) { StringBuilder text = new StringBuilder(); string fileName = @"C:\Users\J123\Desktop\xyz.pdf"; PdfReader

iTextSharp - draw rectangle - border width issue

☆樱花仙子☆ 提交于 2019-12-08 12:54:31
问题 here's a simple code: var w = Utilities.MillimetersToPoints(420); var h = Utilities.MillimetersToPoints(210); var doc1 = new Document(new Rectangle(w, h)); PdfWriter writer = PdfWriter.GetInstance(doc1, new FileStream("Doc1.pdf", FileMode.Create)); doc1.Open(); PdfContentByte cb = writer.DirectContent; var rect = new Rectangle(200, 200, 100, 100); and now, if I do the following: cb.Rectangle(200, 200, 100, 100); cb.Stroke(); then I see the rectangle. But I need to set its border width, so I

How can I add text to a Checkbox I create using iTextSharp?

一曲冷凌霜 提交于 2019-12-08 12:38:45
问题 Derived from Jeff S's methodology found here, I can add a "Checkbox" to a PDF page like so: PdfPTable tblFirstRow = new PdfPTable(5); tblFirstRow.SpacingBefore = 4f; tblFirstRow.HorizontalAlignment = Element.ALIGN_LEFT; . . . // code where textboxes are added has been elided for brevity PdfPCell cell204Submitted = new PdfPCell() { CellEvent = new DynamicCheckbox("checkbox204Submitted", "204 Submitted or on file") }; tblFirstRow.AddCell(cell204Submitted); doc.Add(tblFirstRow); The

Index was outside the bounds of the array while reading a .Pdf using iTextSharp

天大地大妈咪最大 提交于 2019-12-08 12:17:39
问题 Im using the Open Source Tool iTextSharp to read a .Pdf file in my Asp.Net MVC3 application which is coded in c#.Net. Below is my Code. filePath = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, Path.GetFileName(Infile.FileName)); if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } Infile.SaveAs(filePath); var pdfdoc = new iTextSharp.text.Document(); PdfReader reader2 = new PdfReader((string)filePath); string strText = string.Empty; for (int page = 1; page <=