itext

Get the original content from a signed pdf

风格不统一 提交于 2019-12-21 06:08:19
问题 I would like to know how I could get the original content from a signed pdf document using iText java library or another one. Thanks UPDATE 1: Possible example: PdfReader reader = new PdfReader(PATH_TO_PDF); AcroFields fields = reader.getAcroFields(); ArrayList<String> signatures = fields.getSignatureNames(); for (String signature : signatures) { // Start revision extraction ByteArrayOutputStream out = new ByteArrayOutputStream(); byte bb[] = new byte[8192]; InputStream ip = fields

iText direct Printing

廉价感情. 提交于 2019-12-21 06:07:05
问题 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

iText 7: Paragraph height as it would be rendered

☆樱花仙子☆ 提交于 2019-12-21 05:24:08
问题 I can set the width of a new paragraph as follows, which results in a certain height: Paragraph p = new Paragraph("some longer text some longer text some longer text"); p.setWidth(100); System.out.println("height " + p.getHeight()); document.add(p); Of course p.getHeight() is null , since the rendered height is calculated during rendering the PDF file. But I need the height before the final rendering. How can I get it most efficiently? 回答1: To get the effective width of the paragraph as if it

Should I dynamically recreate a PDF, rather than store it in either the database or the filesystem?

谁说胖子不能爱 提交于 2019-12-21 05:04:22
问题 I need customers to be able to download PDFs of letters that have been sent to them. I have read the threads about database versus filesystem storage of documents or images, and it does sound like the consensus is that, for anything more than just a few images, filesystem is the way to go. What I want to know: would a reasonable alternative be to just store the letter details in the database, and recreate the PDF 'on the fly' when it is requested? Is that approach superior or inferior to

How to find whether PDF has landscape orientation or portrait

心不动则不痛 提交于 2019-12-21 02:45:31
问题 Are there tools to determine whether a PDF has landscape orientation or portrait? I have currently looked upon pdfbox and Itext for this but seem that I could not find it. Please tell if they support this. Extracting the PDF pages information using Origami is providing a information the pdf pages have rotation of some degree. Here is what Origami reports: {:Parent=>#<PDF::Reader::Reference:0x872349c @id=8, @gen=0>, :Type=>:Page, :Contents=>#<PDF::Reader::Reference:0x8722f24 @id=4, @gen=0>,

Convert HTML with images to PDF using iText

。_饼干妹妹 提交于 2019-12-21 02:19:08
问题 I have searched the questions and have not been able to find a solution to my specific problem. What I need to do is convert HTML files that contain images and CSS styling to PDF. I am using iText 5 and have been able to include the styling into the generated PDF. However, I am still struggling including the images. I have included my code below. The image with the absolute path is included in the generated PDF, the image with the relative path is not. I know I need to implement

Reading PDF Annotations with iText

自古美人都是妖i 提交于 2019-12-20 15:30:39
问题 I trying to get the contents of a PDF annotation to string so I can store that information in a database for searching purposes. Does anyone know how to accomplish this using iText/iTextSharp? 回答1: Yes, but the specifics really depend on what kind[s] of annotations you're talking about. In general: PdfDictionary pageDict = myPdfReader.getPageN(firstPageIsOne); PdfArray annotArray = pageDict.getAsArray(PdfName.ANNOTS); for (int i = 0; i < annotArray.size(); ++i) { PdfDictionary curAnnot =

Performance iText vs.PdfBox

杀马特。学长 韩版系。学妹 提交于 2019-12-20 14:41:13
问题 I'm trying to convert a pdf (my favorite book Effective Java, if its matter)to text, i checked both iText and Apache PdfBox. I see a really big difference in performance: With iText it took 2:521, and with PdfBox: 6:117. This if my code for PdfBOx PDFTextStripper stripper = new PDFTextStripper(); BUFFER.append(stripper.getText(PDDocument.load(pdf))); And this is for iText PdfReader reader = new PdfReader(pdf); for (int i = 1; i <= reader.getNumberOfPages(); i++) { BUFFER.append

Both landscape and portrait for pdf with Flying Saucer/iText

不打扰是莪最后的温柔 提交于 2019-12-20 11:44:22
问题 Is there a way to set different page styles with Flying Saucer/iText? I need to have the first couple of pages in landscape, then switch to portrait at a certain page and out. Any ideas? 回答1: Nevermind, found the answer. For anyone interested, this is how you do it: @page land { size:landscape; } @page port { size:portrait; } .landscapePage { page:land; } .portraitPage { page:port; } voilá! 回答2: For anyone still stuck with the problem Derek mentioned, I've found that I need to explicitly set

Both landscape and portrait for pdf with Flying Saucer/iText

一个人想着一个人 提交于 2019-12-20 11:44:18
问题 Is there a way to set different page styles with Flying Saucer/iText? I need to have the first couple of pages in landscape, then switch to portrait at a certain page and out. Any ideas? 回答1: Nevermind, found the answer. For anyone interested, this is how you do it: @page land { size:landscape; } @page port { size:portrait; } .landscapePage { page:land; } .portraitPage { page:port; } voilá! 回答2: For anyone still stuck with the problem Derek mentioned, I've found that I need to explicitly set