itextsharp

Watermark in itextsharp is not displaying properly

南楼画角 提交于 2019-12-08 08:14:36
问题 I'm using iTextSharp to populate the data to PDF Templates, which is created in OpenOffice. it populating fine, I'm getting proper PDF, Watermark is not displaying properly. below is my code: public void addWaterMark(PdfStamper stamper, int pageNumber, Watermark watermark) { List<WatermarkField> watermarkFields = watermark.getWatermarkFieldAsReference(); for (WatermarkField watermarkField : watermarkFields) { // setting font and font size for the watermark text Font FONT = new Font(FontFamily

How do I check a check box in a pdf template

浪尽此生 提交于 2019-12-08 07:30:41
问题 I would like to use data from a form and add to my pdf template. I use the following for textfields... PdfStamper formFiller = new PdfStamper(reader, ms); AcroFields formFields = formFiller.AcroFields; formFields.SetField("Name", formData.Name); How do I check a checkbox? 回答1: I think this should do the trick: formFields.SetField("checkBoxId", "Yes"); 来源: https://stackoverflow.com/questions/6253211/how-do-i-check-a-check-box-in-a-pdf-template

iTextSharp - Is it possible to set a different alignment in the same cell for text

ぐ巨炮叔叔 提交于 2019-12-08 06:02:18
问题 In one cell and on the same line, I must add two text (name and date). The first snippet of text must be on the left page side, the second one on the right, and everything must be in one line. I've tried used Paragraph s, Chunk s and Phrase s but I don't know how to do it. 回答1: If you want to separate two pieces of text in the same Phrase or Paragraph , you have to create a Chunk I often refer to as glue : Chunk glue = new Chunk(new VerticalPositionMark()); You can use this glue like this:

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

跟風遠走 提交于 2019-12-08 05:59:33
问题 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 回答1: The most common use of XMP in the context of PDF is when you add an XMP stream for the whole document that is referred to from the root dictionary of the PDF (aka the Catalog). However, if you consult the PDF specification, you notice that XMP can be used in the context of many other objects inside a PDF, the page level

How do I embed a source PDF onto an existing page in a PDF?

戏子无情 提交于 2019-12-08 05:48:01
问题 I need to programmatically embed an existing PDF (a small graphic) onto a specfic page on an existing PDF. Using iTextSharp I've been able to add a new page containing this embedded PDF, but what need is to modify an existing page by adding this graphic. Is this possible using iTextSharp or any other PDF-generation libarary? 回答1: I tend to do this sort of thing using Context, which is a Tex-based layout tool that in integrated into the pdftex Tex/Metapost engine. There's a learning curve

Streaming a pdf to the user's browser using itextsharp

[亡魂溺海] 提交于 2019-12-08 05:43:57
问题 I'm trying to follow this article here: http://www.4guysfromrolla.com/articles/030911-1.aspx I have this method in Services.asmx: [WebMethod] public void CreatePdf() { // Create a Document object var document = new Document(PageSize.A4, 50, 50, 25, 25); // Create a new PdfWriter object, specifying the output stream var output = new MemoryStream(); var writer = PdfWriter.GetInstance(document, output); // Open the Document for writing document.Open(); // Create a new Paragraph object with the

Generate table of content using itextsharp

断了今生、忘了曾经 提交于 2019-12-08 05:42:02
问题 What I am doing is to generate a pdf booklet from database. I need go generate a content table with page numbers. E.g there are two chapters with page number like: ============================= Content table Chapter 1 ----- 3 Chapter 2 ----- 17 ============================= The text "Chapter 1 ----- " is normal paragraph. But the page number "3" has to be produced using PdfTemplate because it can only be known later. But the pdfTemplate is absolutely positioned. How can I know where to

scaling images in iTextSharp

丶灬走出姿态 提交于 2019-12-08 05:40:13
问题 I'm having some trouble scaling an image that i am inserting. I must be doing something wrong, because it does not change at all, no matter what i do. This is the code i have at the moment, but it does not seem to work. The image gets inserted fine, it just doesn't scale, no matter what values i try. Any obvious things i am doing wrong? Any common things that people do wrong? I am working in C#, but i assume the syntax is the same (more or less) in all languages. Image imgSpine = Image

Adding annotations with iTextSharp to rotated crop box

守給你的承諾、 提交于 2019-12-08 05:16:07
问题 So, I'm trying to simply add a text annotation to a pdf at the top left corner of a pdf document. Current code is like this: public static byte[] StampPDFDocument(byte[] pdf, string stampString) { using (var ms = new MemoryStream()) { var reader = new iTextSharp.text.pdf.PdfReader(pdf); var stamper = new iTextSharp.text.pdf.PdfStamper(reader, ms); var box = reader.GetCropBox(1); var left = box.Left; var top = box.Top; iTextSharp.text.Rectangle newRectangle = new iTextSharp.text.Rectangle(left

How To programmatically detect XFA (Adobe XML Forms Architecture) dynamic PDF

泄露秘密 提交于 2019-12-08 05:02:57
问题 I have a system that converts pdf to tif. Basically it's a program written in csharp that uses iTextSharp to get metadata about the pdf and pdf2tif (http://pdftotif.sourceforge.net/) to convert to the file. I've noticed a number of pdf's do not convert correctly. In Acrobat and Foxit they open as multi page forms but in any other viewer (Ghostscript...) they open as 1 page documents with the message "To view the full contents of this document, you need a later version of the PDF viewer. You