itextsharp

Itextsharp text extraction

廉价感情. 提交于 2019-11-27 01:21:19
问题 I'm using itextsharp on vb.net to get the text content from a pdf file. The solution works fine for some files but not for other even quite simple ones. The problem is that the token stringvalue is set to null (a set of empty square boxes) token = New iTextSharp.text.pdf.PRTokeniser(pageBytes) While token.NextToken() tknType = token.TokenType() tknValue = token.StringValue I can meassure the length of the content but I cannot get the actual string content. I realized that this happens

Can itextsharp.xmlworker render embedded images?

放肆的年华 提交于 2019-11-27 01:12:59
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: public ActionResult MakePdf() { string html = @"<?xml version=""1.0"" encoding=""UTF-8""?> <!DOCTYPE html

iTextSharp Creating a Footer Page # of #

送分小仙女□ 提交于 2019-11-27 00:46:56
I'm trying to create a footer on each of the pages in a PDF document using iTextSharp in the format Page # of # following the tutorial on the iText pages and the book. Though I keep getting an exception on cb.SetFontAndSize(helv, 12); - object reference not set to an object. Can anyone see the issue? Code is below. Thanks, Rob public class MyPdfPageEventHelpPageNo : iTextSharp.text.pdf.PdfPageEventHelper { protected PdfTemplate total; protected BaseFont helv; private bool settingFont = false; public override void OnOpenDocument(PdfWriter writer, Document document) { total = writer

How to Set Height of PdfPTable in iTextSharp

≯℡__Kan透↙ 提交于 2019-11-26 23:35:30
问题 i downloaded the last version of iTextSharp dll. I generated a PdfPTable object and i have to set it's height. Despite to set width of PdfPTable, im not able to set height of it. Some authors suggest to use 'setFixedHeight' method. But the last version of iTextSharp.dll has not method as 'setFixedHeight'. It's version is 5.5.2. How can i do it? 回答1: Setting a table's height doesn't make sense once you start thinking about it. Or, it makes sense but leaves many questions unanswered or

Set inherit Zoom(action property) to bookmark in the pdf file

谁说我不能喝 提交于 2019-11-26 23:33:55
问题 I have found the number of bookmarks in the pdf file using the following code. var reader = new PdfReader(System.Windows.Forms.Application.StartupPath + "\\zoom.pdf", new System.Text.ASCIIEncoding().GetBytes("")); IList<Dictionary<string, object>> bookmarks = SimpleBookmark.GetBookmark(reader); foreach (Dictionary<string, object> bk in bookmarks) { string bjj = bk.Values.ToArray().GetValue(0).ToString(); } But i need to set the inherit zoom action property for book bookmark in the pdf file.

copy pdf form with PdfCopy not working in itextsharp 5.4.5.0

谁说胖子不能爱 提交于 2019-11-26 23:31:27
问题 In the release notes of iText 5.4.4 it says: From now on you can now merge forms and preserve the tagged PDF structure when using the addDocument() method in PdfCopy. At the same time, we've deprecated PdfCopyFields.* I try to merge multiple pdf documents into one pdf document. If one of these documents is a pdf form with acroFields, those fields will be invisible in the output document. This is the case when I use the addDocument() method in PdfCopy. When I use the addDocument() method in

Generate and design PDF with iTextSharp or similar [closed]

醉酒当歌 提交于 2019-11-26 23:24:46
问题 tl;dr : Basically I'm just wondering what is the best/easiest way to design a PDF document? Is it remotely legit to actually design a whole PDF document with iTextSharp with code(i.e not loading external files)? I want the final result to look similar to a webpage with various colours, borders, images and everything. Or do you have to rely on other documents like .doc, .html files to achieve a good design? Originally I thought that I would use HTML markup to generate a PDF, however seeing how

Html to pdf some characters are missing (itextsharp)

主宰稳场 提交于 2019-11-26 23:16:46
问题 I want to export gridview to pdf by using the itextsharp library. The problem is that some turkish characters such as İ,ı,Ş,ş etc... are missing in the pdf document. The code used to export the pdf is: protected void LinkButtonPdf_Click(object sender, EventArgs e) { Response.ContentType = "application/pdf"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.AddHeader("content-disposition", "attachment;filename=FileName.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache

Invalidpdfexception pdf header signature not found

拥有回忆 提交于 2019-11-26 22:18:24
问题 I have some code that reads pdf files. The code fails at the line : iTextSharp.text.pdf.PRTokeniser.CheckPdfHeader() at iTextSharp.text.pdf.PdfReader.ReadPdf() I know from other entries that this issue is coming from some invalid formatting in the pdf. However I'm not in a position to tell my users to redo their pdfs. Is there some other way around this issue, that can allow reading of the pdf despite this problem? 回答1: If a file doesn't start with %PDF- then there's nothing to fix: the file

How to add image background to pdf for every page?

拥有回忆 提交于 2019-11-26 22:02:25
问题 I'm trying to set a background to a pdf and managed to set it with an image my pdf has a big table so the pages are added automatically not with the Document.NewPage() method so the image background is set only on the first page. This is the code that adds the background: Image backImg = Image.GetInstance(@"D:\websites\DIS\bugs\130208\A4.png"); backImg.SetAbsolutePosition(0, 0); backImg.Alignment = Image.UNDERLYING; var doc = new Document(pageSize); PdfWriter pdfWriter = PdfWriter.GetInstance