Skip to content

Commit 19853b8

Browse files
joris.schellekensyulian-gaponenko
authored andcommitted
Merge branch 'hotfix/hotfix2186' into develop
Autoported commit. Original commit hash: [80b48abff3]
2 parents 06743ea + 8242073 commit 19853b8

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

itext.tests/itext.kernel.tests/itext/kernel/pdf/PdfReaderTest.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ source product.
4545
using iText.IO.Source;
4646
using iText.IO.Util;
4747
using iText.Kernel;
48+
using iText.Kernel.Utils;
4849
using iText.Test;
4950
using iText.Test.Attributes;
5051

@@ -1337,6 +1338,25 @@ public virtual void FreeReferencesTest() {
13371338
pdfDoc.Close();
13381339
}
13391340

1341+
/// <exception cref="System.IO.IOException"/>
1342+
/// <exception cref="System.Exception"/>
1343+
[NUnit.Framework.Test]
1344+
public virtual void FreeReferencesTest02() {
1345+
String cmpFile = sourceFolder + "cmp_freeReferences02.pdf";
1346+
String outputFile = destinationFolder + "freeReferences02.pdf";
1347+
String inputFile = sourceFolder + "freeReferences02.pdf";
1348+
PdfWriter writer = new PdfWriter(outputFile);
1349+
PdfReader reader = new PdfReader(inputFile);
1350+
PdfDocument inputPdfDocument = new PdfDocument(reader);
1351+
PdfDocument outputPdfDocument = new PdfDocument(writer);
1352+
int lastPage = inputPdfDocument.GetNumberOfPages();
1353+
inputPdfDocument.CopyPagesTo(lastPage, lastPage, outputPdfDocument);
1354+
inputPdfDocument.Close();
1355+
outputPdfDocument.Close();
1356+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outputFile, cmpFile, destinationFolder, "diff_"
1357+
));
1358+
}
1359+
13401360
/// <exception cref="System.IO.IOException"/>
13411361
[NUnit.Framework.Test]
13421362
public virtual void PdfVersionTest() {
Binary file not shown.
Binary file not shown.

itext/itext.kernel/itext/kernel/pdf/PdfReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ protected internal virtual PdfDictionary ReadXrefSection() {
891891
tokens.NextValidToken();
892892
int gen = tokens.GetIntValue();
893893
tokens.NextValidToken();
894-
if (pos == 0L && gen == 65535 && num == 1) {
894+
if (pos == 0L && gen == 65535 && num == 1 && start != 0) {
895895
// Very rarely can an XREF have an incorrect start number. (SUP-1557)
896896
// e.g.
897897
// xref

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
e7a529dc4a127492fa4adc6f642e70f412134758
1+
80b48abff3e4bdc9fb0ef37486f9107e0587e34a

0 commit comments

Comments
 (0)