Skip to content

Commit fb721ca

Browse files
committed
PDFBOX-5660: add debug output, improve exception message
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1928164 13f79535-47bb-0310-9956-ffa450edef68
1 parent 19560a7 commit fb721ca

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
import java.util.Set;
4242
import java.util.stream.Collectors;
4343

44+
import org.apache.logging.log4j.LogManager;
45+
import org.apache.logging.log4j.Logger;
46+
4447
import org.apache.pdfbox.cos.COSArray;
4548
import org.apache.pdfbox.cos.COSBase;
4649
import org.apache.pdfbox.cos.COSBoolean;
@@ -84,6 +87,8 @@
8487
*/
8588
public class COSWriter implements ICOSVisitor
8689
{
90+
private static final Logger LOG = LogManager.getLogger(COSWriter.class);
91+
8792
/**
8893
* The dictionary open token.
8994
*/
@@ -881,7 +886,8 @@ private void doWriteSignature() throws IOException
881886
throw new IOException("Can't write new byteRange '" + byteRange +
882887
"' not enough space: byteRange.length(): " + byteRange.length() +
883888
", byteRangeLength: " + byteRangeLength +
884-
", byteRangeOffset: " + byteRangeOffset);
889+
", byteRangeOffset: " + byteRangeOffset +
890+
", inLength: " + inLength);
885891
}
886892

887893
// copy the new incremental data into a buffer (e.g. signature dict, trailer)
@@ -1278,10 +1284,12 @@ private void detectPossibleSignature(COSDictionary obj) throws IOException
12781284
COSBase base3 = byteRange.get(3);
12791285
if (base2 instanceof COSInteger && base3 instanceof COSInteger)
12801286
{
1287+
// PDFBOX-5521 avoid hitting "old" signatures
12811288
long br2 = ((COSInteger) base2).longValue();
12821289
long br3 = ((COSInteger) base3).longValue();
12831290
if (br2 + br3 > incrementalInput.length())
12841291
{
1292+
LOG.debug("reachedSignature at offset {}, byteRange: {}", getStandardOutput().getPos(), byteRange);
12851293
reachedSignature = true;
12861294
}
12871295
}

0 commit comments

Comments
 (0)