itextsharp

Code isn't drawing a horizontal line in my PDF

扶醉桌前 提交于 2020-02-21 12:53:18
问题 I'm trying to add a horizontal line on top to divide the header text from the actual values in my pdf file: Here's my code: public class StudentList { public void PrintStudentList(int gradeParaleloID) { StudentRepository repo = new StudentRepository(); var students = repo.FindAllStudents() .Where(s => s.IDGradeParalelo == gradeParaleloID); try { Document document = new Document(PageSize.LETTER); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(Environment.GetFolderPath

How to fix “Compression JPEG is only supported with a single strip” issue

谁都会走 提交于 2020-02-08 07:43:06
问题 I'm working on a project in which I have to create a PDF file using itextsharp . However, I get the following error: System.IO.IOException: Compression JPEG is only supported with a single strip. This image has 229 strips. at iTextSharp.text.pdf.codec.TiffImage.GetTiffImageColor(TIFFDirectory dir, RandomAccessFileOrArray s) at iTextSharp.text.pdf.codec.TiffImage.GetTiffImage(RandomAccessFileOrArray s, Int32 page, Boolean direct) at iTextSharp.text.Image.GetInstance(Uri url) at iTextSharp.text

How to fix “Compression JPEG is only supported with a single strip” issue

半世苍凉 提交于 2020-02-08 07:42:12
问题 I'm working on a project in which I have to create a PDF file using itextsharp . However, I get the following error: System.IO.IOException: Compression JPEG is only supported with a single strip. This image has 229 strips. at iTextSharp.text.pdf.codec.TiffImage.GetTiffImageColor(TIFFDirectory dir, RandomAccessFileOrArray s) at iTextSharp.text.pdf.codec.TiffImage.GetTiffImage(RandomAccessFileOrArray s, Int32 page, Boolean direct) at iTextSharp.text.Image.GetInstance(Uri url) at iTextSharp.text

iTextSharp - Write HTML to pdf document

社会主义新天地 提交于 2020-02-07 17:13:07
问题 I've tried my damnedest to get this to work, but all info on the web regarding iTextSharp seems to be out dated. (I'm using version 5.5.3) I have a simple string variable containing the HTML that I want rendered to a PDF. There are a few examples using XMLWorker / XMLWorkerHelper, but these classes no longer seem to be part of iTextSharp. HTMLWorker is still available, but the moans about being obsolete. (And also doesn't work) This is what I have so far: public byte[] RenderPdf() {

iTextSharp comparing 2 PDFs for equality

我的未来我决定 提交于 2020-01-30 06:45:30
问题 I am generating and storing PDFs in a database. The pdf data is stored in a text field using Convert.ToBase64String(pdf.ByteArray) If I generate the same exact PDF that already exists in the database, and compare the 2 base64strings, they are not the same. A big portion is the same, but it appears about 5-10% of the text is different each time. What would make 2 pdfs different if both were generated using the same method? This is a problem because I can't tell if the PDF was modified since it

Insert an Image in PDF using ITextSharp

天涯浪子 提交于 2020-01-30 05:50:06
问题 I have to insert a an image in a pdf. That is, wherever I see a text 'Signature', I have to insert an signature image there . I can do by saying absolute positions . But, I am looking for how to find the position of the word 'Signature' in the pdf and insert the image. Appreciate ur help! This is the working code: using (Stream inputImageStream = new FileStream(@"C:\signature.jpeg", FileMode.Open, FileAccess.Read, FileShare.Read)) using (Stream outputPdfStream = new FileStream(@"C:\test

Encrypt PDF document using iTextSharp

佐手、 提交于 2020-01-26 03:23:06
问题 I want to make my PDF document protected by not allowing fill in and copy from it. I am using iTextSharp for this. I have following code: PdfReader reader = new PdfReader(document, System.Text.Encoding.UTF8.GetBytes(PASSWORD)); using (MemoryStream ms = new MemoryStream()) { using (PdfStamper stamper = new PdfStamper(reader, ms)) { stamper.SetEncryption( null, Encoding.ASCII.GetBytes(PASSWORD), PdfWriter.ALLOW_PRINTING, PdfWriter.ENCRYPTION_AES_128); } } reader.Close(); When the document is

Copying fields in iTextSharp 5.4.5.0

半世苍凉 提交于 2020-01-25 14:38:05
问题 I was under the impression that it is now possible to copy AcroFields using PdfCopy. In the release notes for iText 5.4.4.0 this is listed as possible now. However, when I try to do so it appears all the annotations (I think I am using that term correctly, still fairly new to iText...) for the fields are stripped out. It looks like the fields are there (meaning I can see the blue boxes that indicate an editable field), but they are not editable. If I try to bring the PDF up in Acrobat I get a

How to tile a pdf to multiple pages with a border

走远了吗. 提交于 2020-01-25 12:05:28
问题 Using itextsharp I am trying to tile a single (large) page pdf document (called import document) into a new document where this page is split into several DIN A4 pages (called output document). But I want to draw a border around the DIN A4 pages of the output and only add a smaller than A4 size part of the import document. For clarification please see the picture: On the left is the import doc in size A3 which is like two A4 pages side-by-side (black dotted line). This shall be split to A4

How can you eliminate white-space in multiple columns using iTextSharp?

╄→尐↘猪︶ㄣ 提交于 2020-01-25 11:51:26
问题 I'd like to add a Paragraph of text to pages in 2 columns. I understand that MultiColumnText has been eliminated. I know I can create column 1, write to it, and if there is more text create column 2 and write to it. If there is still more text, go to the next page and repeat. However I always end up with either: a long chunk of text orphaned in the left column. a full left column and partially used right column. How can I format my content in 2 columns while reducing white space, such as