mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
Handle null token in DirectObjectFinder, handle null state in SetNamedGraphicsState(), add and test and fix #874
This commit is contained in:
BIN
src/UglyToad.PdfPig.Tests/Integration/Documents/ErcotFacts.pdf
Normal file
BIN
src/UglyToad.PdfPig.Tests/Integration/Documents/ErcotFacts.pdf
Normal file
Binary file not shown.
26
src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs
Normal file
26
src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
namespace UglyToad.PdfPig.Tests.Integration
|
||||
{
|
||||
public class GithubIssuesTests
|
||||
{
|
||||
[Fact]
|
||||
public void Issue874()
|
||||
{
|
||||
var doc = IntegrationHelpers.GetDocumentPath("ErcotFacts.pdf");
|
||||
|
||||
using (var document = PdfDocument.Open(doc, new ParsingOptions() { UseLenientParsing = true, SkipMissingFonts = true }))
|
||||
{
|
||||
var page1 = document.GetPage(1);
|
||||
Assert.Equal(1788, page1.Letters.Count);
|
||||
|
||||
var page2 = document.GetPage(2);
|
||||
Assert.Equal(2430, page2.Letters.Count);
|
||||
}
|
||||
|
||||
using (var document = PdfDocument.Open(doc, new ParsingOptions() { UseLenientParsing = true, SkipMissingFonts = false }))
|
||||
{
|
||||
var ex = Assert.Throws<ArgumentNullException>(() => document.GetPage(1));
|
||||
Assert.StartsWith("Value cannot be null.", ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,8 @@
|
||||
private static readonly HashSet<string> _documentsToIgnore =
|
||||
[
|
||||
"issue_671.pdf",
|
||||
"GHOSTSCRIPT-698363-0.pdf"
|
||||
"GHOSTSCRIPT-698363-0.pdf",
|
||||
"ErcotFacts.pdf"
|
||||
];
|
||||
|
||||
[Theory]
|
||||
|
||||
@@ -661,6 +661,11 @@
|
||||
|
||||
var state = ResourceStore.GetExtendedGraphicsStateDictionary(stateName);
|
||||
|
||||
if (state is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.TryGet(NameToken.Lw, PdfScanner, out NumericToken? lwToken))
|
||||
{
|
||||
currentGraphicsState.LineWidth = lwToken.Data;
|
||||
|
||||
@@ -32,6 +32,11 @@
|
||||
{
|
||||
var temp = scanner.Get(reference.Data);
|
||||
|
||||
if (temp is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (temp.Data is T tTemp)
|
||||
{
|
||||
tokenResult = tTemp;
|
||||
|
||||
Reference in New Issue
Block a user