mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-04-05 20:55:01 +08:00
handle case where xref has multiple parts with incorrect offset #352
This commit is contained in:
parent
72db3bf244
commit
dd95b38345
@ -28,7 +28,7 @@
|
||||
parts.Add(part);
|
||||
}
|
||||
|
||||
public CrossReferenceTable Build(long firstCrossReferenceOffset, ILog log)
|
||||
public CrossReferenceTable Build(long firstCrossReferenceOffset, long offsetCorrection, ILog log)
|
||||
{
|
||||
CrossReferenceType type = CrossReferenceType.Table;
|
||||
DictionaryToken trailerDictionary = new DictionaryToken(new Dictionary<NameToken, IToken>());
|
||||
@ -65,7 +65,7 @@
|
||||
break;
|
||||
}
|
||||
|
||||
currentPart = parts.FirstOrDefault(x => x.Offset == prevBytePos);
|
||||
currentPart = parts.FirstOrDefault(x => x.Offset == prevBytePos || x.Offset == prevBytePos + offsetCorrection);
|
||||
if (currentPart == null)
|
||||
{
|
||||
log.Warn("Did not found XRef object pointed to by 'Prev' key at position " + prevBytePos);
|
||||
@ -88,7 +88,7 @@
|
||||
// merge used and sorted XRef/trailer
|
||||
foreach (long bPos in xrefSeqBytePos)
|
||||
{
|
||||
var currentObject = parts.First(x => x.Offset == bPos);
|
||||
var currentObject = parts.First(x => x.Offset == bPos || x.Offset == bPos + offsetCorrection);
|
||||
if (currentObject.Dictionary != null)
|
||||
{
|
||||
foreach (var entry in currentObject.Dictionary.Data)
|
||||
|
@ -207,7 +207,7 @@
|
||||
throw new PdfDocumentFormatException("The cross reference was not found.");
|
||||
}
|
||||
|
||||
var resolved = table.Build(crossReferenceLocation, log);
|
||||
var resolved = table.Build(crossReferenceLocation, offsetCorrection, log);
|
||||
|
||||
// check the offsets of all referenced objects
|
||||
if (!CrossReferenceObjectOffsetValidator.ValidateCrossReferenceOffsets(bytes, resolved, log, out var actualOffsets))
|
||||
|
Loading…
Reference in New Issue
Block a user