itextsharp

ITextSharp HTML to PDF?

倖福魔咒の 提交于 2019-11-26 11:35:20
I'd like to know if ITextSharp has the capability of converting HTML to PDF. Everything I will convert will just be plain text but unfortunately there is very little to no documentation on ITextSharp so I can't determine if that will be a viable solution for me. If it can't do it, can someone point me to some good, free .net libraries that can take a simple plain text HTML document and convert it to a pdf? tia. Jonathan I came across the same question a few weeks ago and this is the result from what I found. This method does a quick dump of HTML to a PDF. The document will most likely need

Highlight words in a pdf using itextsharp, not displaying highlighted word in browser

让人想犯罪 __ 提交于 2019-11-26 11:33:24
问题 Highlighted words are not displaying in browser using itextsharp. Adobe Browser CODE List<iTextSharp.text.Rectangle> MatchesFound = strategy.GetTextLocations(splitText[i].Trim(), StringComparison.CurrentCultureIgnoreCase); foreach (Rectangle rect in MatchesFound) { float[] quad = { rect.Left - 3.0f, rect.Bottom, rect.Right, rect.Bottom, rect.Left - 3.0f, rect.Top + 1.0f, rect.Right, rect.Top + 1.0f }; //Create our hightlight PdfAnnotation highlight = PdfAnnotation.CreateMarkup(stamper.Writer,

Extract image from PDF using itextsharp

别说谁变了你拦得住时间么 提交于 2019-11-26 11:23:40
问题 I am trying to extract all the images from a pdf using itextsharp but can\'t seem to overcome this one hurdle. The error occures on the line System.Drawing.Image ImgPDF = System.Drawing.Image.FromStream(MS); giving an error of \"Parameter is not valid\". I think it works when the image is a bitmap but not of any other format. I have this following code - sorry for the length; private void Form1_Load(object sender, EventArgs e) { FileStream fs = File.OpenRead(@\"reader.pdf\"); byte[] data =

Extract images using iTextSharp

拈花ヽ惹草 提交于 2019-11-26 10:33:15
I have been using this code with great success to pull out the first image found in each page of a PDF. However, it is now not working with some new PDFs for an uknown reason. I have used other tools (Datalogics, etc) that do pull out the images fine with these new PDFs. However, I do not want to buy Datalogics or any tool if I can use iTextSharp. Can anybody tell me why this code is not finding the images in the PDF? Knowns: my PDFs only have 1 image per page and nothing else. using iTextSharp.text; using iTextSharp.text.pdf; ... public static void ExtractImagesFromPDF(string sourcePdf,

How can I extract subscript / superscript properly from a PDF using iTextSharp?

随声附和 提交于 2019-11-26 10:03:45
问题 iTextSharp works well extracting plain text from PDF documents, but I\'m having trouble with subscript/superscript text, common in technical documents. TextChunk.SameLine() requires two chunks to have identical vertical positioning to be \"on\" the same line, which isn\'t the case for superscript or subscript text. For example, on page 11 of this document, under \"COMBUSTION EFFICIENCY\": http://www.mass.gov/courts/docs/lawlib/300-399cmr/310cmr7.pdf Expected text: monoxide (CO) in flue gas in

How can I add an image to all pages of my PDF?

限于喜欢 提交于 2019-11-26 10:03:14
问题 I have been trying to add an image to all pages using itextsharp. The image needs to be OVER all content of every page. I have used the following code below all the other doc.add() Document doc = new Document(iTextSharp.text.PageSize.A4, 10, 10, 30, 1); PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(Server.MapPath(\"~/pdf/\" + fname), FileMode.Create)); doc.Open(); Image image = Image.GetInstance(Server.MapPath(\"~/images/draft.png\")); image.SetAbsolutePosition(12, 300); writer

How to reduce memory consumption of PdfPTable with many cells

最后都变了- 提交于 2019-11-26 10:00:59
问题 I\'m creating a PDF using ITextSharp which is composed of a single PdfTable. Unfortunately for a particular data set, I\'m getting an Out of memory Exception due to the large number PdfPCells that are created (I\'ve profiled the memory usage - I\'ve got nearly 1/2 a million cells !) Is there any way to reduce the memory usage in such a case? I\'ve tried flushing at various points (after each row) and full compression The PdfWriter is based on a FileStream Code looks a pretty much like this:

Can itextsharp.xmlworker render embedded images?

本秂侑毒 提交于 2019-11-26 09:36:55
问题 I would like to create dynamic PDF documents using HTML and dynamic images. My code works fine with standard HTML and full paths for the images, but when I try to embed the image inline in the document I get the error Exception Details: System.IO.IOException: The document has no pages. Is there a way to embed the images without an HTTP call per image? I don\'t want that because I think it will cause scalability issues and the images are sensitive. Here is my code that gives the IOException:

how to highlight a text or word in a pdf file using iTextsharp?

吃可爱长大的小学妹 提交于 2019-11-26 08:26:44
问题 I need to search a word in a existing pdf file and i want to highlight the text or word and save the pdf file I have an idea using PdfAnnotation.CreateMarkup we could find the position of the text and we can add bgcolor to it...but i dont know how to implement it :( Please help me out 回答1: This is one of those "sounds easy but is actually really complicated" things. See Mark's posts here and here. Ultimately you'll probably be pointed to LocationTextExtractionStrategy. Good luck! If you

Itextsharp: Adjust 2 elements on exactly one page

本小妞迷上赌 提交于 2019-11-26 07:49:33
问题 So, I\'m having this problem using C# (.NET 4.0 + WinForms) and iTextSharp 5.1.2. I have some scanned images stored on a DB and need to build on the fly PDF with those images. Some files have just one page and other ones hundreds. That is working just fine using: foreach (var page in pages) { Image pageImage = Image.GetInstance(page.Image); pageImage.ScaleToFit(document.PageSize.Width,document.PageSize.Height); pageImage.Alignment = Image.ALIGN_TOP | Image.ALIGN_CENTER; document.Add(pageImage