Crash while reading BASEVERSION from extensions dictionnary
In some (malformed ?) PDF files, it seems the BaseVersion field type in Extensions dictionnary is a number instead of a text. So it crashes in com.gitlab.pdftk_java.cat::225 with the cast to PdfName.
I attached an example : number.pdf
A quick fix I made is to convert the value to a string before creating the PdfName so it works in both cases. I can make a MR about that if you wants.
Here is the stacktrace :
pdftk number.pdf cat 1 output out.pdf verbose
Command Line Data is valid.
Input PDF Filenames & Passwords in Order
( <filename>[, <password>] )
number.pdf
The operation to be performed:
cat - Catenate given page ranges into a new PDF.
The output file will be named:
out.pdf
Output PDF encryption settings:
Output PDF will not be encrypted.
No compression or uncompression being performed on output.
Creating Output ...
Unhandled Java Exception in create_output():
java.lang.ClassCastException: class com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfNumber cannot be cast to class com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfName (com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfNumber and com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfName are in unnamed module of loader 'app')
at com.gitlab.pdftk_java.cat.create_output_cat(cat.java:225)
at com.gitlab.pdftk_java.TK_Session.create_output(TK_Session.java:1451)
at com.gitlab.pdftk_java.pdftk.main_noexit(pdftk.java:190)
at com.gitlab.pdftk_java.pdftk.main(pdftk.java:161)
There was a problem with pdftk-java. Please report it at
https://gitlab.com/pdftk-java/pdftk/issues
including the message above, the version of pdftk-java (3.3.2), and if possible steps to reproduce the error.
Edited by Yoann Laissus