itext

Converting HTML to PDF using iText

橙三吉。 提交于 2020-06-09 05:37:38
问题 I am posting this question because many developers ask more or less the same question in different forms. I will answer this question myself (I am the Founder/CTO of iText Group), so that it can be a "Wiki-answer." If the Stack Overflow "documentation" feature still existed, this would have been a good candidate for a documentation topic. The source file: I am trying to convert the following HTML file to PDF: <html> <head> <title>Colossal (movie)</title> <style> .poster { width: 120px;float:

How to place paragraphs in specific place using iTextSharp

瘦欲@ 提交于 2020-05-28 03:38:17
问题 How do I place text at a specific location on the pdf? I did a little bit of searching but didn't find anything too good. I have document.Add(new Paragraph("Date:" + DateTime.Now)); and I wanted to place that on a specific area on the pdf file. My code: private void savePDF_Click(object sender, EventArgs e) { FileStream fileStream = new FileStream(nameTxtB.Text + "Repair.pdf", FileMode.Create, FileAccess.Write, FileShare.None); Document document = new Document(); document.Open(); iTextSharp

How to place paragraphs in specific place using iTextSharp

亡梦爱人 提交于 2020-05-28 03:35:58
问题 How do I place text at a specific location on the pdf? I did a little bit of searching but didn't find anything too good. I have document.Add(new Paragraph("Date:" + DateTime.Now)); and I wanted to place that on a specific area on the pdf file. My code: private void savePDF_Click(object sender, EventArgs e) { FileStream fileStream = new FileStream(nameTxtB.Text + "Repair.pdf", FileMode.Create, FileAccess.Write, FileShare.None); Document document = new Document(); document.Open(); iTextSharp

How to solve pdf header signature not found error?

丶灬走出姿态 提交于 2020-05-24 21:22:30
问题 I'm using iText in my java program for editing an existing pdf.The generated pdf could not open and it shows pdf header signature not found error.I'm using both my input and output file in a same name. private static String INPUTFILE = "/sample.pdf"; private static String OUTPUTFILE = "/sample.pdf"; public static void main(String[] args) throws DocumentException, IOException { Document doc = new Document(); PdfWriter writer = PdfWriter.getInstance(doc,new FileOutputStream(OUTPUTFILE)); doc

How to automate PDF form-filling in Java

痞子三分冷 提交于 2020-05-24 08:23:01
问题 I am doing some "pro bono" development for a food pantry near where I live. They are inundated with forms and paperwork, and I would like to develop a system that simply reads data from their MySQL server (which I set up for them on a previous project) and feeds data into PDF versions of all the forms they are required to fill out. This will help them out enormously and save them a lot of time, as well as get rid of a lot of human errors that are made when filling out these forms. Not knowing

How to automate PDF form-filling in Java

混江龙づ霸主 提交于 2020-05-24 08:22:20
问题 I am doing some "pro bono" development for a food pantry near where I live. They are inundated with forms and paperwork, and I would like to develop a system that simply reads data from their MySQL server (which I set up for them on a previous project) and feeds data into PDF versions of all the forms they are required to fill out. This will help them out enormously and save them a lot of time, as well as get rid of a lot of human errors that are made when filling out these forms. Not knowing

Cannot create iTextSharp PDF from inside the Controller, but works fine when the same Action is called from View

有些话、适合烂在心里 提交于 2020-05-17 07:28:37
问题 In my controller, I have an action like this to generate a PDF using iTextSharp: public FileResult Print(int id) { string fileName = "something.pdf"; Document document = new Document(PageSize.A4, 18, 18, 36, 36); MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); HeaderFooter.Title = "Something"; HeaderFooter.Box = "box"; HeaderFooter tevent = new HeaderFooter(); writer.SetBoxSize(HeaderFooter.Box, new Rectangle(18, 72, 577, 770)); writer

Cannot create iTextSharp PDF from inside the Controller, but works fine when the same Action is called from View

与世无争的帅哥 提交于 2020-05-17 07:28:26
问题 In my controller, I have an action like this to generate a PDF using iTextSharp: public FileResult Print(int id) { string fileName = "something.pdf"; Document document = new Document(PageSize.A4, 18, 18, 36, 36); MemoryStream stream = new MemoryStream(); PdfWriter writer = PdfWriter.GetInstance(document, stream); HeaderFooter.Title = "Something"; HeaderFooter.Box = "box"; HeaderFooter tevent = new HeaderFooter(); writer.SetBoxSize(HeaderFooter.Box, new Rectangle(18, 72, 577, 770)); writer

Adjust width for image in Itextsharp while adding digital signature in GRAPHIC_AND_DESCRIPTION mode C# .net

試著忘記壹切 提交于 2020-05-17 06:27:08
问题 I want to adjust width of added Image along with description while signing pdf using itextsharp library C#. My code below regarding setting image and descreption in signature: var pdfStamper = PdfStamper.CreateSignature(reader, os, '\0', null, true); var signatureAppearance = pdfStamper.SignatureAppearance; var imageData = Path.Combine(_env.WebRootPath, ImagePathere); var image = Image.GetInstance(imageData); signatureAppearance.SignatureGraphic = image; BaseFont bf = BaseFont.CreateFont

How to print two parallel tables side by side in iText7, rendering them on one page at at a time and then adding new page

风格不统一 提交于 2020-05-17 03:00:55
问题 I want to add two parallel tables (tables contain content more than one page) side by side in iText7. Rendering should be done as: Render two tables on page 1, then add new page. Then render remaining part of tables on second page. If they still overflows add another page. Add remaining part of table on page 3 and so on. Here is the approach that is used in iText5 for this scenario. Main code: ColumnText[] columns = new ColumnText[2]; columns[0]=column1; columns[1]=column3; while (addColumns