itextsharp

How to add image background to pdf for every page?

可紊 提交于 2019-11-28 01:46:21
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(doc, new FileStream(filePath, FileMode.Create)); doc.Open(); doc.Add(backImg); ... creating a big

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

不想你离开。 提交于 2019-11-28 01:45:27
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. please advise me to do from above code or any other sample code in C# Bruno Lowagie This question is a

itext ColumnText ignores alignment

怎甘沉沦 提交于 2019-11-28 01:42:48
I'm trying to get some rows of text on the left side and some on the right side. For some reason iText seems to ignore the alignment entirely. Example: // create 200x100 column ct = new ColumnText(writer.DirectContent); ct.SetSimpleColumn(0, 0, 200, 100); ct.AddElement(new Paragraph("entry1")); ct.AddElement(new Paragraph("entry2")); ct.AddElement(new Paragraph("entry3")); ret = ct.Go(); ct.SetSimpleColumn(0, 0, 200, 100); ct.Alignment = Element.ALIGN_RIGHT; ct.AddElement(new Paragraph("entry4")); ct.AddElement(new Paragraph("entry5")); ct.AddElement(new Paragraph("entry6")); ret = ct.Go(); I

copy pdf form with PdfCopy not working in itextsharp 5.4.5.0

烈酒焚心 提交于 2019-11-28 01:23:54
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 PdfCopyFields it works fine. PdfCopyFields is deprecated in iTextSharp, but is PdfCopy working correctly?

Using iTextSharp to write data to PDF works great, but Acrobat Reader asks 'Do you want to save changes' when closing file

谁说胖子不能爱 提交于 2019-11-28 00:48:28
问题 I'm using iTextSharp 5.3.2.0 to add information to an existing PDF file that contains a W-2 form. Everything is working perfectly and the PDF file looks great when written into the browser's response stream; however, when the user is done looking at the PDF, he is asked "Do you want to save changes to 'W2.pdf' before closing?" every time he views the document from the web page. In trying to narrow the problem down, I've actually stripped out all of my modifications but the problem continues.

Set Metadata in iTextSharp

筅森魡賤 提交于 2019-11-28 00:43:41
问题 I am developing an application and i use the iTextSharp library. I am also reading the iText in action from Manning so i can get references. In Chapter 12 it has the following code to change the metadata in Java. PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); HashMap<String, String> info = reader.getInfo(); info.put("Title", "Hello World stamped"); info.put("Subject", "Hello World with changed metadata"); info.put("Keywords",

Generate and design PDF with iTextSharp or similar [closed]

徘徊边缘 提交于 2019-11-28 00:22:09
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 bad the support seems to be when it comes to styling/CSS so am I rethinking the whole situation. Which

iTextSharp XMLWorker parsing really slow

六月ゝ 毕业季﹏ 提交于 2019-11-28 00:18:10
I am parsing HTML string using iTextSharp XMLWorker in my WPF application using the below code: var css = ""; using (var htmlMS = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(html))) { //Create a stream to read our CSS using (var cssMS = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(css))) { //Get an instance of the generic XMLWorker var xmlWorker = XMLWorkerHelper.GetInstance(); //Parse our HTML using everything setup above xmlWorker.ParseXHtml(writer, doc, htmlMS, cssMS, System.Text.Encoding.UTF8, fontProv); } } The parsing works fine but it is really slow, it takes around 2

itextsharp trimming pdf document's pages

只愿长相守 提交于 2019-11-28 00:12:50
问题 I have a pdf document that has form fields that I'm filling out programatically with c#. Depending on three conditions, I need to trim (delete) some of the pages from that document. Is that possible to do? for condition 1: I need to keep pages 1-4 but delete pages 5 and 6 for condition 2: I need to keep pages 1-4 but delete 5 and keep 6 for condition 3: I need to keep pages 1-5 but delete 6 回答1: Instead of deleting pages in a document what you actually do is create a new document and only

Html to pdf some characters are missing (itextsharp)

孤人 提交于 2019-11-27 23:07:07
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); System.IO.StringWriter stringWrite = new StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite =