itextsharp

Define foreground color of a itextsharp table cell

别来无恙 提交于 2019-12-07 09:46:40
问题 I have a iTextSharp.text.Table and tried to change the foreground text color. But there is no method on the Cell object to define the color. Does anybody knows, where I can adjust the color? 回答1: Try the following var FontColour = new BaseColor(31, 73, 125); var MyFont = FontFactory.GetFont("Times New Roman", 11, FontColour ); table.AddCell(new Paragraph("My Text", MyFont)); 回答2: LnDCobras answerworked well. My final solution is the following: Font font = new Font(Font.HELVETICA, 11, new

Read certificate from pdf

限于喜欢 提交于 2019-12-07 09:25:08
问题 I'm using ITextSharp in order to read certificate informations from digitally signed pdf document. The ITextSharp.Text.Pdf.PdfPKCS7 class exposes three properties: Certificates (as list) SignCertificate (as single object) SignCertificateChain (as list) How can I combine these three properties in order to achieve all info about a single certificate? I'd be able to show all certificate path (all nested certificates). 回答1: Certificates gives you the list in no particular order, including

PDF Add Text and Flatten

Deadly 提交于 2019-12-07 08:32:25
I'm developing a web application that displays PDFs and allows users to order copies of the documents. We want to add text, such as "unpaid" or "sample", on the fly when the PDF is displayed. I have accomplished this using itextsharp. However, the page images are easily separated from the watermark text and extracted using a variety of freeware programs. How can I add the watermark to the pages in the PDF, but flatten the page images and watermark together so that the watermark becomes part of the pdf page image, thereby preventing the watermark from being removed (unless the person wants to

iTextSharp - Use Colspan with PdfPRow

六月ゝ 毕业季﹏ 提交于 2019-12-07 06:43:04
问题 I am able to create multiple rows if they contain the same number of columns: table = new PdfPTable(3); var firstRowCell1 = new PdfPCell( new Phrase ("Row 1 - Column 1")); var firstRowCell2 = new PdfPCell( new Phrase ("Row 2 - Column 2")); var firstRowCell3 = new PdfPCell( new Phrase ("Row 3 - Column 3")); PdfPCell[] row1Cells = { firstRowCell1, firstLineRow2, firstRowCell3 }; var row1 = new PdfPRow(row1Cells); table.Rows.Add(row1); var nextRowCell1 = new PdfPCell( new Phrase ("Row 2 - Column

opening PDF document from memory

不羁的心 提交于 2019-12-07 04:03:51
问题 It is possible to create a PDF document in memory with iTextSharp that gives the user a choice to "open" or "save"?, and if it opens then it opens in a browser window. At the moment the only I have save it to disk. EDIT: ok I've got it sussed. I did end up having to write the file to a folder, but it is only temporary as gets overwritten every time. Here is the solution for what it's worth: private void GeneratePDF() { var doc1 = new Document(); string path = Server.MapPath("~/pdfs/"); string

iTextSharp ShowTextAligned Anchor Point

夙愿已清 提交于 2019-12-07 03:26:55
问题 I'm currently successfully adding text to a PDF using iTextSharp's ShowTextAligned method. The method looks like this (C#): public void ShowTextAligned( int alignment, string text, float x, float y, float rotation ) However, it is unclear where the anchor point is for the text we're making. We provide x and y , but does these correspond to the upper left corner of the text rectangle, the lower left corner, or something else? Also is this impacted by line spacing? I looked at the documentation

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

你说的曾经没有我的故事 提交于 2019-12-07 01:51:27
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. 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: public void createPdf(String dest) throws IOException, DocumentException { Document document = new Document();

iTextSharp “The document has no pages.”

陌路散爱 提交于 2019-12-07 00:42:22
问题 I'm using iTextSharp to update A PDF's file properties: FileStream fs = File.Open(@"C:\Developer\C#Projects\BylawSearch\0001.pdf", FileMode.Open); Document document = new Document(); PdfWriter writer = PdfWriter.GetInstance(document, fs); document.Open(); document.AddSubject("Blah"); document.AddTitle("Blah blah"); document.AddKeywords("Blah blah blah"); document.Close(); I'm getting a "The document has no pages." error from iTextSharp. Any help appreciated. 回答1: You haven't added any

How do I check a check box in a pdf template

谁都会走 提交于 2019-12-06 21:19:25
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? 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

How to detect newline from PDF using iTextSharp [closed]

主宰稳场 提交于 2019-12-06 16:53:55
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I have used getbaseline[vector.I2] for calculating subscript and superscript. By doing this I'm not able to extract newline from PDF.