Skip to content

Commit 80b48ab

Browse files
author
joris.schellekens
committed
Merge branch 'hotfix/hotfix2186' into develop
2 parents e7a529d + 5958b75 commit 80b48ab

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

kernel/src/main/java/com/itextpdf/kernel/pdf/PdfReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ protected PdfDictionary readXrefSection() throws IOException {
808808
tokens.nextValidToken();
809809
int gen = tokens.getIntValue();
810810
tokens.nextValidToken();
811-
if (pos == 0L && gen == 65535 && num == 1) {
811+
if (pos == 0L && gen == 65535 && num == 1 && start != 0) {
812812
// Very rarely can an XREF have an incorrect start number. (SUP-1557)
813813
// e.g.
814814
// xref

kernel/src/test/java/com/itextpdf/kernel/pdf/PdfReaderTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ This file is part of the iText (R) project.
4646
import com.itextpdf.io.source.ByteArrayOutputStream;
4747
import com.itextpdf.io.source.ByteUtils;
4848
import com.itextpdf.kernel.PdfException;
49+
import com.itextpdf.kernel.utils.CompareTool;
4950
import com.itextpdf.test.ExtendedITextTest;
5051
import com.itextpdf.test.annotations.LogMessage;
5152
import com.itextpdf.test.annotations.LogMessages;
@@ -1477,6 +1478,28 @@ public void freeReferencesTest() throws IOException {
14771478
pdfDoc.close();
14781479
}
14791480

1481+
@Test
1482+
public void freeReferencesTest02() throws IOException, InterruptedException {
1483+
1484+
String cmpFile = sourceFolder + "cmp_freeReferences02.pdf";
1485+
String outputFile = destinationFolder + "freeReferences02.pdf";
1486+
String inputFile = sourceFolder + "freeReferences02.pdf";
1487+
1488+
PdfWriter writer = new PdfWriter(outputFile);
1489+
PdfReader reader = new PdfReader(inputFile);
1490+
1491+
PdfDocument inputPdfDocument = new PdfDocument(reader);
1492+
PdfDocument outputPdfDocument = new PdfDocument(writer);
1493+
1494+
int lastPage = inputPdfDocument.getNumberOfPages();
1495+
inputPdfDocument.copyPagesTo(lastPage, lastPage, outputPdfDocument);
1496+
1497+
inputPdfDocument.close();
1498+
outputPdfDocument.close();
1499+
1500+
Assert.assertNull(new CompareTool().compareByContent(outputFile, cmpFile, destinationFolder, "diff_"));
1501+
}
1502+
14801503
@Test
14811504
public void pdfVersionTest() throws IOException {
14821505
String filename = sourceFolder + "hello.pdf";

0 commit comments

Comments
 (0)