itext

Text extraction from a PDF using iText7. How to improve its performance?

非 Y 不嫁゛ 提交于 2019-12-22 01:04:53
问题 Currently, I use this code to extract text from a Rectangle (area). public static class ReaderExtensions { public static string ExtractText(this PdfPage page, Rectangle rect) { var filter = new IEventFilter[1]; filter[0] = new TextRegionEventFilter(rect); var filteredTextEventListener = new FilteredTextEventListener(new LocationTextExtractionStrategy(), filter); var str = PdfTextExtractor.GetTextFromPage(page, filteredTextEventListener); return str; } } It works, but I don't know if it's the

Bad border of image iTextSharp

六眼飞鱼酱① 提交于 2019-12-22 01:04:32
问题 I use iTextSharp to add images to a pdf-document. When I add border for image I see one-pixel part of Image (look at the screenshot): It is visible when I use white color for the border. How I can remove it? My code iTextSharp.text.Rectangle rec = new iTextSharp.text.Rectangle(PageSize.A4); iTextSharp.text.Document document = new iTextSharp.text.Document(rec); using (var writer = PdfWriter.GetInstance(document, new FileStream("file.pdf", FileMode.Create))) { document.Open(); iTextSharp.text

Set 8 1/2“ x 12” itext page size [duplicate]

假如想象 提交于 2019-12-22 00:59:42
问题 This question already has answers here : How to set the page size to Envelope size with Landscape orientation? (2 answers) Closed 3 years ago . I am using itext PDF, and I need to set PDF document size as German Std. Fanfold(8 1/2" x 12"),I don't know how set Inches In Itext document. // Now I can set paper size as A4 but i need to set 8 1/2" x 12" or German Std. Fanfold size document(name: fileName,pageSize: PageSize.A4,leftMargin:8, rightMargin:8, topMargin:8, bottomMargin:3) Thanks in

Arabic caracters in html to pdf using iText

末鹿安然 提交于 2019-12-22 00:29:04
问题 I've gone through avery iText topic related to arabic caracters on stackoverflow already, but didn't find an answer for this one. I need to convert an html file in to pdf, but this html contains both english and arabic caracters. Displaying the html in Notepadd++ or in any browser, there is no problem, I can see arabic caracters properly, but when I use the following program to convert into pdf, I can't figure out a way to display arabic caracters, I only get "?" instead : import java.io

iText - PdfPTable RowSpan using mytable.writeSelectedRows

巧了我就是萌 提交于 2019-12-21 23:59:52
问题 I'm using iText 5.1.3, and I want to add a header to my Pdf Document. I used the known solution posted here: http://itextpdf.com/examples/iia.php?id=104 This solution used the PdfPageEventHelper class, and overridden the method onEndPage() to add the Header exactly after finishing every page. The example provided in the link above works fine as it adds a table as the Header of the document. I'm trying to do exactly the same with 1 difference, that I want some cells in that table to have

Image in between a paragraph Using iText

自古美人都是妖i 提交于 2019-12-21 20:46:38
问题 I am using iText to generate my custom .pdf document. I tried a lot but i am not able to do get a desired design of my text which includes an image. I need an output just like shown below: I have tried Chunk class and Paragraph class but i am not able to get the desired. Any ideas? 回答1: You have (at least) two options: Use image.setAlignment(Image.LEFT | Image.TEXTWRAP); and add the image to the document (not to a Chunk or Paragraph ). This will add the image to the left and wrap the other

Verify if a PDF is digitally signed with iText

青春壹個敷衍的年華 提交于 2019-12-21 19:43:17
问题 As the title says I want to know if a given PDF file is already digitally signed. I used iText to sign it but I'm not able to know if it is already signed to eventually resign it or perform other actions. Is there a way to do it simply (possibly using iText)? 回答1: Using iText: PdfReader reader = new PdfReader(...); AcroFields acroFields = reader.getAcroFields(); List<String> signatureNames = acroFields.getSignatureNames(); Now signatureNames contains the names of all reachable signature

iText 5.5.3 PDFPCell : long text doesn't fit corrctly in cell (wrap text incorrectly)

左心房为你撑大大i 提交于 2019-12-21 17:44:30
问题 i am trying to create a Persian PDF containing tables and i want to write in it. when my string is long it doesn't fit the cell correctly. feels like String fills the cell upside down!... i mean for example when i want to write "hello my friend . what's up?" in the cell the output is like this: | what's up? | | my friend | | hello | but of course in Persian (it's Ok in English) here i attached the code by the way private LanguageProcessor al = new ArabicLigaturizer(); cell = new PdfPCell(new

itextsharp HTMLWorker [deprecated]

北城以北 提交于 2019-12-21 12:22:17
问题 I have using itextsharp dll(v5.5.9.0) for generating a PDF from Html in Asp.net Mvc. In this, I am using a class HTMLWorker . I get a result that matches my requirement. It's working fine now. But it shows as [deprecated] . In the future, will it be working/supported or not? (or can I move to xmlworker?) 回答1: The HTMLWorker class is deprecated. It was started as a personal project to parse small HTML snippets. It was written without a clear design. It needed to serve the purpose of an

iText direct Printing

非 Y 不嫁゛ 提交于 2019-12-21 06:09:02
问题 I am using iText to generate a pdf and write it to the file system as the following: private void createPDF() throws Exception{ com.itextpdf.text.Document doc = new com.itextpdf.text.Document(); PdfWriter docWriter = null; path = "C:\\PATH\\TO\\Desktop\\EXAMPLE_FOLDER\\" + pdfFilename; docWriter = PdfWriter.getInstance(doc, new FileOutputStream(path)); doc.addTitle("Invoice"); doc.setPageSize(PageSize.A4); doc.open(); PdfContentByte cb = docWriter.getDirectContent(); fillPDFDetails(cb); if