Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@

public class GithubIssuesTests
{
[Fact]
public void Issue982()
{
var path = IntegrationHelpers.GetSpecificTestDocumentPath("PDFBOX-659-0.pdf");

using (var document = PdfDocument.Open(path))
{
for (int p = 1; p <= document.NumberOfPages; ++p)
{
var page = document.GetPage(p);
foreach (var pdfImage in page.GetImages())
{
Assert.True(pdfImage.TryGetPng(out _));
}
}
}
}

[Fact]
public void Issue973()
{
Expand All @@ -25,11 +43,11 @@ public void Issue973()
using (var document = PdfDocument.Open(path, new ParsingOptions() { UseLenientParsing = false }))
{
var exception = Assert.Throws<InvalidOperationException>(() => document.GetPage(2));
Assert.Equal("Cannot execute a pop of the graphics state stack, it would leave the stack empty.", exception.Message);
Assert.Equal("Cannot execute a pop of the graphics state stack, it would leave the stack empty.",
exception.Message);
}
}


[Fact]
public void Issue959()
{
Expand Down
Binary file not shown.
10 changes: 4 additions & 6 deletions src/UglyToad.PdfPig/Filters/CcittFaxDecodeFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using CcittFax;
using Util;

// Filter updated from original port because of issue #982

/// <summary>
/// Decodes image data that has been encoded using either Group 3 or Group 4.
/// <para>
Expand Down Expand Up @@ -62,11 +64,6 @@ private static CcittFaxCompressionType DetermineCompressionType(ReadOnlySpan<byt
{
var compressionType = CcittFaxCompressionType.Group3_1D; // Group 3 1D

if (input.Length < 20)
{
throw new InvalidOperationException("The format is invalid");
}

if (input[0] != 0 || (input[1] >> 4 != 1 && input[1] != 1))
{
// leading EOL (0b000000000001) not found, search further and
Expand Down Expand Up @@ -114,7 +111,8 @@ private static void InvertBitmap(Span<byte> bufferData)
{
for (int i = 0, c = bufferData.Length; i < c; i++)
{
bufferData[i] = (byte)(~bufferData[i] & 0xFF);
ref byte b = ref bufferData[i];
b = (byte)(~b & 0xFF);
}
}
}
Expand Down
Loading