itextsharp

Using ItextSharp PdfPTable, table.TotalHeight returns 0.0, but expecting a positive float value

一笑奈何 提交于 2019-12-12 13:54:24
问题 I'm using ItextSharp to create a PDF document with multiple PdfPTables. I group multiple PdfPTables using a list, and the list is created in a function and returned as a list. I then take the list and loop through it to add each PdfPTable to the document. In the case that the next PdfPTable in the list is larger than the remaining space on the document I want to add a new page. Using a breakpoint, I've noticed that "table.TotalHeight" always returns 0, when I expect it to return a positive

iTextSharp - acroform field encoding

安稳与你 提交于 2019-12-12 12:44:18
问题 I'm trying to fill out a AcroForm's textfield with iTextSharp. The Acroform textfield was created also by iTextSharp by this piece of code: TextField Field = new TextField(OutputWriter, FieldPos, "MyField"); OutputWriter.AddAnnotation(Field.GetTextField()); // OutputWriter is writing to form.pdf I fill the form using this code: PdfReader reader = new PdfReader("form.pdf"); PdfStamper filledOutForm = new PdfStamper(reader, new FileStream("filled_form.pdf", FileMode.Create)); AcroFields form =

Loading BaseFont from embedded resource in iTextSharp

為{幸葍}努か 提交于 2019-12-12 12:26:52
问题 I am using iTextSharp to generate dynamic PDF documents. I have a requirement to use a very specific font for which I have the licensed .ttf file. I can use the code the below to load and use the font, however I would much prefer to have the font file as located as an embedded resource in my class library rather than being reliant on a specific location on disk. string fontpath = Server.MapPath("."); BaseFont customfont = BaseFont.CreateFont(fontpath + "myspecial.ttf", BaseFont.CP1252,

ITextSharp: Text not wrapping around image within cell

纵饮孤独 提交于 2019-12-12 12:11:41
问题 I am having real problems, I have a cell with a phrase, and I want a small icon to the left of the phrase, but each element is being rendered on a new line here is my code that returns the cell: var cell = new PdfPCell(); Bitmap bitmap = new Bitmap(21, 21); Graphics g = Graphics.FromImage(bitmap); g.Clear(Color.White); SolidBrush brush = new SolidBrush(colour); g.FillEllipse(brush, 0, 0, 20, 20); brush.Dispose(); g.DrawImageUnscaled(bitmap, 0, 0); g.Dispose(); var imgIcon = iTextSharp.text

itext get content size

会有一股神秘感。 提交于 2019-12-12 11:50:27
问题 I just spent a few hours scouring the web. It seems others also have this issue, but I couldn't find an answer. I have a whole bunch of PDF files that I need to get their measurements, namely their height and witdh of the pages content. In Adobe Illustrator, when you import a PDF you have the option of triming to the "bounding box". That's exactly what I need. I tried many approaches, here's the hodgepodge: Dim pdfStream = IO.File.OpenRead(FilePath) Dim img = PdfImages(pdfStream) Dim

How may I get the image of DataVisualization.Charting.Chart to iTextSharp.text.Image without writing to a file?

纵然是瞬间 提交于 2019-12-12 11:34:22
问题 I'm writing a piece of software for visualization of measurement data. For this I use System.Windows.Forms.DataVisualization.Charting.Chart and I do know that I can get the shown image by chartObj.SaveImage to store it to a file. My software shall have a PDF export in which the picture should be included. For this, I'm using iTextSharp. Again, I do know how to put a picture which I have stored in a file into the PDF by iTextSharp.text.Image.GetInstance. So by now I am able to take the picture

How to Change Default Font Size in iTextSharp After Exporting GridView to PDF?

左心房为你撑大大i 提交于 2019-12-12 11:13:46
问题 I am using the iTextSharp method in the following link to export a GridView to a PDF document: http://www.aspsnippets.com/Articles/Export-GridView-To-Word-Excel-PDF-CSV-Formats-in-ASP.Net.aspx The code is like this: protected void btnExportPDF_Click(object sender, EventArgs e) { Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new

Get PDF page size with iTextSharp

你离开我真会死。 提交于 2019-12-12 10:59:50
问题 I have a PDF document that I just received via file upload (InputFile). I'd like to use iTextSharp to check it's page size before proceeding. For example, the size of a pdf when you go to file > Properties > Description Tab > Page Size (in acrobat). Any advice on how I can do that? THANKS! 回答1: You need to read the pdf from your input stream (m). PdfReader reader = new PdfReader(m); // Page size Rectangle pagesize = reader.GetPageSize(1); 来源: https://stackoverflow.com/questions/3480730/get

How to set copyright metadata of an existing PDF using iTextSharp for C#

江枫思渺然 提交于 2019-12-12 09:43:51
问题 How can the copyright metadata of an existing (i.e. a pdf loaded from file or memory stream) pdf file be set using iTextSharp for C#? Thanks a lot 回答1: The native XMP structures don't have copyright implemented (or at least they don't in a way that Adobe Reader recognizes.) To do that you can reverse engineer what Adobe kicks out and write it manually: String inputPDF = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Services.pdf"); String outputPDF = Path.Combine

Append PDF to a Signed PDF

一笑奈何 提交于 2019-12-12 09:28:03
问题 I need to append a pdf file to a digital signed pdf file, keeping valid the signature ...maybe using revision? ...using iTextSharp? How can I do it? Please help me with some sample. 回答1: You can't as that invalidates the whole point of digital signatures, namely to detect when something exactly as you describe occurs and therefore ensure the validity of the original document. To do as you want, you will need to add the extra PDF to the unsigned original PDF and then resign the new