itextsharp

How do you underline text with dashedline in ITEXT PDF

老子叫甜甜 提交于 2019-11-28 10:07:24
问题 I have underlined "Some text" by var par = new Paragraph(); par.Add(new Chunk("Some text", CreateFont(12, Font.UNDERLINE))); document.Add(par); It is possible underline just "Some text" with dashed line (not the paragraph)? Thanks 回答1: This answer tells you how to do it but unfortunately doesn't provide any code so I've provided it below. To the best on my knowledge there isn't a direct way to achieve this in iTextSharp by just setting a simple property. Instead, you need to use a PageEvent

How do I insert a hyperlink to another page with iTextSharp in an existing PDF?

╄→尐↘猪︶ㄣ 提交于 2019-11-28 10:05:19
问题 I would like to add a link to an existing pdf that jumps to a coordinate on another page. I am able to add a rectangle using this code: PdfContentByte overContent = stamper.GetOverContent(1); iTextSharp.text.Rectangle rectangle = new Rectangle(10,10,100,100,0); rectangle.BackgroundColor = BaseColor.BLUE; overContent.Rectangle(rectangle); stamper.Close(); How can I do similar to create a link that is clickable? Thanks. 回答1: This is explained in chapter 7 of the book "iText in Action - Second

iTextSharp is missing HeaderFooter class

与世无争的帅哥 提交于 2019-11-28 09:58:05
This is weird, I am currently using iTextSharp and I want to add a Header & Footer to my PDFs. In all the examples they simply create a new HeaderFooter() object. However, I have iTextSharp libraries all imported but the HeaderFooter is not defined. I've used Reflector to see if I can find out whereabouts the class is and its missing?! Does anyone know what has happened to this class? CResults Most of the examples refer to an earlier version of iTextSharp. For version 5+ of iTextSharp (which I assume you are using) the HeaderFooter property/object has been removed. See http://itextpdf.com

Highlighting text ( colors ) of existing PDF using iTextsharp using C#

笑着哭i 提交于 2019-11-28 09:29:48
I would like know whether we can highlight text (colors) of already created PDF using itextsharp ? I see examples like creating a new PDF, while doing so we can apply colors. I am looking for where I can get chunks of text from PDF and apply colors and save it. Here is the thing I am trying to accomplish, read a PDF file, parse text and highlight text based on business rules. Any third party dll suggestion also works, as a first step I am looking in to opensource iTextsharp library . Chris Haas Yes you can highlight text but you will have to work for it unfortunately. What looks like a

Need help with creating PDF from HTML using itextsharp

落爺英雄遲暮 提交于 2019-11-28 09:29:00
I'm trying to crate a PDF out of a HTML page. The CMS I'm using is EPiServer. This is my code so far: protected void Button1_Click(object sender, EventArgs e) { naaflib.pdfDocument(CurrentPage); } public static void pdfDocument(PageData pd) { //Extract data from Page (pd). string intro = pd["MainIntro"].ToString(); // Attribute string mainBody = pd["MainBody"].ToString(); // Attribute // makae ready HttpContext HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType = "application/pdf"; // Create PDF document Document pdfDocument = new Document(PageSize.A4, 80, 50, 30,

Unicode symbols in iTextSharp

对着背影说爱祢 提交于 2019-11-28 09:09:10
问题 I'm trying to use a Unicode symbol in my PDF file with iTextSharp. Dim base As BaseFont = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\WINGDING.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED) Dim wd As Font = New Font(base, 12, Font.NORMAL, BaseColor.BLACK) phrase = New Phrase("q", wd) It's the Q.Key in Wingding. But in the PDF file it's not working. It just prints nothing where the Char should be. Where is the error? 回答1: I just did the following and it worked exactly as it should. The Wingdings

iTextSharp is producing a corrupt PDF with Response

耗尽温柔 提交于 2019-11-28 08:28:11
问题 i tryed both, but still not working iTextSharp + FileStream = Corrupt PDF file iTextSharp is producing a corrupt PDF using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream()) { //abre o documento para poder editar document.Open(); //Adiciona os campos de assinatura document.Add(Assinatura()); //fecha o documento ao finalizar a edição document.Close(); //Prepara o download byte[] bytes = memoryStream.ToArray(); memoryStream.Close(); Response.Clear(); Response.ContentType =

Bold a single word within a sentence with iTextSharp

点点圈 提交于 2019-11-28 08:16:36
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.WidthPercentage = 100; width = new float[1]; width[0] = 0.7F; pdftb4.SetWidths(width); pdfcel4 = new

Edit DirectContent of iTextSharp PdfSmartCopy class

折月煮酒 提交于 2019-11-28 08:10:41
问题 At my work sometimes I have to merge from few to few hundreds pdf files. All the time I've been using Writer and ImportedPages classes. But when I have merged all files into one, file size becomes enormous, sum of all merged files sizes, because fonts being attached to every page, and not reused (fonts are embedded to every page, not whole document). Not very long time ago I found out about PdfSmartCopy class, which reuses embedded fonts and images. And here the problem kicks in. Very often,

What is the connection between LTV and document timestamps?

我的梦境 提交于 2019-11-28 08:00:06
问题 I am confused about LTV in iText. I have read the paper, discussions but there is one thing still unclear. What is the connection between LTV and document timestamps? Or more precisely, how do I make pdf LTV enabled without using timestamps? One thing I know for sure, to make an LTV enabled document, I do not need timestamps. I tried signing a document with a digital certificate in acrobat and when opened it says the document is LTV enabled, I did not use any timestamp. 回答1: LTV enabled in