itextsharp

How to merge first 3 columns for rows with same value in PDF

随声附和 提交于 2019-12-12 03:26:21
问题 I'm using itextSharp to export a DataTable to a pdf table. I can export the data to a pdf table using the sample code i have posted below. The DataTable contains close to 21 columns. The first column in the pdf (DataTable) might contain similar values for any number of rows. If the data values in first column for a group of rows is similar, i want to merge the first 3 columns of those rows as one cell. I'm having trouble modifying the code below to achieve this. public iTextSharp.text.Table

Extract ID of a PDF document using iTextSharp

元气小坏坏 提交于 2019-12-12 03:22:39
问题 I need to extract PDF identifier mentioned in the trailer section of the document. But I am not able to get that value. Eg. Following is mentioned in my pdf file: trailer <</Size 196/Prev 370761/Root 160 0 R/Info 158 0 R/ID[<30EB7FCBB6756E461176FBBD0CEBA7B9><DB67D6D43AE0FA4FBF8CC171FC66790A>]>> I need to extract value 30EB7FCBB6756E461176FBBD0CEBA7B9 . Using the PdfReader.Trailer I get a dictionary type of object if one key as 'ID' but I am not able to get the above required value from it.

Why does breaking out of a foreach loop cause complaint “Cannot access a closed Stream”?

那年仲夏 提交于 2019-12-12 03:06:26
问题 Based on the suggestion in the comments here, I refactored my method to try to assign data to a MemoryStream outside of the iTextSharp.text.Document "using" (but within the MemoryStream using clause): internal static HttpResponseMessage GeneratePDFOfReportFutures() { HttpResponseMessage result = null; futureReports = GetAllFutureReports(); try { using (var ms = new MemoryStream()) { using (var doc = new Document(PageSize.A4.Rotate(), 25, 25, 25, 25)) // the "Rotate" makes it landscape

itext add text to pdf increase file size

牧云@^-^@ 提交于 2019-12-12 02:52:57
问题 I have a PDF file and I want to add a simple number on each page. Here is my code: reader = new PdfReader(fileOut); Document final = new Document(reader.GetPageSize(1)); PdfWriter w = PdfWriter.GetInstance(final, new FileStream(finalFile, FileMode.Create, FileAccess.Write)); w.SetFullCompression(); final.Open(); for (int i = 1; i <= reader.NumberOfPages; i++) { final.NewPage(); PdfContentByte cb = w.DirectContent; ControlNumberTimes(cb, "C"+i, 560, 725, 270, Element.ALIGN_LEFT); cb

C# - Set inherit zoom action for all the bookmarks in the PDF file

倾然丶 夕夏残阳落幕 提交于 2019-12-12 02:48:56
问题 I have a PDF file with 3 types of bookmark 1st book mark - 100% zoom 2nd book mark - 200% zoom 3rd book mark - 300% zoom I have used following code but its fails in the annotation line. PdfArray annots = page.getAsArray(PdfName.ANNOTS); // fails for (int i = 0; i < annots.size(); i++) { PdfDictionary annotation = annots.getAsDict(i); if (PdfName.LINK.equals(annotation.getAsName(PdfName.SUBTYPE))) { PdfArray d = annotation.getAsArray(PdfName.DEST); if (d != null && d.size() == 5 && PdfName.XYZ

How to check if a checkbox is checked or not on a non-form PDF using C#?

僤鯓⒐⒋嵵緔 提交于 2019-12-12 01:58:36
问题 Using c#, I want to see if a specific check box is checkd on a PDF page. The PDF file is not a form one. PDF could be something like: Sample file is here: MDS30ResidentP2.pdf (in this sample file, I want to somehow figure it out that check-box "E" in the question A1000 is checked. Again: the PDF is not in "form" format!). PS: none of the following posts was solved my problem: PDF Parsing extract CheckBox Fields value iTextSharp: reading radio button, check box states from a non-form PDF 回答1:

PDF Field format changes after Encrypting the PDF document using iTextSharp

删除回忆录丶 提交于 2019-12-12 01:58:16
问题 I am using iTextSharp to manipulate PDF documents. I have to make PDF document encrypted and I am able to do it. The only problem that I am getting now is the format of form fields - they got changed. For example: I have text field of ' Integer ' type with format ' 1,234.00 '. Before encrypting the format is what I have set. But after encrypting the PDF the format changes to default i.e. value becomes ' 1234 '. Any suggestion? UPDATE: I am using following code to set password on document:

Bottomborder for a subtable cell and for the general pdfPcell of parent table are not making a single straight line in iTextPDF

自古美人都是妖i 提交于 2019-12-12 01:57:59
问题 I have used one parent table that is table_body. One child table that is sub_table(as i would like to place this sub_table inside a PdfPCell in the parent table. ). I want to draw a line when a row is complete for the parent table as per my requirement. But, the issue is bottomborder for the subtable and for the general pdfPcell 'body_cell_bottomBorder' is not getting aligned in a single straight line. PdfPTable table_body = new PdfPTable(2); // main table table_body.getDefaultCell()

Divide one page PDF file in two pages PDF file

匆匆过客 提交于 2019-12-12 01:55:44
问题 I'm using iTextSharp to handle pdf files. I'd like to know how I can split a page in half and make 2 different pages from the two pieces. I tried a lot but nothing seems to work right now. First try iTextSharp.text.Rectangle size = new iTextSharp.text.Rectangle(0, pdfReader.GetPageSize(1).Height / 2, pdfReader.GetPageSize(1).Width, 0); Second try iTextSharp.text.Rectangle size = pdfReader.GetPageSizeWithRotation(1); iTextSharp.text.Document document = new iTextSharp.text.Document(size

how to insert a table into existing PDF using itextsharp

主宰稳场 提交于 2019-12-12 01:48:57
问题 Is there any way (using iTextSharp) to work with a pdf form like the following one ... where : 1- some fields to appear in the first page only ( Top of the form ) 2- some fields to appear in the last page only ( Bottom of the form ) 3- table to be added using C# code after the form is generated with the the first two sections and the table me consume more than one page ( between the first two ) I did the following : FillTable(); Byte[] buffer = System.IO.File.ReadAllBytes(@"C:\Users\mahmod