itext7

Calculate the width of a table in iText 7

泄露秘密 提交于 2019-12-25 19:12:30
问题 I use iText 7 with html2pdf 2.1.2 version and try to convert HTML file to PDF. I use HtmlConverter#convertToElements to process an html file. Then I would like to calculate the width of one of the elements (a table in particular). I have tried to implement custom TagWorker class, but i get table only after it's filled. Also tried convertToDocument and some other ways but with no success. Is there a way to get a table width at run time? Thanks in advance. 回答1: The bad news: in general, it's

Itext7 - Place Text at specific position

与世无争的帅哥 提交于 2019-12-25 11:40:28
问题 ColumnText ct = new ColumnText(writer.getDirectContent()); ct.setSimpleColumn(left,bottom,right,top); ct.setText(new Phrase("String")); ct.go(); This how we were doing in Itext 5 . But how can we place text on specific position on page . I have multiple text to place on page along with images . Thanks 回答1: Try this: Paragraph p = new Paragraph("test"); p.setFixedPosition(100, 800, 200); document.add(p); It should be that simple. In this example, x = 100, y = 800, and 200 is the width. For an

Page break in Itext7 in method htmltopdf

你。 提交于 2019-12-25 07:41:39
问题 I have a problem with generating a page break in the Itext7. Environnement: Visual Studio 2017 C# Version itext7 core: 7.0.2.2 [Trial License atm] Version itext7.pdfhtml: 1.0.0.2 Flow to generate my PDF: Use of RazorEngine to parse my model with my cshtml Create a doc and writer Use of iText.Html2pdf.HtmlConverter.ConvertToPdf(msHtml, writer); => mshtml is the memory of my generated html in step 1 Stackoverflow Questions i've tested Suggested solution 1: is for php... Page break in Html2Pdf =

ITEXT7 TABLE BORDERLESS (No Border)

混江龙づ霸主 提交于 2019-12-25 07:35:53
问题 This code below does not work. Table table = new Table(2); table.setBorder(Border.NO_BORDER); I am new to itext7 and all I wanted is to have my table borderless. Like how to do it? 回答1: The table itself is by default not responsible for borders in iText7, the cells are. You need to set every cell to be borderless if you want a borderless table (or set the outer cells to have no border on the edge if you still want inside borders). Cell cell = new Cell(); cell.add("contents go here"); cell

itext7 barcodes in footer

随声附和 提交于 2019-12-25 03:45:16
问题 I'm working on a rather complex solution that takes an html-like input and converts it to a pdf. One of the many items that I'm trying to solve for is adding barcodes (all types, 3 of 9, PDF417, and qr code) to the footer of documents. A couple details that give me pause on how to implement: Bar code will contain current page number Bar code will contain total page count Bar code will be inside other itext elements (like a table cell or paragraph) and (in the final solution) needs to be

How to retrieve the PdfStampAnnotation rotation

落花浮王杯 提交于 2019-12-25 01:33:07
问题 Referring to How to retrieve the image of a PdfStampAnnotation, how to retrieve the rotation of an stamp annotation ? I create a document, put a stamp1, turn the page and add another stamp2. The document is ok (stamp1 image is rotated and stamp2 is not) but the extracted the images are exactly the same (same orientation). I can get the page rotation with page.getRotation() // 90 And if I'm trying to get stamps (images) orientation // I expect to get 0 but get 90 stamp1.getPdfObject()

How add Multiple links in same PDF using iText

与世无争的帅哥 提交于 2019-12-25 01:27:58
问题 I'm using the Link and Destination tags of iText 7.0.5 to create the links while generating the pdf doc. When there is only one Link and Destination, its working as expected. But when I'm adding multiple links and destination, its not working as expected. For example there are three links and 3 destinations and each link mapped to different destination. If I click on third link in PDF it will be redirected to third destination, but if I click on first and second links, those are also

canvas incorrectly draws heights cell in table itext7

China☆狼群 提交于 2019-12-25 01:15:20
问题 i draw table as it: Draw custom borders for table with more flexibility in itext7 But i But with big data the table is badly drawn height cell in table. PdfDocument pdfDoc = new PdfDocument(new PdfWriter("_testPd/dashed_underline.pdf")); Document doc = new Document(pdfDoc, PageSize.A5); Table table = new Table(3).useAllAvailableWidth().setFixedLayout(); table.addCell("Highway System that runs east from the Indiana state line near Lake Michigan through the southern Lower Peninsula to Detroit,

How to retrieve the image of a PdfStampAnnotation

让人想犯罪 __ 提交于 2019-12-25 01:05:02
问题 I created a pdf using the following example: https://developers.itextpdf.com/examples/actions-and-annotations/clone-creating-and-adding-annotations#2260-addstamp.java @Category(SampleTest.class) public class AddStamp extends GenericTest { public static final String DEST = "./target/test/resources/sandbox/annotations/add_stamp.pdf"; public static final String IMG = "./src/test/resources/img/itext.png"; public static final String SRC = "./src/test/resources/pdfs/hello.pdf"; public static void

iText PDFSweep RegexBasedCleanupStrategy not work in some case

…衆ロ難τιáo~ 提交于 2019-12-25 00:59:53
问题 I'm trying to use iText PDFSweep RegexBasedCleanupStrategy to redact some words from pdf, however I only want to redact the word but not appear in other word, eg. I want to redact "al" as single word, but I don't want to redact the "al" in "mineral". So I add the word boundary("\b") in the Regex as parameter to RegexBasedCleanupStrategy, new RegexBasedCleanupStrategy("\\bal\\b") however the pdfAutoSweep.cleanUp not work if the word is at the end of line. 回答1: In short The cause of this issue