Skip to content

Commit cf68079

Browse files
BezrukovMiText-CI
authored andcommitted
Add log message for invalid Version in the catalog
DEVSIX-5094 Autoported commit. Original commit hash: [923408ccb]
1 parent abc0dab commit cf68079

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

itext.tests/itext.kernel.tests/itext/kernel/pdf/PdfDocumentTest.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,14 @@ public virtual void RemovePageWithInvalidOutlineTest() {
438438
}
439439

440440
[NUnit.Framework.Test]
441+
[LogMessage(iText.IO.LogMessageConstant.DOCUMENT_VERSION_IN_CATALOG_CORRUPTED, LogLevel = LogLevelConstants
442+
.ERROR)]
441443
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);
444+
using (PdfReader reader = new PdfReader(SOURCE_FOLDER + "sample-with-invalid-catalog-version.pdf")) {
445+
using (PdfDocument pdfDocument = new PdfDocument(reader)) {
446+
NUnit.Framework.Assert.IsNotNull(pdfDocument);
447+
}
448+
}
445449
}
446450

447451
private class IgnoreTagStructurePdfDocument : PdfDocument {

itext/itext.io/itext/io/LogMessageConstant.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ public sealed class LogMessageConstant {
116116

117117
public const String DOCUMENT_SERIALIZATION_EXCEPTION_RAISED = "Unhandled exception while serialization";
118118

119+
public const String DOCUMENT_VERSION_IN_CATALOG_CORRUPTED = "The document version specified in catalog is corrupted";
120+
119121
public const String DURING_CONSTRUCTION_OF_ICC_PROFILE_ERROR_OCCURRED = "During the construction of the ICC profile, the {0} error with message \"{1}\" occurred, the ICC profile will not be installed in the image.";
120122

121123
public const String ELEMENT_DOES_NOT_FIT_AREA = "Element does not fit current area. {0}";

itext/itext.kernel/itext/kernel/pdf/PdfDocument.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,6 +1978,8 @@ protected internal virtual void Open(PdfVersion newPdfVersion) {
19781978
}
19791979
}
19801980
catch (ArgumentException) {
1981+
LogManager.GetLogger(typeof(iText.Kernel.Pdf.PdfDocument)).Error(iText.IO.LogMessageConstant.DOCUMENT_VERSION_IN_CATALOG_CORRUPTED
1982+
);
19811983
}
19821984
}
19831985
PdfStream xmpMetadataStream = catalog.GetPdfObject().GetAsStream(PdfName.Metadata);

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6bf4ecfb0e4a409b1e5f2096045ca741e3fb854e
1+
923408ccb8e69382d597778d71847b73717eae25

0 commit comments

Comments
 (0)