Closed starplanet closed 6 years ago
JDK1.7 PDFbox2.07+levigo-jbig2-imageio2.0
//------------------------------------------------------------
//--------------------------------------------------------------
JDK1.6 PDFbox2.07+ levigo-jbig2-imageio 1.6.5
ImageIO.scanForPlugins(); //add this code
PDFRenderer renderer = new PDFRenderer(document);
Which java file could I add the patch to? I add 'ImageIO.scanForPlugins' to pdfbox/src/main/java/org/apache/pdfbox/filter/JBIG2Filter.java
in pdfbox-2.0.7 src, but it doesn't work.
public DecodeResult decode(InputStream encoded, OutputStream decoded,
COSDictionary parameters, int index) throws IOException
{
ImageIO.scanForPlugins()
ImageReader reader = findImageReader("JBIG2", "jbig2-imageio is not installed");
DecodeResult result = new DecodeResult(new COSDictionary());
result.getParameters().addAll(parameters);
Then I try to add 'ImageIO.scanForPlugins' to 'tools/src/main/java/org/apache/pdfbox/tools/PDFToImage.java', It still doesn't work.
// render the pages
boolean success = true;
endPage = Math.min(endPage, document.getNumberOfPages());
ImageIO.scanForPlugins();
PDFRenderer renderer = new PDFRenderer(document);
Can you tell more clearly?
Please note that this GitHub project is related to just the JBIG2 decoder, therefore it is the wrong place to ask for help about the integration into PDFBox. However, this project is currently in the process of becoming being transferred under the PDFBox umbrella, including the required re-licensing from GPL to ASL. Future PDFBox releases will therefore most likely include the plugin, obviating the need to integrate it manually.
Maybe I will help somebody.. add line to your code: IIORegistry.getDefaultInstance().registerServiceProvider(new JBIG2ImageReaderSpi()); in order to ImageIO will register jbig2 plugin. or add jar file into class path (but it did not work for me) ImageIO.scanForPlugins(); - also didnot work for me..
@asilverskold thanks for your comment. However, please keep my comment from above in mind: the plugin is now maintained under the Apache PDFBox umbrella. For downloads see https://pdfbox.apache.org/download.cgi
The maven coordinates of the latest Apache release are:
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>jbig2-imageio</artifactId>
<version>3.0.2</version>
</dependency>
I download the newest pdfbox command line tools pdfbox-app-2.0.7.jar from official website and levigo-jbig2-imageio-1.6.5.jar from search.maven.org.
When I use the following command to extract images from a pdf document which includes jbig2 images, pdfbox tool will report error.
the error messages are like following: