FAQ Database Discussion Community


How to align a label versus its content?

itextsharp,itext
I have a label (e.g. "A list of stuff") and some content (e.g. an actual list). When I add all of this to a PDF, I get: A list of stuff: test A, test B, coconut, coconut, watermelons, apple, oranges, many more fruites, carshow, monstertrucks thing I want to change...

Sign PDF with smartcard in web context using CAPICOM & iTextSharp

itextsharp,activex,digital-signature,smartcard,capicom
Read through the following references: iText Digital signature white paper, and C# examples. (specifically chapter 4) For those interested, another great and concise summary of the PDF signing process. CAPICOM documentation. Online examples / questions here and on iText mailing list archives, such as here and here. Hashing code: BouncyCastle.X509Certificate[]...

what is wrong with godaddy's timestamp server and itextsharp?

itextsharp
I am using the iTextSharp library to sign PDF documents. When I use the standard TSAClientBouncyCastle class to get time stamp from GoDaddy's server ( http://tsa.starfieldtech.com ), the response is an empty stream. At the same time, it perfectly works with other RFC 3161 compliant timestamp servers. Also, when I...

Merging documents with itextsharp

c#,.net,itextsharp
I am not experienced with iTextSharp and have this need: I have generated 2 PDFs: a small PDF (i.e. size A6) of one page containing 1 background image and some text in various format (paragraph, chunks, etc), some barcode some rectancles... But nothing more (no forms etc). The pdf is...

How to add text on the last page through pdfcontentbyte? [closed]

c#,pdf-generation,itextsharp
I'm creating a PDF document using iTextSharp and it contains a table that spans multiple pages. After adding the table, my PDF document has 3 pages. Now what I want to do is: Add some text on the last page through Pdfcontentbyte. ...

iTextSharp VB.Net - Fixing the formatting of my table to properly display in PDF

vb.net,pdf,design,datagridview,itextsharp
So far I keep getting PDF's life these: I just want to have a PDF file that displays them like an Excel would. Example: How do I make my iTextSharp values to display properly? I just want my words to line up straight instead of cutting them in halves. My...

Watermark in PDF file is hiding behind images

c#,pdf,itextsharp
I want to add a watermark to an existing PDF by using the following: ITextSharp insert text to an existing pdf The 3rd answer is working but if the PDF contains an image then the watermark is hidden behind it....

itextsharp 5.5.5 textcolor property is removed

c#,pdf,itextsharp
I have updated my itextsharp for 4.x.x to 5.5.5 (latest version) However the following line will give an error: Font heading1 = new Font(bfTimes, 16, Font.BOLD, Color.BLACK); Error: The name'Color' does not exist in the current context itextsharp.text.font.color is removed from the new version. How do I set the color...

iTextSharp 5.5.6 PdfCopy Failing with “Cannot access a closed file”

