itextsharp

How to handle the case in wich an iText\iTextSharp table is splitted in two pages?

丶灬走出姿态 提交于 2019-12-02 10:43:10
问题 I have the following problem using iTextSharp. I am putting some tables into my document. The problem is that if a table content not fit on a page and go into another page I have that it overwrite the second page header, so I have the following situation: As you can see I am inserting a table at the end of a page and this is splitted in two pages and the second page header is overwrite by the table content. I want to avoid this situation but I don't know how have I to do. I am thinking that

How to add a table as a header?

こ雲淡風輕ζ 提交于 2019-12-02 10:40:01
I am working with iTextSharp trying to add an header and a footer to my generated PDF but, if I try to add an header that have width of 100% of my page I have some problem. So I have do the following things: 1) I have create a class named PdfHeaderFooter that extends the iTextSharp PdfPageEventHelper class 2) Into PdfHeaderFooter I have implemented the OnStartPage() method that generate the header: // write on start of each page public override void OnStartPage(PdfWriter writer, Document document) { base.OnStartPage(writer, document); PdfPTable tabHead = new PdfPTable(new float[] { 1F });

iTextSharp v5 GetTextFromPage() throws IndexOutOfRangeException

寵の児 提交于 2019-12-02 10:26:05
Trying to extract the textual content of a pdf with the following code: PdfReader reader = new PdfReader(path); string strText = string.Empty; for (int page = 1; page <= reader.NumberOfPages; page++) { string s = PdfTextExtractor.GetTextFromPage(reader, page); strText += " " + s; } reader.Close(); NumberOfPages returns 257, but at page 227, GetTextFromPage() throws a IndexOutOfRangeException. Any help is appreciated. hofnarwillie I resolved this issue by updating my version of iTextSharp from 5.1 to 5.2. 来源: https://stackoverflow.com/questions/8578793/itextsharp-v5-gettextfrompage-throws

itextsharp adding header and footer, displayed inside the page margin not outside the page margin.

我的梦境 提交于 2019-12-02 10:25:38
I am new to ItextSharp, just wondering how to place header and footer outside the margin after end of page event? it seems when i used the onendpage event instead of adding the footer outside of the page margin, it adds inside of page margin, and it always produce stackoverflow exception when it will be over the bottom margin where it should add outside of the margin? are there any settings to tell to add the text in document footer outside of margin (or is it padding)? thanks in advance. As you are new to iText... when you are looking for samples concerning some specific topic, you should

Write MS Word Doc using itextsharp library

荒凉一梦 提交于 2019-12-02 10:23:53
Can I write MS Word document using iTextSharp library? If yes, please give me sample code. No, you can't. According to Wikipedia , iTextSharp is a .NET port of iText, a free and open source library for creating and manipulating PDF files in Java . You can use it to create pdf documents, but not MS Word documents. 来源: https://stackoverflow.com/questions/3758043/write-ms-word-doc-using-itextsharp-library

How to add an image to a table cell in iTextSharp using webmatrix

◇◆丶佛笑我妖孽 提交于 2019-12-02 10:11:26
问题 I have made a table with cells and interested in having an image in one of the cell. Below is my code: doc.Open(); PdfPTable table = new PdfPTable(2); table.TotalWidth = 570f; table.LockedWidth = true; table.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right PdfPCell points = new PdfPCell(new Phrase("and is therefore entitled to 2 points", arialCertify)); points.Colspan = 2; points.Border = 0; points.PaddingTop = 40f; points.HorizontalAlignment = 1;//0=Left, 1=Centre, 2=Right table.AddCell

How to correctly fill in XFA form data using iTextSharp to allow editing and saving result in Acrobat XI

倖福魔咒の 提交于 2019-12-02 09:56:11
I have an application that I'm using the populate a pdf form using iTextSharp. /// <summary> /// Imports XFA Data into a new PDF file. /// </summary> /// <param name="pdfTemplate">A PDF File with an unpopulated form.</param> /// <param name="xmlFormData">XFA form data in XML format.</param> /// <returns>a memorystream containing the new PDF file.</returns> public static void XFAImport(System.IO.Stream pdfTemplate, System.IO.Stream xmlFormData, System.IO.Stream outputStream) { using (iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(pdfTemplate)) { using (iTextSharp.text

I can't insert something as “Page X of Y” into my PDF footer using iTextSharp

穿精又带淫゛_ 提交于 2019-12-02 09:47:35
问题 I am pretty new in iTextSharp and I have the following situation: I am creating a PDF that contains an header and a footer (for the header and footer creation I am using a class that extends PdfPageEventHelper and I have override the OnStartPage() and the OnEndPage() method, it work fine). Now my problem is that I have to insert as Page X of Y into my footer. Where X**is the **current page number and Y is the total page number . The value of Y is not fixed (because the length of my PDF is not

iTextSharp: Page header out of alignment with large tables

痞子三分冷 提交于 2019-12-02 09:41:44
I am using the latest version of iTextSharp (5.4.3). When defining an even simple page header the header gets out of vertical alignment if the document contains large tables that do not fit on one page. The alignment on the first page a large table is displayed is fine, but on subsequent pages the header is displayed further down and overlays the table. My code is below. Would be nice to get a workaround or an idea what could be wrong. By the way: When adding paragraphs that cause an automatic page break I get the page headers as expected. Here's my test code: const string pdfFileName =

How can I get the resolution of an embeded image in a PDF using ITextSharp

99封情书 提交于 2019-12-02 09:23:52
I've built a method that tries to see if the resolution of all the embedded images in a given pdf is at least 300 PPI (print-worthy). What it does is cycle through each image on a page, and compare its width and height to the artbox width and height. It works successfully if there is only one image per page, but when there are multiple, the artbox size includes all of the images, throwing the numbers off. I was hoping that somebody might have some idea of how to get the rectangle size the image is drawn in so I can compare correctly, or if there is an easier way to get the PPI of an image