itextsharp

iTextSharp - Convert word doc/docx to pdf

无人久伴 提交于 2019-11-26 17:42:28
问题 I understand iTextSharp can be used for converting a document to pdf. But first we have to create a document from scratch using iTextSharp.text.Document and then adding elements to this document. What if I have an existing doc file, is it possible to convert this document to pdf using iTextSharp. Also, I want to use iTextSharp or any similar tool which can perform following on a doc file: manipulation of doc/docx/text files (like replacing some placeholders with DB values) as well as converts

iTextSharp - How to get the position of word on a page

╄→гoц情女王★ 提交于 2019-11-26 17:28:42
问题 I am using iTextSharp and the reader.GetPageContent method to pull the text out of a PDF. I need to find the rectangle/position for each word found in the document. Is there any way to get the rectangle/position of a word in a PDF using iTextSharp? 回答1: Yes there is. Check out the text.pdf.parser package, specifically LocationTextExtractionStrategy . Actually, that might not do the trick either. You'll probably want to write your own TextExtractionStrategy to feed into PdfTextExtractor:

How can I combine multiple PDF files excluding page breaks using iTextSharp?

蓝咒 提交于 2019-11-26 17:25:41
问题 I wonder if anyone has done this with iTextSharp, but I would like to combine multiple PDF files into one but leave the page breaks out. For example, I would like to create 4 PDF files containing 3 lines of text each, so I want the resulting file to have all 12 lines in 1 page. Is this possible? 回答1: As the OP also tagged this question with [iText] and I am more at home with Java than .Net, here an answer for iText/Java. It should be easy to translate to iTextSharp/C#. The original question I

How to return PDF to browser in MVC?

和自甴很熟 提交于 2019-11-26 17:16:49
I have this demo code for iTextSharp Document document = new Document(); try { PdfWriter.GetInstance(document, new FileStream("Chap0101.pdf", FileMode.Create)); document.Open(); document.Add(new Paragraph("Hello World")); } catch (DocumentException de) { Console.Error.WriteLine(de.Message); } catch (IOException ioe) { Console.Error.WriteLine(ioe.Message); } document.Close(); How do I get the controller to return the pdf document to the browser? EDIT: Running this code does open Acrobat but I get an error message "The file is damaged and could not be repaired" public FileStreamResult pdf() {

What are the extra characters in the font name of my PDF?

房东的猫 提交于 2019-11-26 17:11:48
问题 while extracting font name from pdf i will get some junk characters followed by plus sign and then the font name with font style. i want to remove the junk characters.only for few pdf i get that junk characters. example:MMLPEO+RemingtonNoiseless string curFont = renderInfo.GetFont().PostscriptFontName; 回答1: The "junk" characters indicate that the font isn't embedded completely. You'll find names such as ABC123+RemingtonNoiseless, XYZ456+RemingtonNoiseless, etc... meaning that there may be

itext positioning text absolutely

谁说我不能喝 提交于 2019-11-26 16:58:17
问题 In itext I have a chunk/phrase/paragraph (I dont mind which) and I want to position some where else on the page e.g. at 300 x 200. How would I do this? 回答1: In the end I wrote my own method to do it. private void PlaceChunck(String text, int x, int y) { PdfContentByte cb = writer.DirectContent; BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.SaveState(); cb.BeginText(); cb.MoveText(x, y); cb.SetFontAndSize(bf, 12); cb.ShowText(text); cb

iTextSharp international text

流过昼夜 提交于 2019-11-26 16:53:39
问题 I have a table in asp.net page,and trying to export it as a PDF file,I have couple of international characters that are not shown in generated PDF file,any suggestions, Thanks in advance 回答1: The key for proper display of alternate characters sets (Russian, Chinese, Japanese, etc.) is to use IDENTITY_H encoding when creating the BaseFont. Dim bfR As iTextSharp.text.pdf.BaseFont bfR = iTextSharp.text.pdf.BaseFont.CreateFont("MyFavoriteFont.ttf", iTextSharp.text.pdf.BaseFont.IDENTITY_H,

Using LocationTextExtractionStrategy in itextSharp for text coordinate

喜夏-厌秋 提交于 2019-11-26 16:48:49
My goal is to retrieve data from PDF which may be in table structure to an excel file. using LocationTextExtractionStrategy with iTextSharp we can get the string data in plain text with page content in left to right manner. How can I move forward such that during PdfTextExtractor.GetTextFromPage(reader, i, new LocationTextExtractionStrategy()) I could make the text retain its coordinate in the resulting string. As for instance if the first line in the pdf has text aligned to right, then the resulting string must be containing trailing space or spaces keeping the content right aligned. Please

Removing Watermark from a PDF using iTextSharp

强颜欢笑 提交于 2019-11-26 16:29:47
问题 I added a watermark on pdf using Pdfstamper. Here is the code: for (int pageIndex = 1; pageIndex <= pageCount; pageIndex++) { iTextSharp.text.Rectangle pageRectangle = reader.GetPageSizeWithRotation(pageIndex); PdfContentByte pdfData = stamper.GetUnderContent(pageIndex); pdfData.SetFontAndSize(BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED), watermarkFontSize); PdfGState graphicsState = new PdfGState(); graphicsState.FillOpacity = watermarkFontOpacity; pdfData

put page number when create PDF with iTextSharp

时光怂恿深爱的人放手 提交于 2019-11-26 16:29:41
问题 I'm working with ASP MVC and i use iTextSharp to generate PDF's in my application. But now i have a problem: I printing lists and when exist more than one page, i want to show the page number (ex.: Page 1 to 4 ). I found some examples, but i think it is more complexes than i need to do (like exameple). EDIT: I found this example 2. I can count number of pages, but i cant print the number in pages. What i did: public ActionResult downloadListaISCC(DateTime? DataFimFiltro) { //Code to generate