mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-10-07 16:04:34 +08:00
Add xref-streams tied to any parts, not just the first
On a large sample of pdf-files PdfPig failed to read the correct StructTree-object for about 1% of them. The StructTree object was simply missing in the CrossReferenceTable.CrossReferenceTable. It turned out that the constructed CrossReferenceTable could miss Stream-parts if there were multiple Table-parts because a stream will only be added if it's associated with the very first Table-part. The remedy would seem to be to check for and add streams that are associated with any of the Table-parts, not just the first one. On a sample of 72 files where this failed, this changed fixed the StructTree for all of them.
This commit is contained in:
@@ -56,16 +56,16 @@
|
||||
// add this and follow chain defined by 'Prev' keys
|
||||
xrefPartToBytePositionOrder.Add(firstCrossReferenceOffset);
|
||||
|
||||
// Get any streams that are tied to this table.
|
||||
var activePart = currentPart;
|
||||
var dependents = parts.Where(x => x.TiedToXrefAtOffset == activePart.Offset);
|
||||
foreach (var dependent in dependents)
|
||||
{
|
||||
xrefPartToBytePositionOrder.Add(dependent.Offset);
|
||||
}
|
||||
|
||||
while (currentPart.Dictionary != null)
|
||||
{
|
||||
// Get any streams that are tied to this table.
|
||||
var activePart = currentPart;
|
||||
var dependents = parts.Where(x => x.TiedToXrefAtOffset == activePart.Offset);
|
||||
foreach (var dependent in dependents)
|
||||
{
|
||||
xrefPartToBytePositionOrder.Add(dependent.Offset);
|
||||
}
|
||||
|
||||
long prevBytePos = currentPart.GetPreviousOffset();
|
||||
if (prevBytePos == -1)
|
||||
{
|
||||
|
Reference in New Issue
Block a user