itextsharp

Page X of Y issue

那年仲夏 提交于 2019-11-26 13:29:00
I tried 3 different ways of displaying Page numbers, OnCloseDocument content is not displaying in the page, none of them worked. My Intention is displaying Page numbers like this 1 of 10 2 0f 10 .............. ............ 10 of 10 on each page I know how to display 1 2 3 4 .... 10 but don`t know how to display total page number I`m using OnCloseDocument to display No.of pages count,but the content in it is not displaying. public class MyPdfPageEventHelpPageNo : iTextSharp.text.pdf.PdfPageEventHelper { protected PdfTemplate total; protected BaseFont helv; private bool settingFont = false;

Render PDF in iTextSharp from HTML with CSS

懵懂的女人 提交于 2019-11-26 13:17:14
问题 Any idea how to render a PDF using iTextSharp so that it renders the page using CSS. The css can either be embedded in the HTML or passed in separately, I don't really care, just want it to work. Specific code examples would be greatly appreciated. Also, I would really like to stick with iTextSharp, though if you do have suggestions for something else, it's got to be free, open source, and have a license that permits using it in commercial software. 回答1: It's not possible right now but

Merging multiple PDFs using iTextSharp in c#.net

谁都会走 提交于 2019-11-26 12:59:31
Well i'm trying to merge multiple PDFs in to one. I gives no errors while compiling. I tried to merge the docs first but that went wrong because I'm working with tables. This is the asp.net code-behind if (Button.Equals("PreviewWord")) { String eventTemplate = Server.MapPath("/ERAS/Badges/Template/EventTemp" + EventName + ".doc"); String SinglePreview = Server.MapPath("/ERAS/Badges/Template/PreviewSingle" + EventName + ".doc"); String PDFPreview = Server.MapPath("/ERAS/Badges/Template/PDFPreviewSingle" + EventName + ".pdf"); String previewPDFs = Server.MapPath("/ERAS/Badges/Template

Convert Pdf file pages to Images with itextsharp

十年热恋 提交于 2019-11-26 12:46:00
问题 I want to convert Pdf pages in Images using ItextSharp lib. Have any idea how to convert each page in image file 回答1: iText/iTextSharp can generate and/or modify existing PDFs but they do not perform any rendering which is what you are looking for. I would recommend checking out Ghostscript or some other library that knows how to actually render a PDF. 回答2: you can use ImageMagick convert pdf to image convert -density 300 "d:\1.pdf" -scale @1500000 "d:\a.jpg" and split pdf can use itextsharp

iTextSharp Creating a Footer Page # of #

百般思念 提交于 2019-11-26 12:25:00
问题 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

Generate a PDF that automatically prints

岁酱吖の 提交于 2019-11-26 12:24:35
I have a ASP.NET Web application that generates a PDF. I am using iTextSharp. What happens is that you click a button and it downloads. My employer want to be able to click the button and have it open with the print dialog. yms Method 1: Using embedded javascript inside your PDF files You can try creating an iText PDFAction object with a javascript call this.print(false) (you can use new PdfAction(PdfAction.PRINTDIALOG) for this), and associate it with the OpenAction event of your pdf file. The code in iText Java should look like this: PdfWriter writer = PdfWriter.getInstance(document, new

How To Remove Whitespace on Merge

人盡茶涼 提交于 2019-11-26 11:55:29
I have some code that takes 3 different PDF byte arrays and merges them. This code works great. The issue (some people) are having is that each PDF is considered to be a full page (if printed) even if there is only say 4 inches of content on it, thus leaving 7 inches of white space vertically. Then the middle document gets put in and may or may not have vertical white space at the end of it. Then the footer gets put on its own page as well. Here is the code: byte[] Bytes = rv.LocalReport.Render("PDF", null, out MimeType, out Encoding, out Extension, out StreamIDs, out Warnings); List<byte[]>

How to merge multiple pdf files (generated in run time)?

风流意气都作罢 提交于 2019-11-26 11:52:13
How to merge multiple pdf files (generated on run time) through ItextSharp then printing them. I found the following link but that method requires the pdf names considering that the pdf files stored and this is not my case . I have multiple reports i'll convert them to pdf files through this method : private void AddReportToResponse(LocalReport followsReport) { string mimeType; string encoding; string extension; string[] streams = new string[100]; Warning[] warnings = new Warning[100]; byte[] pdfStream = followsReport.Render("PDF", "", out mimeType, out encoding, out extension, out streams,

How to continue field output on a second page?

我的未来我决定 提交于 2019-11-26 11:39:59
问题 I have generated a PDF from a template. The PDF has a field in the middle of it that is of variable length. I am trying to work it so that if the field\'s content overflows, then the program will use a second instance template as a second page and continue in the same field there. Is this possible? 回答1: This will only work if you flatten the form. I've written a proof of concept where I have a PDF form src that has a field named "body" : public void manipulatePdf(String src, String dest)

ITextSharp HTML to PDF?

♀尐吖头ヾ 提交于 2019-11-26 11:35:26
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