add merge test for document with object stream

This commit is contained in:
Eliot Jones
2020-04-16 20:57:57 +01:00
parent 635ae13a77
commit e382e581ba
2 changed files with 42 additions and 2 deletions

View File

@@ -93,5 +93,45 @@
"Expected object count to be lower than 24");
}
}
[Fact]
public void CanMergeWithObjectStream()
{
var first = IntegrationHelpers.GetDocumentPath("Single Page Simple - from google drive.pdf");
var second = IntegrationHelpers.GetDocumentPath("Multiple Page - from Mortality Statistics.pdf");
var result = PdfMerger.Merge(first, second);
WriteFile(nameof(CanMergeWithObjectStream), result);
using (var document = PdfDocument.Open(result, ParsingOptions.LenientParsingOff))
{
Assert.Equal(7, document.NumberOfPages);
foreach (var page in document.GetPages())
{
Assert.NotNull(page.Text);
}
}
}
private static void WriteFile(string name, byte[] bytes)
{
try
{
if (!Directory.Exists("Merger"))
{
Directory.CreateDirectory("Merger");
}
var output = Path.Combine("Merger", $"{name}.pdf");
File.WriteAllBytes(output, bytes);
}
catch
{
// ignored.
}
}
}
}

View File

@@ -17,7 +17,7 @@
using Tokenization.Scanner;
using Tokens;
using XObjects;
using static UglyToad.PdfPig.Core.PdfSubpath;
using static PdfPig.Core.PdfSubpath;
internal class ContentStreamProcessor : IOperationContext
{
@@ -540,7 +540,7 @@
return;
}
var currentState = this.GetCurrentState();
var currentState = GetCurrentState();
if (CurrentPath.IsStroked)
{
CurrentPath.LineDashPattern = currentState.LineDashPattern;