Details
-
Type: Bug
-
Status: Open
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: 6.3.2
-
Fix Version/s: None
-
Component/s: Core/Parsing
-
Labels:None
-
Environment:Windows 7 64 bit, Oracle JDK 8u60
Description
It seems like ICEpdf 6.3.2 introduced a regression, because with ICEpdf 6.2.2 everything works fine.
If I try to load a PDF document via byte array using org.icepdf.core.pobjects.Document.setByteArray(byte[], int, int, String), it throws IOException with the following stack trace:
============================================
java.io.IOException: java.lang.String cannot be cast to java.lang.Number
at org.icepdf.core.pobjects.Document.setInputStream(Document.java:499)
at org.icepdf.core.pobjects.Document.setByteArray(Document.java:365)
at com.example.App.testPdf(App.java:13)
...
============================================
And the following appears in standard error output stream:
============================================
Dec 07, 2019 12:20:38 AM org.icepdf.core.pobjects.Catalog <clinit>
INFO: ICEsoft ICEpdf Core 6.3.2
Dec 07, 2019 12:20:38 AM org.icepdf.core.pobjects.Document setInputStream
WARNING: Cross reference deferred loading failed, will fall back to linear reading.
Dec 07, 2019 12:20:38 AM org.icepdf.core.pobjects.Document setInputStream
SEVERE: Error loading PDF Document.
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
at org.icepdf.core.util.Parser.getObject(Parser.java:150)
at org.icepdf.core.pobjects.Document.loadDocumentViaLinearTraversal(Document.java:629)
at org.icepdf.core.pobjects.Document.setInputStream(Document.java:478)
at org.icepdf.core.pobjects.Document.setByteArray(Document.java:365)
at com.example.App.testPdf(App.java:13)
...
============================================
Here is the code snippet which I use to reproduce:
============================================
package com.example;
import org.icepdf.core.pobjects.Document;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public void testPdf(String pdfPath) throws Exception {
byte[] bytes = Files.readAllBytes(Paths.get(pdfPath));
Document document = new Document();
document.setByteArray(bytes, 0, bytes.length, null);
document.dispose();
}
}
============================================
To test it, call this:
new App().testPdf("/full/path/to/pdf/file.pdf");
If needed, I can provide PDF documents, which cause this issue, via email channel.
If I try to load a PDF document via byte array using org.icepdf.core.pobjects.Document.setByteArray(byte[], int, int, String), it throws IOException with the following stack trace:
============================================
java.io.IOException: java.lang.String cannot be cast to java.lang.Number
at org.icepdf.core.pobjects.Document.setInputStream(Document.java:499)
at org.icepdf.core.pobjects.Document.setByteArray(Document.java:365)
at com.example.App.testPdf(App.java:13)
...
============================================
And the following appears in standard error output stream:
============================================
Dec 07, 2019 12:20:38 AM org.icepdf.core.pobjects.Catalog <clinit>
INFO: ICEsoft ICEpdf Core 6.3.2
Dec 07, 2019 12:20:38 AM org.icepdf.core.pobjects.Document setInputStream
WARNING: Cross reference deferred loading failed, will fall back to linear reading.
Dec 07, 2019 12:20:38 AM org.icepdf.core.pobjects.Document setInputStream
SEVERE: Error loading PDF Document.
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
at org.icepdf.core.util.Parser.getObject(Parser.java:150)
at org.icepdf.core.pobjects.Document.loadDocumentViaLinearTraversal(Document.java:629)
at org.icepdf.core.pobjects.Document.setInputStream(Document.java:478)
at org.icepdf.core.pobjects.Document.setByteArray(Document.java:365)
at com.example.App.testPdf(App.java:13)
...
============================================
Here is the code snippet which I use to reproduce:
============================================
package com.example;
import org.icepdf.core.pobjects.Document;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public void testPdf(String pdfPath) throws Exception {
byte[] bytes = Files.readAllBytes(Paths.get(pdfPath));
Document document = new Document();
document.setByteArray(bytes, 0, bytes.length, null);
document.dispose();
}
}
============================================
To test it, call this:
new App().testPdf("/full/path/to/pdf/file.pdf");
If needed, I can provide PDF documents, which cause this issue, via email channel.
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
Yauheni Sidarenka
created issue -