itextsharp,itext
This seems to be similar to this question: Merging Tagged PDF without ruining the tags I'm using the latest iTextSharp NuGet package (v5.5.6) trying to merge two tagged PDFs. When calling Document.Close() I'm getting an ObjectDisposedException originating from PdfCopy.FlushIndirectObjects(). at System.IO.__Error.FileNotOpen() at System.IO.FileStream.get_Position() at iTextSharp.text.io.RAFRandomAccessSource.Get(Int64 position, Byte[] bytes, Int32 off,...

crop Left side of pdf using Itextsharp

pdf,itextsharp
I am trying to crop left side of pdf to 10 mm. i used below code public void TrimLeft(string sourceFilePath, string outputFilePath) { PdfReader pdfReader = new PdfReader(sourceFilePath); float width =(float) GetPDFwidth(sourceFilePath); float height = (float)GetPDFHeight(sourceFilePath); float widthTo_Trim = iTextSharp.text.Utilities.MillimetersToPoints(10); // Set which part of the source document will be...

How do I add XMP metadata to each page of an existing PDF using iTextSharp

pdf,itextsharp
So far all the examples seem to involve adding metadata while creating a new Document. I want to take an existing PDF and add a GUID to each page's XMP using the stamper

How can i export my web page to pdf using iTextSharp

asp.net,itextsharp
i use this tutorial :http://www.aspsnippets.com/Articles/Export-ASPNet-Web-Page-with-images-to-PDF-using-ITextsharp.aspx for convert my page to pdf ,but when i run the project i get this error: An exception of type 'System.InvalidOperationException' occurred in System.Web.dll but was not handled in user code Additional information: RegisterForEventValidation can only be called during Render(); how can i solve...

PdfStamper being disposed

c#,pdf,itextsharp,idisposable,pdfstamper
The PdfStamper I'm passing in to this method is being disposed of at the end of the method - why, and how do I stop it? I'm trying to create a page object from the template, which I can then add to the PdfStamper X number of times. //real code...

C# ItextSharp Fontawesome Icons ( currency ) - PDF

c#,pdf,icons,itextsharp
i have problem is importing the icons (fontawesome-webfont.ttf) and showing them on PDF -but i am unable to show them on the PDF especialy currency icon (fa-money) some of the icons i was able to get it from the CultureInfo class if any thing i missed apart from this chunkRows...

How to directly print a PDF dynamically created with iTextSharp using asp.net c#?

c#,asp.net,pdf,printing,itextsharp
I have looked around a lot and i cant seem to find a way that works for me. I am creating a website, and I have two buttons, a Download button (which works fine) and a Print button that should print the PDF (or even just open the PDF in...

PDF Filter used to encode data in iTextSharp

pdf,pdf-generation,itextsharp
Currently I am working with iTextSharp library to generate PDF files and these files will be processed by some file processor. This pdf file processor is having some limitation with pdf filters which it will use to decode the data from the file. I am very keen to know which...

ITextSharp rotate all text on a page about a point

.net,pdf,rotation,itextsharp,affinetransform
I've just burnt an hour working out a solution to this, which I'm sure isn't the best one; I'd be happy to hear if there is a better solution. I need to rotate all text on a page about a point. I've tried transforming the point to the origin, performing...

Tagging individual pages of a PDF with ItextSharp C#

c#,.net,pdf,itextsharp,tagging
I am currently working with ITEXTSHARP 5.5.6.0 My goal is to add a Key to each page and have those persistent when I read the document again with another application. I want to be able to keep track of every page individually (the key is unique, and comes from another...

How to nest tables without extending the inner table?

.net,itextsharp
I am using itextsharp 5.5.3 in a .net project to generate a PDF file. I have a PdfPTable with two cells (in one row). I put another PdfPTable in each cell - first one with two rows and second one with three rows. The last row of the smaller table...

iTextSharp change outcome quality / compression like PDF24Creator

c#,pdf,itextsharp
I was wondering if I can compress/Change the Quality of my outcoming pdf-file with iTextSharp and C# like I can do with Adobe Acrobat Pro or PDF24Creator. Using the PDF24Creator I can open the pdf, save the file again and set the "Quality of the PDF" to "Low Quality" and...

How to show digital signature VALUE in signature appearance of PDF file with iTextSharp

c#,itextsharp,digital-signature
Is it possible to append Digital signature VALUE in signature appearance while signing document, because I am using this part of code PdfFilename = txtFile.Text + "\\" + (string)chkLista.Items[i]; DestPdfFilename = txtFile.Text + "\\" + (string)chkLista.Items[i] + "-signed.pdf"; Org.BouncyCastle.X509.X509CertificateParser cp = new Org.BouncyCastle.X509.X509CertificateParser(); Org.BouncyCastle.X509.X509Certificate[] chain = new Org.BouncyCastle.X509.X509Certificate[] { cp.ReadCertificate(cert.RawData)...

Add Uploaded File(s) to iTextSharp PDF New Page

c#,pdf,itextsharp
I'm at the last step in completing a pdf generator. I am using iText sharp and i am able to stamp a base64 image with no problem thanks to help from StackOverflow. My question is how would I iterate over posted files and add a new page with posted image...

Send .PDF file generated in memory via Resposne

c#,http,itextsharp,servicestack,httpresponse
So I have problem with Resposne file. I can send some file but it is corrupted. I know my pdf librabry works fine (checked on console app) public void Get(ClaimExportRequest exportRequest) { var str = ExportToPdf(claimDataTable); using (var streams = new MemoryStream(str)) { base.Response.AddHeader("Content-Disposition", "attachment; filename=report.pdf"); base.Response.AddHeader("Content-Length", str.Length.ToString(CultureInfo.InvariantCulture)); base.Response.ContentType =...

iTextSharp display 'error' using PdfContentByte and ColumnText

c#,pdf,itextsharp
I'm trying to use PdfContentByte and ColumnText to display notes imported from customer orders. The document and notes display correctly however, when I scroll down at all in the document, I get an error saying "An error exists on this page. Acrobat may not display the page correctly. Please contact...

Skip an extra line after particular row

c#,.net,itextsharp,itext
I have a table which has 3 columns and it has about 10 rows. But what I want to do is skip an extra line after a particular row. Here is my code; Paragraph paragraphTable3 = new Paragraph(); paragraphTable3.SpacingBefore = 20f; paragraphTable3.SpacingAfter = 10f; PdfPTable third_table = new PdfPTable(3); third_table.TotalWidth...

Get PDF be written in the center of the page itextsharp

c#,pdf,pdf-generation,itextsharp
I had a fillable PDF document (2 pages in total) consisting of different sizes of page; the first page is 8.5 * 11 inches (612 * 792), containing fillable fields; the second page is 9.5 * 12 inches (684 * 864), containing No fillable fields. Even though the second page...

How to Check PDF is Reader enabled or not using C#?

c#,pdf,itextsharp,pdfbox
My only requirement is to find a selected pdf in a folder is Reader enabled or not, more specifically if usage rights are defined in a way that allows people to add annotations (e.g. comments). I am doing this in windows application. If I click a button, an event is...

How to show a cell(column with its row values) of a pdftable(iTextSharp) in next line c#?

c#,pdf,itextsharp
I am generating a PDF document with a PdfPTable. There are three columns say Col a, Col b, and Col c. Currently it looks coming like this: Col a | Col b | Col c -------------------------------------------------------- ValuesofCol a | ValuesofCol b | ValuesofCol c But as the Col c is...

iTextSharp SetField for fields with same name on different pages

itextsharp
I used acroFields.GetTranslatedFieldName() to get the next fieldnames from the pdf: topmostSubform[0].Page1[0].CheckBox2A[0] topmostSubform[0].Page1[0].CheckBox2A[1] topmostSubform[0].Page2[0].CheckBox2A[0] topmostSubform[0].Page2[0].CheckBox2A[1] topmostSubform[0].Page3[0].CheckBox2A[0] topmostSubform[0].Page3[0].CheckBox2A[1] I use the next line of code to fill CheckBox2A[0] on the second page. fields.SetField("topmostSubform[0].Page2[0].CheckBox2A[0]", "1") Instead of CheckBox2A[0] on the second page, CheckBox2A[0] on the first page...

How do I make an iTextSharp signature appear on every page of a document?

c#,pdf,itextsharp
when I sign a document the signature only appears on the first page. Is there anything I can do to make it appear on every page? This is the method I'm using right now to sign the PDF, hope it helps find a solution: public static PdfStamper SignHashedUser(string Target, SysX509.X509Certificate2...

merging pdf docs using node webkit ,iTextsharp and edge

pdf,itextsharp,node-webkit,edge
I am merging multiple pdf docs into one pdf using the three tools mentioned in the title. Everything is working until I try to delete the original pdf's. They are "in use" by webkit. If I close NW they are released of course. I can run the same code but...

How to “postMessage” to host from within pdf when viewed in IE9 object element

javascript,asp.net-mvc,pdf,internet-explorer-9,itextsharp
I am attempting to do a small PoC with PDFs and have run into an issue. I am looking to post a message to a PDF and have the PDF post a message to the browser. The deets: I am viewing the PDF in an "object" element in IE9. I...

StorageFile filled with stream, not replacing the File

c#,windows-store-apps,itextsharp,filesavepicker
I have a Problem using the FileSavePicker. I always thought, the FileSavePicker would replace the file, when you Chose the Name of an existing file. It even asks "theres already some file with that Name, do you want to replace it?" when you click on save. In the next steps...

How to dislplay “✔” when signature is valid with iTextSharp?

c#,itextsharp,pdfstamper
I need to do a signature in pdf like this when trusted certificate: When certificate is unknown origin then display a "?". I can do the signature, but not display "✔" or "?"....

How To Remove Whitespace on Merge

c#,pdf,itextsharp
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...

Why do the widths of my textboxes differ when the code is effectively identical (iTextSharp)?

c#,pdf-generation,itextsharp
I've got a PDF file that I'm generating using iTextSharp; here's a part of it that is causing me to suffer from called alopecia areata due to excessive head-scratching: Here's the code: The longer initial text box on the row (below "Tier 2 Signature..."): PdfPTable tblSection6_Row6 = new PdfPTable(5); tblSection6_Row6.WidthPercentage...

Add multiple pages to pdf form with iTextSharp

c#,itextsharp,memorystream
I am trying to fill out a pdf form and the form could have multiple pages of the same form, so instead of writing each one to disk I want to create one pdf document in memory with all the pages. I have seen plenty of example on adding pages...

iTextSharp: “The document is not open” error - when it actually is

itextsharp
I have this code: private static byte[] ConvertPdfDocument(Document document, PdfPTable headerTable, PdfPTable affidavitsTable) { byte[] b; using (MemoryStream ms = new MemoryStream()) { PdfWriter writer = PdfWriter.GetInstance(document, ms); if (document.IsOpen() == false) { document.Open(); } document.Add(headerTable); document.Add(affidavitsTable); document.Close(); writer.Close(); b = ms.ToArray(); } return b; } The "document" object is...

How to add in reply to annotation using iTextSharp

c#,pdf,itextsharp
I am trying to add a sticky note reply to in pdf using iTextSharp. I am able to create a new annotation in the pdf. But i cannot link it as child of an already existing annotation. I copied most of the properties in parent to its child. I copied...

iText parser exception for XML -> PDF conversion

pdf,pdf-generation,itextsharp
I have a basic .vm file which I populate with XML, and then use iText to convert it to a PDF doc: <?xml version="1.0" encoding="UTF-8"?> <!--<!DOCTYPE itext SYSTEM "http://itext.sourceforge.net/itext.dtd">--> <itext creationdate='${System.DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss")}' producer="X"> <paragraph align="Default" size="18.0" style="bold" indentationleft="0.0"> Test </paragraph> </itext> The above is parsed absolutely fine. However something slightly...

How to open a pdf file using itextsharp

c#,itextsharp
I want to open a existing PDF document in my hard disk.How can I open a PDF document and view it with itextsharp? Or do i have to use adobe PDF reader component to view PDF. If I use adobe PDF reader component to view PDF document, is it possible...

Could not load type 'iTextSharp.text.html.HtmlParser' from assembly 'itextsharp, Version=5.5.5.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca'

c#,asp.net-mvc-4,itextsharp,razorpdf
see this link converting html to pdf I got this version error in webconfig let some genius find and solve the qustion. My Model public class Customer { public int CustomerID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } }...

Convert MVC 4 View To Pdf using Itextsharp [closed]

c#,asp.net-mvc-4,itextsharp
I am trying to Convert a MVC 4 View to a PDF. I have no idea where to start, after searching google i found ItextSharp and have been playing around with it. My View is fairly Simple it has a Map and a Table. i would like to just call...

iTextSharp - Setting zoom to “Fit page” and maintain it

c#,pdf,itextsharp,adobe-reader
I can't manage to get the correct zoom on my document created with iTextSharp. When opening the document, the zoom is fine, but as soon as I click on a Bookmark the zoom changes to the Setting of Adobe Reader. So, for example: - I open the pdf Document: Zoom...

Manipulate PDF objects

c#,pdf,pdf-generation,itextsharp,pdfsharp
I am trying to manipulate a PDF, it functions as a template. What I am trying is replacing 'placeholders' in the PDF template with my data. So someone makes a PDF template in Scribus for example, and adds an empty image with the name "company_logo". My application sees an image...

How to get exact opposite of a coordinate in itextsharp? VB.Net

vb.net,pdf,itextsharp
Here is my code: Dim ImagePath = "C:\Users\Miguel\Desktop\Logo.jpg" Dim Img = iTextSharp.text.Image.GetInstance(ImagePath) Img.SetAbsolutePosition(doc.PageSize.Width - 36.0F - 100.0F, doc.PageSize.Height - 36.0F - 99.0F) wri.DirectContent.AddImage(Img) I want to put another image directly at the opposite side (this one is on the right side, I want another photo on the left) of it....

how to add background color for border of itextsharp pdf page

c#,asp.net,.net,pdf-generation,itextsharp
How can I add back ground color [not border line color] at out side of border[four sides] of itextsharp pdf page .. I tride with this .. but Its not working for back ground color of out side of border.. content.EoFill(); content.EoFillStroke(); content.Fill(); content.FillStroke(); but not working public class pageborder...

XMLWorker: cell's vertical-align not working

css,itextsharp,itext,xmlworker
If you check this code: <table> <tr> <td border="1"> <table> <tr><td>Blah</td></tr> <tr><td>Blah</td></tr> <tr><td>Blah</td></tr> </table> </td> <td border="1"> <table> <tr><td>Blah</td></tr> <tr><td>Blah</td></tr> </table> </td> </tr> </table> In here: http://demo.itextsupport.com/xmlworker/ You will see this: But if you click on "transform"...

How to get signature Value from signed PDF in C#?

c#,pdf,itextsharp,digital-signature
How is it possible to get signature Value from signed PDF file? I can get all other data from signature except its value. Is there any way to get it in C#? PdfPKCS7 pk; PdfReader reader = new PdfReader(PdfFilename); AcroFields af = reader.AcroFields; var names = af.GetSignatureNames(); foreach (string name...

How to use a c# Image object in itextSharp

c#,itextsharp
Is there any solution to convert a c# Image object to an iTextSharp compatible image to be used inside the pdf.

How can I get my PdfPTable's border and background color to display (iTextSharp)?

pdf-generation,itextsharp,pdfptable
As you can see, I've got a table which sports borders and a background color (Section 1): ...but section 3 lacks these sartorial refinements, and I don't know why. Here is the pertinent code for section 1 (which displays as it should): PdfPTable tblHeadings = new PdfPTable(3); tblHeadings.WidthPercentage = 100;...

Why is the pdf toolbar not getting hidden using itextsharp? [duplicate]

pdf,itextsharp
This question already has an answer here: Can I hide the Adobe floating toolbar when showing a PDF in browser? 3 answers I used the below code to hide the toolbar widget that gets displayed in the browser. stamper.setViewerPreferences(PdfWriter.HideToolbar); When I open any pdf in the iframe it is...

Could not find file 'C:\Program Files\IIS Express\#'

c#,iis-7.5,itextsharp
I am reading a text file and trying to parse it as an html and make a pdf of it with iTextSharp. Here I load the text file: string HTML = System.IO.File.ReadAllText(Server.MapPath("~/Misc/Html.txt")); HTML = HTML.Replace("[Date]", Paristan.Broker.UI.Components.PersianDate.GetDate(DateTime.Now)); HTML = HTML.Replace("[Title]", person.Title); HTML = HTML.Replace("[Person]", person.Name); The HTML.txt contains something like the...

iTextSharp - Paragraph Line-Height

c#,pdf,pdf-generation,itextsharp,typography
I'm currently working on a PDF but I am facing issues trying to increase the line-height of a Paragraph, this is the code that I have now: var tempTable = new PdfPTable(1); cell = new PdfPCell(new Paragraph("My Account", GetInformationalTitle())); cell.Border = Rectangle.NO_BORDER; tempTable.AddCell(cell); cell = new PdfPCell(new Paragraph("http://www.google.com/", GetInformationalOblique())); cell.Border...

How to set basefont color?

c#,pdf,itextsharp
I want to change my basefont color. I used a rectangle to set the background color, but I can't figure out how to get my font to be white, as I'm using PdfContentByte object. I tried to use Chunk to set the font color but SetFontAndSize overrides it. BaseFont bfTimes...

iTextSharp - Unable to draw rectangle over tablecell background color

c#,pdf,itextsharp
I'm using iTextSharp to create a PDF using an HTML page as an example. I am trying to put a border around text to highlight certain items. Using methods from these posts (Draw Rect at curr position, and Add Text over image ) I have used OnGenericTag events to create...

Locking a signed PDF using iTextSharp after Long Term Validation(LTV) has been added using LtvTimestamp

pdf,itextsharp
Is it possible to stop any annotations and / or signatures being added after a PDF has had LTV added using LtvTimestamp? I've tried adding PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED on the initial signing but adding LTV invalidates that signature. Any help would be greatly appreciated....

Reading PDF document with iTextSharp creates string with repeating first page

itextsharp
I currently use iTextSharp to read in some PDF files and parse them by using the string I receive. I have encountered a strange behavior with some PDF files. When getting the string back of a for example 4 page PDF, the string is filled with the pages in the...

Crop Pdf from each edge using itextshap

c#,pdf,itextsharp
I am trying to crop pdf 5 mm from every edge i.e top,bottom,right and left. I tried with below code public void TrimPdf(string sourceFilePath, string outputFilePath) { PdfReader pdfReader = new PdfReader(sourceFilePath); float widthTo_Trim = iTextSharp.text.Utilities.MillimetersToPoints(5); using (FileStream output = new FileStream(outputFilePath, FileMode.Create, FileAccess.Write)) using (PdfStamper pdfStamper = new PdfStamper(pdfReader,...

Add image and text in one line itextsharp

vb.net,pdf,itextsharp
Below code is adding text and image in separate lines. How can I display them in one line? pdfDoc.Add(image) pdfDoc.Add(New Paragraph(text)) ...

IOError on file deletion

c#,file,itextsharp,watermark
The following code is used for watermarking pdf : using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using iTextSharp.text; using iTextSharp.text.pdf; namespace WaterDocument { class Program { static void Main(string[] args) { string FileLocation = "C:\\Users\\Desktop\\Hello.pdf"; // string watermarkedFile = "Watermarked.pdf"; // Creating watermark on a separate layer...

iTextSharp: how to scale font to make a multiline it fill a rectangle

text,itextsharp,textwrapping
Using iTextSharp I have to fill a given rectangle with a text, both in height and width. The text can wrap, I have to find the correct fontsize for it to fill the rectangle. wrapping the text is not an issue I have a recursive function that return an array...

Extract Embedded XML from PDF with iTextSharp (C#)

c#,pdf,itextsharp
I need to extract XML data embedded in Bankruptcy court files with C#. In PDF Reader the file looks like a typical court doc. In Notepad the XML is buried in the text. I've tried extracting the text with this and another code snippet using SimpleTextExtractionStrategy. The first results in...

Why is my PDF being generated as blank?

c#,pdf,itextsharp,xmlworker
I am using ItextSharp and c#, asp.net MVC to generate a PDF report. However, when I generate the report the PDF comes back as blank (apart from a header which is working fine). I would love your input. The code that generates the report is as follows: using (var writer...

How to use iTextSharp to convert to PDF

c#,itextsharp
ASP: <asp:Label ID="Label1" runat="server" Text="Folder Location: "></asp:Label> <asp:TextBox ID="tbFolder" runat="server"></asp:TextBox> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Destination Folder: "></asp:Label> <asp:TextBox ID="tbDestination" runat="server"></asp:TextBox> <br /><br /> <asp:Button ID="btnExecute" runat="server" Text="Button" OnClick="btnExecute_Click" /> code-behind: public void btnExecute_Click(object sender, EventArgs...

ITextSharp setting background working not for all fields

c#,itextsharp
I have the following string of code setting bacground for all pdf fields: using (var pdfReader = new PdfReader(template)) { using (var pdfStamper = new PdfStamper(pdfReader, new FileStream(fileName, FileMode.Create)){FormFlattening = true}) { var fields = pdfStamper.AcroFields; foreach (var field in fields.Fields) { fields.SetFieldProperty(field.Key, "bgcolor", new BaseColor(Color.Red), null); } } }...

Get Layer2 Text (Signature Description) from signature image using itextsharp

c#,itextsharp
I need to retrieve the layer2 text from a signature. How can I get the description (under the signature image) using itextsharp? below is the code I'm using to get the sign date and username: PdfReader reader = new PdfReader(pdfPath, System.Text.Encoding.UTF8.GetBytes(MASTER_PDF_PASSWORD)); using (MemoryStream memoryStream = new MemoryStream()) { PdfStamper stamper...

Table border does not automatically fit into contents

c#,asp.net-mvc,itextsharp
I have an invoice being constructed via iTextSharp (4.1.2). My problem lies on a certain part of my invoice wherein I display the terms and conditions and the payment terms. The following image below shows my problem. However, when the dynamic rows are not present (I mean no selected discounts,...

iTextSharp - Table in absolute coordinates

c#,table,itextsharp,coordinates,absolute
I am trying to use this tutorial to position table in absolute coordinates using iTextSharp. Here is my code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using iTextSharp; using iTextSharp.text; using iTextSharp.text.pdf; using System.IO; namespace iTextSharpQuestion { class Program { static void Main(string[] args) { System.IO.FileStream fs = new...

Converting images to PDF with iTextSharp preserve clipping path

c#,itextsharp,itext,jpeg,clipping
We're looking to convert images in bulk to PDF, programmatically. So far it looks like we will be using iTextSharp but we have an issue with JPG images with clipping path. We are using the following code in our tests: using (FileStream fs = new FileStream(output, FileMode.Create, FileAccess.Write, FileShare.None)) {...

Clear MemoryStream after passing the objects to a different function

c#,smtp,itextsharp,memorystream
My main question is if I pass object to a function that are using a MemoryStream how to I go about clearing the memorystream? See my code below. In more detail: I'm trying to send multiple emails while creating PDFs on the fly using iTextSharper. I want to make sure...

Save pdf file with user input filename (iTextSharp)

c#,winforms,itextsharp,export-to-pdf
I want to allow user to enter his own file name, just like save file dialog and stream (Example: Stream s = File.Open(sfdPdf.FileName, FileMode.CreateNew) Here is my code: private void btnSave_Click(object sender, EventArgs e) { System.Drawing.Rectangle bounds = this.Bounds; using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using (Graphics graphics...

Adding an imported PDF to a table cell in iTextSharp

pdf,itextsharp
I am creating a new PDF that will contain a compilation of other documents. These other documents can be word/excel/images/PDF's. I am hoping to add all of this content to cells in a table, which is added to the document - this gives me the goodness of automatically adding pages,...

ITextSharp/Pdftk: place Base64 Image from Web on PDF as Pseude-Signature

c#,itextsharp,pdftk
I am trying to conceptualize a way to get base64 image onto an already rendered PDF in iText. The goal is to have the PDF save to disk then reopen to apply the "signature" in the right spot. I haven't had any success with finding other examples online so I'm...

Alignment issue with multiline text form fields in iTextSharp

c#,itextsharp,itext
I have written an application to programatically fill out a form in a PDF template from a database and save the result to disk. Everything is working correctly apart from any multi-line text fields which are not rendering as expected. They should be top, left aligned with no gaps between...

Use Custom font with Unity3D and ItextSharp

android,pdf,fonts,itextsharp
First of all, this question is copied from Unity Answers with no luck getting any solution. If this approach is not acceptable just let me know. Because I need to use special characters, integrated itextsharp font cant handle them, I need to use my own custom font. The integration...

Itextsharp error “Unknown Filter: ” when closing the stamper

c#,itextsharp
I'm trying to add a digital signature to a blank existing pdf, then create a new pdf with the digital signature with it. Here's my code: FileStream fs = new FileStream(newFile, FileMode.Create, FileAccess.Write); PdfReader pdfreader = new PdfReader(pdf); PdfStamper stamper = PdfStamper.CreateSignature(pdfreader, fs, '\0'); stamper.Writer.CloseStream = false; StringBuilder sb =...

Will iTextSharp version 5.5.2 run with C#, .net version 3.5 code?

c#,pdf,itextsharp
I need to merge mutiple pdf files into one pdf. My code is using .net and C# version 3.5. From what I have read here in StackOverflow and elsewhere, iTextSharp seems to be most highly recommended pdf file manipulation utility. Will the latest version of iTextSharp on sourceforge.net, I think...

Drawing circle on existing PDF using itextsharp c#

c#,itextsharp
I got some troubles drawing circle on an existing pdf, I found a code to add text on existing PDF, I tried to adapt it to draw circle but the result is just a blank page Does anyone have an idea how to fix this? My code: string oldFile =...

how to add pagenumbers to every pdf page using itextsharp

c#,pdf,pdf-generation,itextsharp
here is What i want i want to add page numbers to every pdf page that i generated on the fly. i used on end page method but it did not worked out even when i added the doc bottom margin. I decided to add the page numbers after the...

Add javascript to pdf file using iTextSharp

javascript,c#,pdf,itextsharp
I want to embed a javascript snippet inside of a pdf file so that it will immediately print when it's opened from a browser window. To try and achieve this I'm following this example here. I have created a helper class that has a static method to handle this task....

iTextSharp rotated PDF page reverts orientation when file is rasterized at print house

pdf,printing,itextsharp,itext
Using iTextSharp I am creating a PDF composed of a collection of existing PDFs, some of the included PDFs are landscape orientation and need to be rotated. So, I do the following: private static void AdjustRotationIfNeeded(PdfImportedPage pdfImportedPage, PdfReader reader, int documentPage) { float width = pdfImportedPage.Width; float height = pdfImportedPage.Height;...

Namespace for using iTextSharp CSSResolver classes

asp.net,vb.net,itextsharp
I am using iTextSharp CSSResolver classes for using external css in vb.net Please let me know the namespaces for using XMLWorkerFontProvider, CssFilesImpl, StyleAttrCSSResolver classes. Below is my code: Dim fontProvider As XMLWorkerFontProvider = New XMLWorkerFontProvider() Dim cssFiles As CssFilesImpl = New CssFilesImpl(fontProvider) cssFiles.Add(XMLWorkerHelper.GetInstance().GetDefaultCSS()) Dim cssRevolver As StyleAttrCSSResolver = New StyleAttrCSSResolver()...

Draw a line every N words using iTextSharp

position,itextsharp,line,word,draw
Using iTextSharp, I create a pdf writing some text into it. What I need is to draw a line to delimiter the text every 25 words, like the following image: Basically, I need to do that: draw a line every 25 words, just like the image. I'm aware there's a...

How to load a PDF from a stream and add a file attachment?

c#,pdf,reporting-services,itextsharp
I'm using a MS SQL Report Server web service to generate reports in the PDF format: byte[] Input; ReportServer report = new ReportServer(serverUrl + @"/ReportExecution2005.asmx", reportPath); Input = report.RenderToPDF(reportParamNames, reportParamValues); This service returns a byte array with pdf file. I need this byte array load to iTextSharp: using (MemoryStream ms...

giving error while creating pdf.The process cannot access the file.because it is being used by another process

c#,asp.net,pdf,itextsharp
im exporting web page div into pdf and sending that mail to pdf. for first time its creating pdf and sending mail properly.but for next time its giving error saying . file is bieng used by a another process at this line PdfWriter writer = PdfWriter.GetInstance(pdfDoc, new FileStream(strPath, FileMode.Create)); my...

Get exact cordinates of the page to add a watermark with different page rotation using iTextSharp

c#,.net,itextsharp
I have been trying to position a Text Water marks on PDF file using iTextSharp and i am struggling to find the coordinates on each page. it works fine when all the pages in pdf file are of same rotation but if the rotation is different then the coordinates are...

Image going to second page of PDF VB.Net iTextSharp

vb.net,image,pdf,itextsharp
Here is my code: 'Make a new image object Dim ImagePath = "C:\Mickosis\Class Manager\Logo.jpg" Dim Img = iTextSharp.text.Image.GetInstance(ImagePath) Img.SetAbsolutePosition(464, 710) wri.DirectContent.AddImage(Img) Dim ImagePath1 = "C:\Mickosis\Class Manager\AdU.jpg" Dim Img1 = iTextSharp.text.Image.GetInstance(ImagePath1) Img1.SetAbsolutePosition(29, 710) wri.DirectContent.AddImage(Img1) The problem is that if the PDF only has one page, it will appear on the upper...

Register font from byte array in iText

c#,fonts,itextsharp,itext
Is it possible to register a font from a byte array, instead of using file paths? The FontFactory class has two methods for registering fonts. Both use file/folder paths to register fonts: Register RegisterDirectory I looked into the iText source for clues, but I don't understand how the font files...

Geneate table in pdf using itextsharp vb.net from sql

sql,vb.net,pdf,itextsharp
I can create a simple pdf file like "Hello world", but I want to generate a table in pdf file using vb.net. I am using itextsharp library. This is what I have tried so far. Protected Sub Create_PdfTable_Click(sender As Object, e As EventArgs) Handles Create_PdfTable.Click Dim table As New PdfPTable(2)...

Convert html with Persian characters to pdf using iTextSharp

c#,itextsharp,persian
I have a Html file that contains Persian characters. I eant to convert it to pdf using iTextSharp. I have written these lines to do it: string HTML = System.IO.File.ReadAllText(Server.MapPath("~/Misc/Html.txt")); Document document = new Document(); string fontpath = Server.MapPath("~/Fonts/BNazanin.ttf"); iTextSharp.text.FontFactory.Register(fontpath); PdfWriter.GetInstance(document, new FileStream(Server.MapPath("~/Files/Pdf/test.pdf"), FileMode.Create)); document.Open(); try { iTextSharp.text.html.simpleparser.StyleSheet styles =...