itextsharp

iTextSharp trims leading space and causes misalignment of columns

梦想的初衷 提交于 2019-12-25 17:52:48
问题 When moving from the versions 4.1.2 => 5.1.3 of iTextSharp I have come across a bug that happens when generating a PDF from text. The problem is that when the first character of a line has a leading spaces then that leading space gets truncated. This is a problem with a right justified columns. Example: (dashes= spaces) Input : ------Header --------------1 --------------2 0123456789 Output : -----Header -------------1 -------------2 0123456789 ~~~Notice improper alignment because this column

iTextSharp trims leading space and causes misalignment of columns

北慕城南 提交于 2019-12-25 17:52:24
问题 When moving from the versions 4.1.2 => 5.1.3 of iTextSharp I have come across a bug that happens when generating a PDF from text. The problem is that when the first character of a line has a leading spaces then that leading space gets truncated. This is a problem with a right justified columns. Example: (dashes= spaces) Input : ------Header --------------1 --------------2 0123456789 Output : -----Header -------------1 -------------2 0123456789 ~~~Notice improper alignment because this column

How to get ordered list into pdf using itext?

半世苍凉 提交于 2019-12-25 17:03:14
问题 I have to get an ordered list into pdf.The data stored is in html format.When exporting to pdf using itextsharp,the ol-li tags should be replaced by an ordered list. 回答1: You'll want to use iTextSharp's iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList() method. Below is a full working sample WinForms app targeting iTextSharp 5.1.1.0 that does what you're looking for. See the inline comments for what's going on. using System; using System.Collections.Generic; using System.Linq; using

Reading PDF file?

与世无争的帅哥 提交于 2019-12-25 16:57:30
问题 This will be my first time reading a PDF. I was searching around and found so options to do that with C# and choose to use iTextSharp. So far I've done just the basic like reading the file and getting the content without issues. PdfReader reader = new PdfReader(iPDF.Text); for (int x = 2; x <= reader.NumberOfPages; x++) { iResult.Text = Encoding.UTF8.GetString(reader.GetPageContent(x)); break; } As you can see it is a very very basic code just to read the 2nd page of the PDF into a text file

Resizing a form field in iTextSharp

我们两清 提交于 2019-12-25 16:43:49
问题 I am adding a checkbox field to a table cell and it expands across the whole cell. Is there a way I can control the size of the element so it does not take up the whole cell? I found someone else asking the same question but it was from 2006 so I am hoping something is now available. One idea I had while writing this was to nest a new table in the table cell and try do some cell alignment trickery to get the checkbox center aligned but I have already had a shower today and do not want to take

Resizing a form field in iTextSharp

心已入冬 提交于 2019-12-25 16:43:25
问题 I am adding a checkbox field to a table cell and it expands across the whole cell. Is there a way I can control the size of the element so it does not take up the whole cell? I found someone else asking the same question but it was from 2006 so I am hoping something is now available. One idea I had while writing this was to nest a new table in the table cell and try do some cell alignment trickery to get the checkbox center aligned but I have already had a shower today and do not want to take

How to set line width on template clipping

邮差的信 提交于 2019-12-25 12:40:54
问题 I have some PdfTemplate and I want to clip its shape to some path. I know how to do this, but the clipping line is always the same (probably 1 px) and I want to be able to change it. Is there any way to do this? Half-measures, like resizing template will not do the trick. Piece of code: PdfTemplate template = contentByte.CreateTemplate(100, 200); template.MoveTo(0, 0); template.LineTo(50, 50); template.LineTo(50, 0); template.LineTo(0, 50); template.SetLineWidth(5); template.Clip(); Image img

watermark (text or image) in existing pdf

≯℡__Kan透↙ 提交于 2019-12-25 09:58:19
问题 How do I add a watermark (text or image) in an existing pdf in c#? I want the watermark displayed for all pages of the pdf. I tried with itextsharp but the watermark is displaying in only last page of the pdf. public void CreateTemplate(string watermarkText, string targetFileName) { var document = new Document(); var pdfWriter = PdfWriter.GetInstance(document, new FileStream(targetFileName, FileMode.Create)); var font = new iTextSharp.text.Font(iTextSharp.text.Font.HELVETICA, 60, iTextSharp

watermark (text or image) in existing pdf

杀马特。学长 韩版系。学妹 提交于 2019-12-25 09:57:44
问题 How do I add a watermark (text or image) in an existing pdf in c#? I want the watermark displayed for all pages of the pdf. I tried with itextsharp but the watermark is displaying in only last page of the pdf. public void CreateTemplate(string watermarkText, string targetFileName) { var document = new Document(); var pdfWriter = PdfWriter.GetInstance(document, new FileStream(targetFileName, FileMode.Create)); var font = new iTextSharp.text.Font(iTextSharp.text.Font.HELVETICA, 60, iTextSharp

XPath not working correctly with XFA

隐身守侯 提交于 2019-12-25 09:47:10
问题 I have a dynamic PDF form that has a DropDownList. I'm using iTextSharp to try and modify the values inside the PDF before sending it out to the client. Here's what I'm trying, as per an answer in this question: PdfReader reader = new PdfReader(myPdfPath); XmlDocument xdoc = reader.AcroFields.Xfa.DomDocument; XmlNode dropdown = xdoc.SelectSingleNode("/*/template/subform[@name='form1']/subform[@name='form2']/field[@name='DropDownList1']"); But no matter what XPath expression I use (ex: /