File tree Expand file tree Collapse file tree 4 files changed +15
-4
lines changed
itext.tests/itext.kernel.tests
resources/itext/kernel/pdf/PdfDocumentTest
itext/itext.kernel/itext/kernel/pdf Expand file tree Collapse file tree 4 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -437,6 +437,13 @@ public virtual void RemovePageWithInvalidOutlineTest() {
437
437
) ) ;
438
438
}
439
439
440
+ [ NUnit . Framework . Test ]
441
+ public virtual void OpenDocumentWithInvalidCatalogVersionTest ( ) {
442
+ PdfReader reader = new PdfReader ( SOURCE_FOLDER + "sample-with-invalid-catalog-version.pdf" ) ;
443
+ PdfDocument pdfDocument = new PdfDocument ( reader ) ;
444
+ NUnit . Framework . Assert . IsNotNull ( pdfDocument ) ;
445
+ }
446
+
440
447
private class IgnoreTagStructurePdfDocument : PdfDocument {
441
448
internal IgnoreTagStructurePdfDocument ( PdfReader reader )
442
449
: base ( reader ) {
Original file line number Diff line number Diff line change @@ -1971,9 +1971,13 @@ protected internal virtual void Open(PdfVersion newPdfVersion) {
1971
1971
if ( catalog . GetPdfObject ( ) . ContainsKey ( PdfName . Version ) ) {
1972
1972
// The version of the PDF specification to which the document conforms (for example, 1.4)
1973
1973
// if later than the version specified in the file's header
1974
- PdfVersion catalogVersion = PdfVersion . FromPdfName ( catalog . GetPdfObject ( ) . GetAsName ( PdfName . Version ) ) ;
1975
- if ( catalogVersion . CompareTo ( pdfVersion ) > 0 ) {
1976
- pdfVersion = catalogVersion ;
1974
+ try {
1975
+ PdfVersion catalogVersion = PdfVersion . FromPdfName ( catalog . GetPdfObject ( ) . GetAsName ( PdfName . Version ) ) ;
1976
+ if ( catalogVersion . CompareTo ( pdfVersion ) > 0 ) {
1977
+ pdfVersion = catalogVersion ;
1978
+ }
1979
+ }
1980
+ catch ( ArgumentException ) {
1977
1981
}
1978
1982
}
1979
1983
PdfStream xmpMetadataStream = catalog . GetPdfObject ( ) . GetAsStream ( PdfName . Metadata ) ;
Original file line number Diff line number Diff line change 1
- 9c36eb28befb33da8e432e51468f2f845f484d1d
1
+ 6bf4ecfb0e4a409b1e5f2096045ca741e3fb854e
You can’t perform that action at this time.
0 commit comments