Simply order by offset also when not doing brute force to fix #1208

This commit is contained in:
BobLd
2025-11-13 13:26:24 +00:00
parent 52ecef0e28
commit f4e7db5b5b
4 changed files with 28 additions and 0 deletions

View File

@@ -6,9 +6,29 @@
using PdfPig.Core;
using PdfPig.Tokens;
using SkiaSharp;
using UglyToad.PdfPig.AcroForms;
using UglyToad.PdfPig.AcroForms.Fields;
public class GithubIssuesTests
{
[Fact]
public void Issue1208()
{
string[] files = ["Input.visible.pdf", "Input.invisible.pdf"];
foreach (var file in files)
{
var path = IntegrationHelpers.GetSpecificTestDocumentPath(file);
using (var document = PdfDocument.Open(path, new ParsingOptions() { UseLenientParsing = true }))
{
Assert.True(document.TryGetForm(out AcroForm form));
Assert.Single(form.Fields);
Assert.Equal(AcroFieldType.Signature, form.Fields[0].FieldType);
}
}
}
[Fact]
public void Revert_e11dc6b()
{

View File

@@ -61,6 +61,9 @@ internal static partial class FirstPassParser
}
else
{
/* Code below commented to fix issue #1208, while not failing test Issue874
* The logic would need to be reviewed before re-enabling.
// If we didn't brute force then use the previous position for ordering.
foreach (var obj in streamsAndTables)
{
@@ -81,6 +84,11 @@ internal static partial class FirstPassParser
orderedXrefs.Add(obj);
}
}
*/
orderedXrefs.AddRange(
streamsAndTables
.OrderBy(x => x.Offset));
}
DictionaryToken? lastTrailer = null;