itextsharp

itextSharp - htmlString to pdf Unicode are missing

青春壹個敷衍的年華 提交于 2019-11-29 11:28:20
When I am trying to generate PDF from HTML, some Turkish characters like ĞÜŞİÖÇ ğüşıöç are missing in PDF, I see a space in place of these characters but i want to print that character. My code is: public virtual void print pdf(string html, int id) { String htmlText = html.ToString(); Document document = new Document(); string filePath = HostingEnvironment.MapPath("~/Content/Pdf/"); PdfWriter.GetInstance(document, new FileStream(filePath + "\\pdf-"+id+".pdf", FileMode.Create)); document.Open(); iTextSharp.text.html.simpleparser.HTMLWorker hw = new iTextSharp.text.html.simpleparser.HTMLWorker

What is the connection between LTV and document timestamps?

允我心安 提交于 2019-11-29 10:57:42
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. LTV enabled in Adobe Reader The last time I looked Adobe had not publicly defined what they mean by "LTV enabled" technically

iTextSharp for PDF - how add file attachments?

拥有回忆 提交于 2019-11-29 10:55:05
I am using iTextSharp to create a PDF document in C#. I would like to attach another file to the PDF. I'm having just loads of trouble trying to do so. The examples here show some annotations, which apparently attachments are. This is what I've tried: writer.AddAnnotation(its.pdf.PdfAnnotation.CreateFileAttachment(writer, new iTextSharp.text.Rectangle(100,100,100,100), "File Attachment", its.pdf.PdfFileSpecification.FileExtern(writer, "C:\\test.xml"))); Well, what happens is it does add an annotation on the PDF (appears as a little comment voice balloon), which i don't want. test.xml is shown

Rotating PDF 90 degrees using iTextSharp in C#

核能气质少年 提交于 2019-11-29 10:51:31
I am trying to use a PDF for stamping and need to rotate it 90 degrees to lay it on correctly? Anyone know how to do this? Can't seem to find it online. Bruno Lowagie The Rotate90Degrees example uses PdfReader to get an instance of the document then changes the /Rotate value in every page dictionary. If there is no such entry, a /Rotate entry with value 90 is added: final PdfReader reader = new PdfReader(source); final int pagesCount = reader.getNumberOfPages(); for (int n = 1; n <= pagesCount; n++) { final PdfDictionary page = reader.getPageN(n); final PdfNumber rotate = page.getAsNumber

Header, footer and large tables with iTextSharp

耗尽温柔 提交于 2019-11-29 10:38:09
I've added an header and a footer on my document by PdfPageEventHelper. The document has several "large" tables populated at runtime. I've tried to add those tables simply by "documen.Add(table)", but my header and my footer results overwritten. I've already tried both methods to add the tables (WriteSelectedRows and document.Add(myPdfPtable). Here is the code of the PageEventHelper: private class MyPageEventHandler : PdfPageEventHelper { public iTextSharp.text.Image ImageHeader { get; set; } public iTextSharp.text.Image ImageFooter { get; set; } public override void OnEndPage(PdfWriter writer

ITextSharp PdfCopy use examples

萝らか妹 提交于 2019-11-29 10:11:33
I am trying to use PdfSmartCopy from ItextSharp but I cannot find any relevant examples in c#. The ideea is that I have a pdf containing form fields and the fields add 700kb to the size of the pdf document. The original document without form fields was 100kb . Any other sugestions are welcome, especially o reduce the pdf size consistently. (I optimised the generated PDF with adobe acrobat, and it reduced it to 44kb . So there must be a glitch somewhere.) Is there any way to reduce the PDF size? Edit: FormFlatenning doesn't help. The pdf template file contains only text, lines and tables, no

PDF hostContainer callback

和自甴很熟 提交于 2019-11-29 09:41:47
Following this SO solution here to notify clients of a click event in a PDF document, how is it possible to notify the client when the PDF gets submitted by the client using this.myPDF.submitForm("localhost/Handler.ashx?r=2) function? The PDF File is created inside a user control then rendered into a HTML object: string container = ("<object data='/myfile.pdf' type='application/pdf'></object>"); The JS file attached to the PDF is done like this: var webClient = new WebClient(); string htmlContent = webClient.DownloadString(fileurl + "pdf_script.js"); PdfAction action = PdfAction.JavaScript

Get ONLY word count from PDF document

不羁的心 提交于 2019-11-29 08:43:05
I was hoping to get just the word count from a pdf document programmatically. I've looked at PDFSharp, but it's awefully bulky for what I want to do. I don't have access to the server, so I can't install acrobat to get to their api's or anything. I'd be willing to do it in iTextSharp or another tool. iTextSharp has a wonderful PdfTextExtractor object that will get you all of the text (assumming as @Rob A pointed out that its actually stored as text and not images or pure vector). Once you've got all of the text a simple RegEx will give you the word count. The code below should do it for you.

Could not load type 'iTextSharp.text.html.HtmlParser' from assembly 'itextsharp, Version=5.5.5.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca'

女生的网名这么多〃 提交于 2019-11-29 08:39:23
see this link converting html to pdf I got this version error in webconfig let some genius find and solve the qustion. My Model public class Customer { public int CustomerID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } } My Controller this is normal code public ActionResult Index() { List<Customer> customers = new List<Customer>(); for (int i = 1; i <= 10; i++) { Customer customer = new Customer { CustomerID = i, FirstName = string.Format("FirstName{0}", i.ToString()), LastName = string.Format("LastName{0}", i.ToString()) }; customers.Add(customer);

How to read table from PDF using itextsharp?

末鹿安然 提交于 2019-11-29 07:42:13
I am having an problem with reading a table from pdf file. It's a very simple pdf file with some text and a table. The tool i am using is itextsharp. I know there is no table concept in PDF. After some googling, someone said it might be possible to achieve that using itextsharp + custom ITextExtractionStrategy. But I have no idea how to start it. Can someone please give me some hints? or a small piece of sample code? Cheers gustavo.a.hansen This code is for reading a table content. all the values are enclosed by ()Tj, so we look for all the values, you can do anything then with the string