itextsharp

How to Add Page number in Footer in PDF by Itextsharp

久未见 提交于 2019-11-27 21:32:09
I am using iTextSharp DLL in ASP.NET code. I am fetching a data into dataset and Add the dataset into PDF table. If my dataset have more 100 rows then 100 rows will be added into PDF table and 3 or 4 page will be created in PDF file. How can I add the footer in each page? You need to inherit from PdfPageEventHelper class and override the methods shown in the code snippet below: Document doc = new Document(PageSize.A4.Rotate()); using (MemoryStream ms = new MemoryStream()) { PdfWriter writer = PdfWriter.GetInstance(doc, ms); PageEventHelper pageEventHelper = new PageEventHelper(); writer

Merging PDFs with ITextSharp

感情迁移 提交于 2019-11-27 21:17:44
What is the optimum way to merge 2 PDF files with ITextSharp in C#? I'm using ASP.NET/.NET3.5. tommy public static void Merge(List<String> InFiles, String OutFile) { using (FileStream stream = new FileStream(OutFile, FileMode.Create)) using (Document doc = new Document()) using (PdfCopy pdf = new PdfCopy(doc, stream)) { doc.Open(); PdfReader reader = null; PdfImportedPage page = null; //fixed typo InFiles.ForEach(file => { reader = new PdfReader(file); for (int i = 0; i < reader.NumberOfPages; i++) { page = pdf.GetImportedPage(reader, i + 1); pdf.AddPage(page); } pdf.FreeReader(reader); reader

Extract text and text rectangle coordinates from a Pdf file using itextsharp

烈酒焚心 提交于 2019-11-27 20:54:58
I'm trying to get all words and their location coordinates from a PDF file. I've succeeded using the Acrobat API on .NET . Now, I'm trying to get the same result using a free API, such as iTextSharp (the .NET version). I can get the text (line by line) with PRTokeniser , but I have no idea of how to get the coordinates of the line, let alone of each word. My account is too new reply to Mark Storer's answer. I wasn't able to directly use the LocationTextExtracationStrategy (I think I must be doing something wrong). When I used the LocationTextExtracationStrategy I was able to get the text but I

How do I embed fonts in an existing PDF?

此生再无相见时 提交于 2019-11-27 20:27:54
Background: I have PDF's I am programmatically generating. I need to be able to send the PDF directly to a printer from the server (not through an intermediate application). At the moment I can do all of the above (generate PDF, send to printer), but because the fonts aren't embedded in the PDF the printer is doing font substitution. Why the fonts aren't embedded when generated: I am creating PDF's using SQL Reporting Services 2008. There is a known issue with SQL Reporting Services in that it will not embed fonts (unless a series of requirements are met - http://technet.microsoft.com/en-us

How to calculate the correct image size in out pdf using itextsharp?

牧云@^-^@ 提交于 2019-11-27 17:49:47
问题 I' am trying to add an image to a pdf using itextsharp, regardless of the image size it always appears to be mapped to a different greater size inside the pdf ? The image I add is 624x500 pixel (DPI:72): alt text http://www.freeimagehosting.net/uploads/727711dc70.png And here is a screen of the output pdf: alt text http://www.freeimagehosting.net/uploads/313d49044d.png And here is how I created the document: Document document = new Document(); System.IO.MemoryStream stream = new MemoryStream(

creating a pdf from a template in itextsharp and outputting as content disposition.

守給你的承諾、 提交于 2019-11-27 16:30:22
问题 I would like to open an existing pdf, add some text and then output as content disposition using itext sharp. I have the following code. Where it falls down it is that i want to output as memory stream but need to filestream to open the original file. Here's what i have. Obviously defining PdfWriter twice won't work. public static void Create(string path) { var Response = HttpContext.Current.Response; Response.Clear(); Response.ContentType = "application/pdf"; System.IO.MemoryStream m = new

itextsharp: How to generate a report with dynamic header in PDF using itextsharp?

假如想象 提交于 2019-11-27 16:28:59
I'm generating a PDF report with itextsharp, the header of the report has the information of the Customer, In the body of the report contains a list of customer transactions. My doubt is: How to generate a header dynamically for each client? I need an example to generate a header dynamically to the report. Every new page Header need to have the data that client when changing client header should contain information on the new client. Your question risks down-voting or at least comments in the sense of "What have you tried?" However, I've written you a small example in Java which you can easily

Returning iTextSharp PDF as memorystream causes StreamNotSupported

匆匆过客 提交于 2019-11-27 16:20:57
I'm creating a PDF file using the PdfStamper in iTextSharp and return the PDF as a memorystream object to the calling function, that is then used to display the PDF in Teleriks PDF Viewer Component for WinForms. That's the objective. Right now, creating the PDF works as it should, and it returns the data to the Calling function, and in the Calling function, should I write the memorystream contents to a file stream and then open it in Adobe Reader Everything looks just fine. However, if I choose to display the PDF in the PDF Viewer Control I just get an "Unsupported Stream type" error. Now, I

Why doesn't FontFactory.GetFont(“Known Font Name”, floatSize) work?

风流意气都作罢 提交于 2019-11-27 16:17:52
If I say: var georgia = FontFactory.GetFont("Georgia Regular", 10f); it doesn't work. When I check the state of the variable georgia, it has its Family property set to the value UNDEFINED and its FamilyName property set to Unknown . It only works if I actually load and register the font file and then get it like so: FontFactory.Register("C:\\Windows\\Fonts\\georgia.ttf", "Georgia"); var georgia = FontFactory.GetFont("Georgia", 20f); Why is that? iText is written in Java, which means it's platform-independent. It ships with 14 AFM files containing the metrics of the 14 Standard Type 1 fonts (4

How to add a rich Textbox (HTML) to a table cell?

醉酒当歌 提交于 2019-11-27 16:15:36
I have a rich text box named:”DocumentContent” which I’m going to add its content to pdf using the below code: iTextSharp.text.Font font = FontFactory.GetFont(@"C:\Windows\Fonts\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 12f, Font.NORMAL, BaseColor.BLACK); DocumentContent = System.Web.HttpUtility.HtmlDecode(DocumentContent); Chunk chunkContent = new Chunk(DocumentContent); chunkContent.Font = font; Phrase PhraseContent = new Phrase(chunkContent); PhraseContent.Font = font; PdfPTable table = new PdfPTable(2); table.WidthPercentage = 100; PdfPCell cell; cell = new PdfPCell(new Phrase