itext7

Draw custom borders for table spanning across more than one page in itext7

主宰稳场 提交于 2019-12-08 14:44:06
问题 If I do like it: How during work itext find out coordinates text? Everything works. But if i create table more one page, nothing is drawn: PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest)); Document doc = new Document(pdfDoc); doc.add(new Paragraph("Table event")); Table table = new Table(UnitValue.createPercentArray(3)).useAllAvailableWidth(); table.setNextRenderer(new DottedLineTableRenderer(table, new Table.RowRange(0, 0))); table.addCell(new Cell().add(new Paragraph("test\ntest

If I enable Smart Mode, a NullReferenceException is thrown

送分小仙女□ 提交于 2019-12-08 13:42:57
问题 I'm trying to merge a group of PDFs together and ensure that they are compressed well, and that there are no duplicate resources. However, in my code, if I call SetSmartMode(true) on my writer, the first write to it will always result in a NullReferenceException. Here is my (vb.net) code: Private Function CombinePdfBatch(pdfMetaData As IEnumerable(Of QuestDataSet.MetaDataRow), batchNumber As Integer, fileNamePrefix As String, outputDir As String) As String Dim outputFileName As String = Path

iText7 setValue method not working

江枫思渺然 提交于 2019-12-08 13:15:01
问题 I am trying to add a form to a pdf using iText 7 . I keep getting an error when trying to set the value of the field. I haven't been able to find information from the documentation of the addKid() method. Does anyone know how to get around this error? Here's a sample of the code I'm using: PdfTextFormField confField = PdfFormField.createText(pdf); confField.setFieldName(fieldName); PdfWidgetAnnotation confCoverAnnot = new PdfWidgetAnnotation(new Rectangle(x, y, width, height));

IText7- How can i correctly override GetStrategy method on iText7 for .Net (C#) looks alike GetFont method on itextSharp (aka itext 5)?

筅森魡賤 提交于 2019-12-08 09:25:36
问题 In itextSharp (aka itext5), we can custom font throughout the overriding GetFont method on FontFactoryImp (looks like as code sample below), which means that each time the parser XHTML to PDF engine loop the tag containing font(associate with color, size) will get font correctly. While in itext7, I can't find out a way to override GetFont(), So I have to include 2 fonts(font normal and bold) as well. This way make my pdf file increase double size. That's so terrible. This is the code that I

Get the page number from document outline (bookmarks)

被刻印的时光 ゝ 提交于 2019-12-08 09:03:15
问题 I am using the itext7 library to manipulate some existing PDFs. For some reason, I am not able to get the page number from the outline. I guess I somehow should get it from the PdfDestination but cannot find any matching methods in any of its subclasses. PdfDocument pdfDoc = new PdfDocument(new PdfReader("example.pdf")); var root = pdfDoc.GetOutlines(false); foreach (PdfOutline ol in root.GetAllChildren()) { Console.WriteLine(ol.GetTitle()); PdfDestination d = ol.GetDestination(); // how to

Itextsharp 7 - Scaled and Centered Image as watermark

依然范特西╮ 提交于 2019-12-08 05:47:37
问题 I started using itextsharp 7 a few days ago, i used to work with itextsharp 5 for years . I don't manage to add a scaled image at the center of the page as watermark with itext7. My code with itextsharp 5 : using (PdfStamper pdfStamper = new PdfStamper(pdfReader, memoryStream)) { for (int pageIndex = 1; pageIndex <= pdfReader.NumberOfPages; pageIndex++) { pdfStamper.FormFlattening = false; iTextSharp.text.Rectangle pageRectangle = pdfReader.GetPageSizeWithRotation(pageIndex); PdfContentByte

How to get font size of form field on iText7?

五迷三道 提交于 2019-12-08 05:11:15
问题 How can I get font size of a PDF form field on iText7? On iText5, I could do it as this: PdfReader reader = new PdfReader(SRC); PdfStamper stamper = new PdfStamper(reader, outputStream); AcroFields fields = stamper.getAcroFields(); AcroFields.Item item = fields.getFieldItem(FIELDNAME); PdfDictionary merged = item.getMerged(0); TextField textField = new TextField(null, null, null); fields.decodeGenericDictionary(merged, textField); float fontSize = textField.getFontSize(); I could not find how

How to add a check box in a PDF file using iText 7?

ぃ、小莉子 提交于 2019-12-08 04:40:55
问题 How can I add a checkobox into a Pdf file like it is done in this question, but using iText 7? I want the result to look like this: 回答1: Adapting Bruno's answer to iText 7: Paragraph p = new Paragraph("This is a tick box character: "); PdfFont zapfdingbats = PdfFontFactory.createFont(FontConstants.ZAPFDINGBATS); Text chunk = new Text("4").setFont(zapfdingbats).setFontSize(14); p.add(chunk); document.add(p); 回答2: You already know how to check a check box field in an interactive PDF. You now

iText7 508 Table Summary

本秂侑毒 提交于 2019-12-08 02:39:44
问题 We are creating a large table using iText 7 we are almost fully 508 complaint however we are missing the table summary rule. Is there a way to add the table summary at creation time using iText 7? I have attached a picture of what I am looking for. 回答1: It is possible to add AccessibilityProperties to the Table object itself. The Summary needs to be added through a PdfDictionary PdfDictionary attr = new PdfDictionary(); attr.put(new PdfName("Summary"), new PdfString("Info about the table"));

Signing using iText, Adobe Reader reports “Signature was created using Not available.”

纵饮孤独 提交于 2019-12-08 00:48:04
问题 I am successfully signing documents using iText. However, any time that I check the "Advanced Signature Properties" in Adobe Reader I see that the "Signature was created using Not available." My question is, how can I use iText update this piece of information to then display properly in Adobe Reader or any other PDF reader? EDIT #1: An answer suggested using the PdfSignatureAppearance class's setSignatureCreator(String signatureCreator) (API and Source). This was not successful in updating