I found out that I got an error if I try to open an existing 1.6 PDF with iText (version 5.1.1). If I transform this same PDF in a 1.5, I'm able to read it.
I tried to find out since which version of iText PDF 1.6 are handled but cannot find the information.
Any idea?
Thx!
Edit: here the stack :
Caused by: java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1OctetString
at com.itextpdf.text.pdf.PdfEncryption.<init>(PdfEncryption.java:147)
at com.itextpdf.text.pdf.PdfReader.readDecryptedDocObj(PdfReader.java:775)
at com.itextpdf.text.pdf.PdfReader.readDocObj(PdfReader.java:1152)
at com.itextpdf.text.pdf.PdfReader.readPdf(PdfReader.java:512)
at com.itextpdf.text.pdf.PdfReader.<init>(PdfReader.java:172)
Error is happening when executing line :
final PdfReader reader = new PdfReader(file.getAbsolutePath());
Your question is misleading because you make a false allegation. You claim that the version of iText that you are using doesn't support PDF 1.6.
However, the error message you added in the edited version of your question shows the real cause:
Caused by: java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1OctetString
I opened the PDF you shared in the comment in Acrobat Reader, and this is what I saw:
You can clearly read:
The document's Security Method restrict what can be done to the document. To remove security restrictions, set the Security Method to No Security.
That is exactly what you did when you converted the original PDF that was compliant with PDF 1.6 to a document that is compliant with PDF 1.5. If you had removed the security restrictions and kept the file as a PDF 1.6 document, the problem wouldn't have occurred.
This being said. You don't need to remove the security restrictions. You can solve the java.lang.NoClassDefFoundError by adding the correct version of the BouncyCastle library to your CLASSPATH. You may have to change the unethicalreading variable to true as explained here: How to read PDFs created with an unknown random owner password?
Related
first time here posting, though I have benefited many times from other postings on stackoverflow. I am the principal developer of Jmol, which I have recently ported to JavaScript/HTML5. The Jmol applet interfaces with another applet, JSpecView, which in its current form as a Java applet utilizes a slimmed down version of itext.1.4.5.jar to create PDF files of spectra.
I am interested in converting iTtext Java code to JavaScript so that a JavaScript version of the JSpecView applet can create PDF files directly.
Q: Has this already been accomplished?
Q: JSpecView is an Open-Source project licensed under LGPL. All our source code is available. Is this a problem?
Bob Hanson
Principal Developer, Jmol/JSmol
A: I don't think such a port has been done before. But why would you not use an existing JavaScript pdf library? Or what is wrong with doing the PDF generation on the server side? Why would you do more work than is necessary? I've done a quick google on JS PDF libraries and found:
http://jspdf.com/
https://github.com/mozilla/pdf.js
And the following stackoverflow question:
Generating PDF files with Javascript
A: I think it shouldn't be a problem porting it to JavaScript as you'd be porting to the same license (of course, if you're using a version of iText before the license switch to AGPL), but IANAL.
I am using HTML to PDF Converter in my Outsystems application, but when I open the downloaded PDF its size is zero bytes and I am not able to open the PDF too. It throws 'No registered application for this extension.'
Any hints ?
Have a look at that component's official discussion topic here
http://www.outsystems.com/NetworkForums/ViewTopic.aspx?TopicId=7393&Topic=[[]Html-to-PDF-Converter]-Discussion
Halfway through the (rather lenghty) topic a few people reported the same problem. It can be due to a multitude of problems from the page having runtime content (e.g. Flash) to write access restrictions for the creation of temp files.
Miguel
It's quite possible you are missing some dlls. Remember to upload all the dlls in the zip file which you can install from here: http://wkhtmltopdf.org/downloads.html
I need to extract text from DOC, DOCX and PDF files.
I've downloaded two Windows Forms Application demo projects, one here:
http://www.codeproject.com/Articles/31944/Implementing-a-TextReader-to-extract-various-files
the other here:
http://www.codeproject.com/Articles/13391/Using-IFilter-in-C
Both are working just fine within the windows Form Application. But both do not work within my ASP.NET MVC2 application, it gets saying it can't find a filter or throws a method not implemented exception.
Could this be a security error? Like ASP.NET cannot reach the various IFilter's installed on the machine.
DOC files are working by the way.
All is x64 and the files are first saved on disk and have the proper permissions set.
Any help is appreciated.
edit:
PDF error is: The method or operation is not implemented.
DOCX error is: No filter defined
Windows Forms Application both are working. I'm considering getting the output from a Windows Forms/Console application.
I am using TestNg 6.3 with eclipse sdk version 3.7.1
I am getting an error in xml file and the error is
org.xml.sax.SAXParseException: Content is not allowed in prolog.
can i know why this occurs and any modifications can u plz suggest
Seems like the XML is not well formed or there is something wrong with the encoding of the file. I remember I had this error a lot with XSLT when it was not in UTF-8. Encoding is found via selecting file, context menu, and the properties. If this does not help, please share part of your XML.
I've been using the code sample from iText in Action (8.7.2) to deal with the "cannot save" issue with PDF forms and iTextSharp. It was working fine, but recently the fix stopped working and all the variations of the code listed in the book to prevent the saving problem haven't solved it.
I'm using the latest version of the iTextSharp library. Has anyone else run into this? Did an Acrobat update break it?
works for me using iTextSharp 5.0.6, Reader X, and Listing 8.29 ReaderEnabledForm from the book. (it's the file named 'xfa_preserved.pdf' in the zip download)
IIRC the last couple of times i saw similar on the mailing list, the problem was specific to how the original PDF was created. if you subscribe, you can post the original PDF and hopefully one of the experts can take a look if they have time.