itextsharp

Fill PDF template acrofield with HTML formatted text using iTextSharp

帅比萌擦擦* 提交于 2019-12-18 17:03:08
问题 I am using iTextSharp to fill in a PDF template. The data I am using is kept in a database and is HTML formatted. My problem is that when I load the AcroField with this text I get it to do the line breaks, but no bold nor italicizing . I have already attempted to use HtmlWorker , but all the examples online show it being used to convert HTML to a PDF but I am trying to set an AcroField in a PDF template. Any help would be appreciated. 回答1: After spending days looking through forums and

iTextSharp is producing a corrupt PDF

主宰稳场 提交于 2019-12-18 16:48:44
问题 The code snippet below returns a corrupt PDF document however if I return mergedDocument instead it always returns a valid PDF. mergedDocument is based on a PDF file i created using Word, whereas completed document is entirely programmatically generated. The code "works" in that it throws no exceptions. Why is iTextSharp creating a corrupt PDF? byte[] completedDocument = null; using (MemoryStream streamCompleted = new MemoryStream()) { using (Document document = new Document()) { PdfCopy copy

Add a page to PDF document using iTextSharp

有些话、适合烂在心里 提交于 2019-12-18 12:22:40
问题 I would like to add a page to an existing PDF document containing simple text. I have tried the following code that I found on the internet, but so far I haven't got it to work: PdfReader reader = new PdfReader("1.pdf"); Document document = new Document(reader.GetPageSize(1)); PdfCopy copier = new PdfCopy(doc, new FileStream("2.pdf", FileMode.Create)); for (int pageCounter = 1; pageCounter < reader.NumberOfPages + 1; pageCounter++) { //byte[] page = reader.GetPageContent(pageCounter); copier

how to get the particular paragraph in pdf file using iTextSharp in C#?

孤街醉人 提交于 2019-12-18 12:09:34
问题 I am using iTextSharp in my C# winform application.I want to get particular paragraph in PDF file. Is this possible in iTextSharp? 回答1: Yes and no. First the no. The PDF format doesn't have a concept of text structures such as paragraphs, sentences or even words, it just has runs of text. The fact that two runs of text are near to each other so that we think of them as structured is a human thing. When you see something that looks like a three line paragraph in a PDF, in reality the program

iTextsharp landscape document

只愿长相守 提交于 2019-12-18 11:51:11
问题 I am trying to create Landscape PDF using iTextSharp but It is still showing portrait. I am using following code with rotate: Document document = new Document(PageSize.A4, 0, 0, 150, 20); FileStream msReport = new FileStream(Server.MapPath("~/PDFS/") + "Sample1.pdf", FileMode.Create); try { // creation of the different writers PdfWriter writer = PdfWriter.GetInstance(document, msReport); document.Open(); PdfPTable PdfTable = new PdfPTable(1); PdfTable.SpacingBefore = 30f; PdfPCell PdfPCell =

How to add a form field to an existing pdf with itextsharp?

这一生的挚爱 提交于 2019-12-18 10:29:27
问题 How to add a form field to an existing pdf with itextsharp? I have an existing pdf document, I'd like to add form fields to it without creating a copy and writing out a new document. 回答1: After further review, the ruling on the field is overturned. Turns out if you form flatten the stamper the fields do not show on the resulting document (because they lack 'appearance' settings). BTW, form flattening prevents further edits of a form field. Now we can add appearance to the form, however, an

What is the PdfPTable.DefaultCell property used for?

别等时光非礼了梦想. 提交于 2019-12-18 09:49:28
问题 What is the DefaultCell property used for? The Java documentation for PdfPTable.getDefaultCell() reads: Gets the default PdfPCell that will be used as reference for all the addCell methods except addCell(PdfPCell) . I don't understand it. The documentation for the .NET library is lacking. The Java one is still documented but again not that well. I usually look up from the Java one because the two API's are symmetrical. But I still don't understand the meaning of this property. 回答1: When

iTextSharp Font interfering with common font

旧街凉风 提交于 2019-12-18 09:38:48
问题 I have included iTextSharp in my project to have an ability to create a PDF file. This is my code for this: Document document = new Document(iTextSharp.text.PageSize.LETTER,20,20,42,35); PdfWriter writer = PdfWriter.GetInstance(document,newFileStream("Test.pdf",FileMode.Create)); document.Open(); Paragraph paragraph = new Paragraph("Test"); document.Add(paragraph); document.Close(); And now the error comes up saying: Font is an ambiguous reference between System.Drawing.Font and iTextSharp

PdfTable: last cell is not visible

不想你离开。 提交于 2019-12-18 09:18:51
问题 I use PdfPTable in the following way var myTable = new PdfPTable( 3 ); foreach(var nextString in myStrings) { var nextCell = new PdfPCell( new Phrase( nextString, smallFont ) ); nextCell.Border = Rectangle.NO_BORDER; nextCell.AddCell(nextCell); } pdfDocument.Add(myTable); All is perfect then total cell count multiply the number of columns (3). But when I wanted to create a table with 3 columns but 4 cells - last row is not visible. How to solve such issue? itextsharp 5.3.3.0 回答1: To solve

iTextSharp Image Extraction with Transparency

末鹿安然 提交于 2019-12-18 09:14:42
问题 I am using iTextSharp and trying to extract images with transparency from a PDF. When I extract the image the transparency becomes solid black and is lost. I have found multiple examples of image extraction but all of them seem to have the same issue. The code that I am using is below Another example is from itextpdf.com/examples/iia.php?id=284. This example includes images in the "results" section at the top. If you click Img7.png you will see the black border in the image, however at the