itext

iTextSharp 5.5.13.1 no data is available for encoding 10000 when extracting text from PDF

心已入冬 提交于 2021-02-10 15:00:52
问题 I'm trying to extract text from a multipage PDF document and almost all documents extract fine, but a couple of documents blow up with the encoding 10000 error. The only unique thing about the document pages that don't work is that they have a button and form fields on them. { var pageNumbersToSave = new List<int>(); for (var i = 1; i <= r.NumberOfPages; i++) { try { var s = PdfTextExtractor.GetTextFromPage( r, i, new SimpleTextExtractionStrategy() ); I also tried using a PDFStamper to

iTextSharp 5.5.13.1 no data is available for encoding 10000 when extracting text from PDF

南笙酒味 提交于 2021-02-10 14:59:52
问题 I'm trying to extract text from a multipage PDF document and almost all documents extract fine, but a couple of documents blow up with the encoding 10000 error. The only unique thing about the document pages that don't work is that they have a button and form fields on them. { var pageNumbersToSave = new List<int>(); for (var i = 1; i <= r.NumberOfPages; i++) { try { var s = PdfTextExtractor.GetTextFromPage( r, i, new SimpleTextExtractionStrategy() ); I also tried using a PDFStamper to

iTextSharp 5.5.13.1 no data is available for encoding 10000 when extracting text from PDF

我是研究僧i 提交于 2021-02-10 14:57:39
问题 I'm trying to extract text from a multipage PDF document and almost all documents extract fine, but a couple of documents blow up with the encoding 10000 error. The only unique thing about the document pages that don't work is that they have a button and form fields on them. { var pageNumbersToSave = new List<int>(); for (var i = 1; i <= r.NumberOfPages; i++) { try { var s = PdfTextExtractor.GetTextFromPage( r, i, new SimpleTextExtractionStrategy() ); I also tried using a PDFStamper to

Points -> pixels iText (im)precision

孤街浪徒 提交于 2021-02-10 06:00:13
问题 Okay, here's some code ( pdfDocument is a com.itextpdf.text.Document ): PdfPTable table = new PdfPTable(1); PdfPCell cell = new PdfPCell(); cell.setFixedHeight(3f); for (int i = 1; i < 100; i++) { table.addCell(cell); } pdfDocument.add(table); According to my calculations (pixels = points / 0.75f) 3f points should be EXACTLY 4 pixels on a screen with 96dpi (which mine is). However, when I create a table with the code above, I get alternating heights of the cells 4 - 3 - 4 - 3 - 4 - 3 etc...

Points -> pixels iText (im)precision

随声附和 提交于 2021-02-10 05:59:48
问题 Okay, here's some code ( pdfDocument is a com.itextpdf.text.Document ): PdfPTable table = new PdfPTable(1); PdfPCell cell = new PdfPCell(); cell.setFixedHeight(3f); for (int i = 1; i < 100; i++) { table.addCell(cell); } pdfDocument.add(table); According to my calculations (pixels = points / 0.75f) 3f points should be EXACTLY 4 pixels on a screen with 96dpi (which mine is). However, when I create a table with the code above, I get alternating heights of the cells 4 - 3 - 4 - 3 - 4 - 3 etc...

PDF-A1a document not valid after signing with VisualRepresentation using IText

醉酒当歌 提交于 2021-02-10 05:12:57
问题 I digitally sign a PDF-A1a document using IText 7.15.0. In addition to the digital signature, I also add a visual representation (image) to the document. PdfSignatureAppearance appearance = signer.GetSignatureAppearance(); appearance.SetPageNumber(1); Rectangle pr = new Rectangle(10 + ImageOffset, 10 + ImageOffset, 100, 100 ); appearance.SetPageRect(pr); byte[] image = System.IO.File.ReadAllBytes(VisualAppearance); appearance.SetRenderingMode(PdfSignatureAppearance.RenderingMode.GRAPHIC);

PDF-A1a document not valid after signing with VisualRepresentation using IText

[亡魂溺海] 提交于 2021-02-10 05:11:44
问题 I digitally sign a PDF-A1a document using IText 7.15.0. In addition to the digital signature, I also add a visual representation (image) to the document. PdfSignatureAppearance appearance = signer.GetSignatureAppearance(); appearance.SetPageNumber(1); Rectangle pr = new Rectangle(10 + ImageOffset, 10 + ImageOffset, 100, 100 ); appearance.SetPageRect(pr); byte[] image = System.IO.File.ReadAllBytes(VisualAppearance); appearance.SetRenderingMode(PdfSignatureAppearance.RenderingMode.GRAPHIC);

How to remove headers and footers from PDF file using iText in Java

折月煮酒 提交于 2021-02-09 05:37:44
问题 I am using the PDF iText library to convert PDF to text. Below is my code to convert PDF to text file using Java. public class PdfConverter { /** The original PDF that will be parsed. */ public static final String pdfFileName = "jdbc_tutorial.pdf"; /** The resulting text file. */ public static final String RESULT = "preface.txt"; /** * Parses a PDF to a plain text file. * @param pdf the original PDF * @param txt the resulting text * @throws IOException */ public void parsePdf(String pdf,

Align Text and Image vertically with iText 2

為{幸葍}努か 提交于 2021-02-08 10:22:12
问题 I'm trying to print an Image and a text next to each other into a PdfPCell . The image is bigger than the font size, so the row height is increased. iText renders the Text at the bottom of the baseline (First example). But I want the text to be vertically aligned in the middle of the cell (Second example). What can I do to change this? I know I can change the alignment of the cell, but that doesn't change anything. PdfPCell getImageAndText(byte[] image, String text, int originalDimension){

Itext 7 Split Paragraph

萝らか妹 提交于 2021-02-08 10:16:29
问题 How can I split a given paragraph to 2 paragraphs, due to that it fits only partial into canvas. After split, I would like to add the first part into canvas and the second to a new canvas. public Paragraph addParagraphToPage(PdfDocument pdfDocument, int pageNum, Rectangle rectangle, Paragraph p) { PdfPage page = pdfDocument.getPage(pageNum); PdfCanvas pdfCanvas = new PdfCanvas(page.newContentStreamAfter(), page.getResources(), pdfDocument); Canvas canvas = new Canvas(pdfCanvas, pdfDocument,