diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 89216c75..70a3bbd2 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -13,9 +13,11 @@ jobs: - uses: actions/checkout@master - name: Set up dotnet core - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v2 with: - dotnet-version: "2.1.x" + dotnet-version: | + 2.1.x + 6.0.x - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.0.2 diff --git a/.github/workflows/nightly_release.yml b/.github/workflows/nightly_release.yml index 0eca77a0..7ec4938b 100644 --- a/.github/workflows/nightly_release.yml +++ b/.github/workflows/nightly_release.yml @@ -30,9 +30,11 @@ jobs: - uses: actions/checkout@master - name: Set up dotnet core - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v2 with: - dotnet-version: "2.1.x" + dotnet-version: | + 2.1.x + 6.0.x - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.0.2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index abf70298..00d3e912 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,7 +45,7 @@ Open `.\src\UglyToad.PdfPig\UglyToad.PdfPig.csproj` in a text editor and change: ``` - netstandard2.0;net45;net451;net452;net46;net461;net462;net47 + netstandard2.0;net45;net451;net452;net46;net461;net462;net47;net6.0 PdfPig ... ``` diff --git a/src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj b/src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj index 998695b0..bb180705 100644 --- a/src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj +++ b/src/UglyToad.PdfPig.Core/UglyToad.PdfPig.Core.csproj @@ -1,6 +1,6 @@ - netstandard2.0;net45;net451;net452;net46;net461;net462;net47 + netstandard2.0;net45;net451;net452;net46;net461;net462;net47;net6.0 latest 0.1.6-alpha001 False diff --git a/src/UglyToad.PdfPig.DocumentLayoutAnalysis/UglyToad.PdfPig.DocumentLayoutAnalysis.csproj b/src/UglyToad.PdfPig.DocumentLayoutAnalysis/UglyToad.PdfPig.DocumentLayoutAnalysis.csproj index 3a71ba68..88a83e42 100644 --- a/src/UglyToad.PdfPig.DocumentLayoutAnalysis/UglyToad.PdfPig.DocumentLayoutAnalysis.csproj +++ b/src/UglyToad.PdfPig.DocumentLayoutAnalysis/UglyToad.PdfPig.DocumentLayoutAnalysis.csproj @@ -1,6 +1,6 @@ - netstandard2.0;net45;net451;net452;net46;net461;net462;net47 + netstandard2.0;net45;net451;net452;net46;net461;net462;net47;net6.0 latest 0.1.6-alpha001 False diff --git a/src/UglyToad.PdfPig.Fonts/UglyToad.PdfPig.Fonts.csproj b/src/UglyToad.PdfPig.Fonts/UglyToad.PdfPig.Fonts.csproj index fc0311c6..610c9b28 100644 --- a/src/UglyToad.PdfPig.Fonts/UglyToad.PdfPig.Fonts.csproj +++ b/src/UglyToad.PdfPig.Fonts/UglyToad.PdfPig.Fonts.csproj @@ -1,6 +1,6 @@ - netstandard2.0;net45;net451;net452;net46;net461;net462;net47 + netstandard2.0;net45;net451;net452;net46;net461;net462;net47;net6.0 latest 0.1.6-alpha001 False diff --git a/src/UglyToad.PdfPig.Tests/Encryption/AesEncryptionHelperTests.cs b/src/UglyToad.PdfPig.Tests/Encryption/AesEncryptionHelperTests.cs index 6a07a911..1ae27525 100644 --- a/src/UglyToad.PdfPig.Tests/Encryption/AesEncryptionHelperTests.cs +++ b/src/UglyToad.PdfPig.Tests/Encryption/AesEncryptionHelperTests.cs @@ -23,7 +23,9 @@ namespace UglyToad.PdfPig.Tests.Encryption var output = AesEncryptionHelper.Decrypt(data, key); - Assert.Equal("D:20180808103317-07'00'", OtherEncodings.BytesAsLatin1String(output)); + var actual = OtherEncodings.BytesAsLatin1String(output); + + Assert.Equal("D:20180808103317-07'00'", actual); } } } diff --git a/src/UglyToad.PdfPig.Tests/Fonts/SystemFonts/Linux.cs b/src/UglyToad.PdfPig.Tests/Fonts/SystemFonts/Linux.cs index 5959b7f7..a61b2575 100644 --- a/src/UglyToad.PdfPig.Tests/Fonts/SystemFonts/Linux.cs +++ b/src/UglyToad.PdfPig.Tests/Fonts/SystemFonts/Linux.cs @@ -5,6 +5,8 @@ using Xunit; namespace UglyToad.PdfPig.Tests.Fonts.SystemFonts { + using PdfPig.Core; + public class Linux { public static IEnumerable DataExtract => new[] @@ -12,19 +14,43 @@ namespace UglyToad.PdfPig.Tests.Fonts.SystemFonts new object[] { "90 180 270 rotated.pdf", - new object[][] - { - new object[] { "[(x:53.88, y:759.48), 2.495859375, 0]", 0.0 }, - new object[] { "[(x:514.925312502883, y:744.099765720344), 6.83203125, 7.94531249999983]", -90.0 }, - new object[] { "[(x:512.505390717836, y:736.603703191305), 5.1796875, 5.68945312499983]", -90.0 }, - new object[] { "[(x:512.505390785898, y:730.931828191305), 3.99609375, 5.52539062499994]", -90.0 }, + new ExpectedLetterData[] + { + new ExpectedLetterData + { + TopLeft = new PdfPoint(53.88, 759.48), + Width = 2.495859375, + Height = 0, + Rotation = 0 + }, + new ExpectedLetterData + { + TopLeft = new PdfPoint(514.925312502883, 744.099765720344), + Width = 6.83203125, + Height = 7.94531249999983, + Rotation = -90 + }, + new ExpectedLetterData + { + TopLeft = new PdfPoint(512.505390717836, 736.603703191305), + Width = 5.1796875, + Height = 5.68945312499983, + Rotation = -90 + }, + new ExpectedLetterData + { + TopLeft = new PdfPoint(512.505390785898, 730.931828191305), + Width = 3.99609375, + Height = 5.52539062499994, + Rotation = -90 + }, } }, }; [SkippableTheory] [MemberData(nameof(DataExtract))] - public void GetCorrectBBoxLinux(string name, object[][] expected) + public void GetCorrectBBoxLinux(string name, ExpectedLetterData[] expected) { // success on Windows but LinuxSystemFontLister cannot find the 'TimesNewRomanPSMT' font var font = SystemFontFinder.Instance.GetTrueTypeFont("TimesNewRomanPSMT"); @@ -36,13 +62,28 @@ namespace UglyToad.PdfPig.Tests.Fonts.SystemFonts var page = document.GetPage(1); for (int i = 0; i < expected.Length; i++) { - string bbox = (string)expected[i][0]; - var rotation = (double)expected[i][1]; - var current = page.Letters[i]; - Assert.Equal(bbox, current.GlyphRectangle.ToString()); - Assert.Equal(rotation, current.GlyphRectangle.Rotation, 3); + var expectedData = expected[i]; + + var current = page.Letters[i]; + + Assert.Equal(expectedData.TopLeft.X, current.GlyphRectangle.TopLeft.X, 7); + Assert.Equal(expectedData.TopLeft.Y, current.GlyphRectangle.TopLeft.Y, 7); + Assert.Equal(expectedData.Width, current.GlyphRectangle.Width, 7); + Assert.Equal(expectedData.Height, current.GlyphRectangle.Height, 7); + Assert.Equal(expectedData.Rotation, current.GlyphRectangle.Rotation, 3); } } + } + + public class ExpectedLetterData + { + public PdfPoint TopLeft { get; set; } + + public double Width { get; set; } + + public double Height { get; set; } + + public double Rotation { get; set; } } } } diff --git a/src/UglyToad.PdfPig.Tests/UglyToad.PdfPig.Tests.csproj b/src/UglyToad.PdfPig.Tests/UglyToad.PdfPig.Tests.csproj index 6f7f0f5e..878d9824 100644 --- a/src/UglyToad.PdfPig.Tests/UglyToad.PdfPig.Tests.csproj +++ b/src/UglyToad.PdfPig.Tests/UglyToad.PdfPig.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.0 + netcoreapp2.0;net6.0 true false full diff --git a/src/UglyToad.PdfPig.Tokenization/UglyToad.PdfPig.Tokenization.csproj b/src/UglyToad.PdfPig.Tokenization/UglyToad.PdfPig.Tokenization.csproj index dd207610..a4789e7e 100644 --- a/src/UglyToad.PdfPig.Tokenization/UglyToad.PdfPig.Tokenization.csproj +++ b/src/UglyToad.PdfPig.Tokenization/UglyToad.PdfPig.Tokenization.csproj @@ -1,6 +1,6 @@ - netstandard2.0;net45;net451;net452;net46;net461;net462;net47 + netstandard2.0;net45;net451;net452;net46;net461;net462;net47;net6.0 latest 0.1.6-alpha001 False diff --git a/src/UglyToad.PdfPig.Tokens/UglyToad.PdfPig.Tokens.csproj b/src/UglyToad.PdfPig.Tokens/UglyToad.PdfPig.Tokens.csproj index 22a90f7d..48dcb4ca 100644 --- a/src/UglyToad.PdfPig.Tokens/UglyToad.PdfPig.Tokens.csproj +++ b/src/UglyToad.PdfPig.Tokens/UglyToad.PdfPig.Tokens.csproj @@ -1,6 +1,6 @@ - netstandard2.0;net45;net451;net452;net46;net461;net462;net47 + netstandard2.0;net45;net451;net452;net46;net461;net462;net47;net6.0 latest 0.1.6-alpha001 False diff --git a/src/UglyToad.PdfPig/Encryption/AesEncryptionHelper.cs b/src/UglyToad.PdfPig/Encryption/AesEncryptionHelper.cs index 3e4cd7b6..f572a25d 100644 --- a/src/UglyToad.PdfPig/Encryption/AesEncryptionHelper.cs +++ b/src/UglyToad.PdfPig/Encryption/AesEncryptionHelper.cs @@ -1,6 +1,7 @@ namespace UglyToad.PdfPig.Encryption { using System; + using System.Diagnostics; using System.IO; using System.Security.Cryptography; @@ -20,7 +21,7 @@ var iv = new byte[16]; Array.Copy(data, iv, iv.Length); - + using (var rijndael = Rijndael.Create()) { rijndael.Key = finalKey; @@ -28,6 +29,11 @@ var buffer = new byte[256]; + if (data.Length > 256) + { + Debugger.Break(); + } + using (var decryptor = rijndael.CreateDecryptor(rijndael.Key, rijndael.IV)) using (var input = new MemoryStream(data)) using (var output = new MemoryStream()) @@ -36,15 +42,15 @@ using (var cryptoStream = new CryptoStream(input, decryptor, CryptoStreamMode.Read)) { int read; - while ((read = cryptoStream.Read(buffer, 0, buffer.Length)) != -1) + do { - output.Write(buffer, 0, read); + read = cryptoStream.Read(buffer, 0, buffer.Length); - if (read < buffer.Length) + if (read > 0) { - break; + output.Write(buffer, 0, read); } - } + } while (read > 0); return output.ToArray(); } diff --git a/src/UglyToad.PdfPig/UglyToad.PdfPig.csproj b/src/UglyToad.PdfPig/UglyToad.PdfPig.csproj index 89b3d5f4..332decf9 100644 --- a/src/UglyToad.PdfPig/UglyToad.PdfPig.csproj +++ b/src/UglyToad.PdfPig/UglyToad.PdfPig.csproj @@ -1,6 +1,6 @@ - netstandard2.0;net45;net451;net452;net46;net461;net462;net47 + netstandard2.0;net45;net451;net452;net46;net461;net462;net47;net6.0 latest 0.1.6-alpha001 False diff --git a/tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj b/tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj index ec25f460..c2108392 100644 --- a/tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj +++ b/tools/UglyToad.PdfPig.Package/UglyToad.PdfPig.Package.csproj @@ -1,6 +1,6 @@ - netstandard2.0;net45;net451;net452;net46;net461;net462;net47 + netstandard2.0;net45;net451;net452;net46;net461;net462;net47;net6.0 PdfPig full UglyToad