diff --git a/Directory.Build.props b/Directory.Build.props index 097bb99..4c76e77 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -45,12 +45,7 @@ enable true strict - - - - $(DefineConstants);SUPPORTS_MEMBERNOTNULL - $(DefineConstants);SUPPORTS_INIT - $(DefineConstants);SUPPORTS_TYPED_ENUM_ISDEFINED + enable diff --git a/Directory.Build.targets b/Directory.Build.targets index 32ff1d6..35d8d32 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -7,8 +7,22 @@ - - + + + + + + + + + + + + + + + + diff --git a/samples/Synercoding.FileFormats.Pdf.ConsoleTester/Program.cs b/samples/Synercoding.FileFormats.Pdf.ConsoleTester/Program.cs index 55514e1..b3f5be4 100644 --- a/samples/Synercoding.FileFormats.Pdf.ConsoleTester/Program.cs +++ b/samples/Synercoding.FileFormats.Pdf.ConsoleTester/Program.cs @@ -2,11 +2,6 @@ using Synercoding.FileFormats.Pdf.LowLevel.Colors; using Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces; using Synercoding.FileFormats.Pdf.LowLevel.Text; -using Synercoding.Primitives; -using Synercoding.Primitives.Extensions; -using System; -using System.IO; -using static Synercoding.Primitives.ValueCreator; namespace Synercoding.FileFormats.Pdf.ConsoleTester; diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 652e21c..896375d 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,7 +2,7 @@ - net7.0;net6.0;netstandard2.1 + net7.0;net6.0 $(MSBuildAllProjects);$(MSBuildThisFileDirectory)..\Directory.Build.props src diff --git a/src/Synercoding.FileFormats.Pdf/DocumentInformation.cs b/src/Synercoding.FileFormats.Pdf/DocumentInformation.cs index 6f5f3cb..baa2412 100644 --- a/src/Synercoding.FileFormats.Pdf/DocumentInformation.cs +++ b/src/Synercoding.FileFormats.Pdf/DocumentInformation.cs @@ -1,6 +1,4 @@ using Synercoding.FileFormats.Pdf.LowLevel; -using System; -using System.Collections.Generic; namespace Synercoding.FileFormats.Pdf; diff --git a/src/Synercoding.FileFormats.Pdf/Extensions/IContentContextExtensions.cs b/src/Synercoding.FileFormats.Pdf/Extensions/IContentContextExtensions.cs index 9d33fb4..fe49660 100644 --- a/src/Synercoding.FileFormats.Pdf/Extensions/IContentContextExtensions.cs +++ b/src/Synercoding.FileFormats.Pdf/Extensions/IContentContextExtensions.cs @@ -1,6 +1,3 @@ -using System; -using System.Threading.Tasks; - namespace Synercoding.FileFormats.Pdf.Extensions; /// diff --git a/src/Synercoding.FileFormats.Pdf/Extensions/IPageContentContextExtensions.cs b/src/Synercoding.FileFormats.Pdf/Extensions/IPageContentContextExtensions.cs index e697d25..9d7e0d6 100644 --- a/src/Synercoding.FileFormats.Pdf/Extensions/IPageContentContextExtensions.cs +++ b/src/Synercoding.FileFormats.Pdf/Extensions/IPageContentContextExtensions.cs @@ -1,11 +1,6 @@ using Synercoding.FileFormats.Pdf.Internals; using Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces; using Synercoding.FileFormats.Pdf.LowLevel.Text; -using Synercoding.Primitives; -using Synercoding.Primitives.Extensions; -using System; -using System.Linq; -using System.Threading.Tasks; namespace Synercoding.FileFormats.Pdf.Extensions; diff --git a/src/Synercoding.FileFormats.Pdf/Extensions/IShapeContextExtensions.cs b/src/Synercoding.FileFormats.Pdf/Extensions/IShapeContextExtensions.cs index e67d85f..63c8736 100644 --- a/src/Synercoding.FileFormats.Pdf/Extensions/IShapeContextExtensions.cs +++ b/src/Synercoding.FileFormats.Pdf/Extensions/IShapeContextExtensions.cs @@ -1,6 +1,3 @@ -using Synercoding.Primitives; -using Synercoding.Primitives.Extensions; - namespace Synercoding.FileFormats.Pdf.Extensions; /// diff --git a/src/Synercoding.FileFormats.Pdf/Extensions/PrimitiveExtensions.cs b/src/Synercoding.FileFormats.Pdf/Extensions/PrimitiveExtensions.cs index 9471c61..88c2f7d 100644 --- a/src/Synercoding.FileFormats.Pdf/Extensions/PrimitiveExtensions.cs +++ b/src/Synercoding.FileFormats.Pdf/Extensions/PrimitiveExtensions.cs @@ -1,5 +1,3 @@ -using Synercoding.Primitives; - namespace Synercoding.FileFormats.Pdf.Extensions; /// diff --git a/src/Synercoding.FileFormats.Pdf/GraphicState.cs b/src/Synercoding.FileFormats.Pdf/GraphicState.cs index a633906..f489acf 100644 --- a/src/Synercoding.FileFormats.Pdf/GraphicState.cs +++ b/src/Synercoding.FileFormats.Pdf/GraphicState.cs @@ -1,7 +1,6 @@ using Synercoding.FileFormats.Pdf.LowLevel.Colors; using Synercoding.FileFormats.Pdf.LowLevel.Graphics; using Synercoding.FileFormats.Pdf.LowLevel.Text; -using System.Linq; namespace Synercoding.FileFormats.Pdf; diff --git a/src/Synercoding.FileFormats.Pdf/IContentContext.cs b/src/Synercoding.FileFormats.Pdf/IContentContext.cs index afd6952..1f4a37e 100644 --- a/src/Synercoding.FileFormats.Pdf/IContentContext.cs +++ b/src/Synercoding.FileFormats.Pdf/IContentContext.cs @@ -1,8 +1,6 @@ using Synercoding.FileFormats.Pdf.LowLevel; using Synercoding.FileFormats.Pdf.LowLevel.Colors; using Synercoding.FileFormats.Pdf.LowLevel.Graphics; -using System; -using System.Threading.Tasks; namespace Synercoding.FileFormats.Pdf; diff --git a/src/Synercoding.FileFormats.Pdf/IPageContentContext.cs b/src/Synercoding.FileFormats.Pdf/IPageContentContext.cs index c214368..84fe573 100644 --- a/src/Synercoding.FileFormats.Pdf/IPageContentContext.cs +++ b/src/Synercoding.FileFormats.Pdf/IPageContentContext.cs @@ -1,6 +1,4 @@ using Synercoding.FileFormats.Pdf.LowLevel; -using System; -using System.Threading.Tasks; namespace Synercoding.FileFormats.Pdf; diff --git a/src/Synercoding.FileFormats.Pdf/Image.cs b/src/Synercoding.FileFormats.Pdf/Image.cs index df84367..9500f2f 100644 --- a/src/Synercoding.FileFormats.Pdf/Image.cs +++ b/src/Synercoding.FileFormats.Pdf/Image.cs @@ -1,8 +1,6 @@ using SixLabors.ImageSharp; using Synercoding.FileFormats.Pdf.LowLevel; using Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces; -using System; -using System.IO; namespace Synercoding.FileFormats.Pdf; @@ -21,7 +19,7 @@ internal Image(PdfReference id, SixLabors.ImageSharp.Image image) image.SaveAsJpeg(ms, new SixLabors.ImageSharp.Formats.Jpeg.JpegEncoder() { Quality = 100, - ColorType = SixLabors.ImageSharp.Formats.Jpeg.JpegColorType.YCbCrRatio444 + ColorType = SixLabors.ImageSharp.Formats.Jpeg.JpegEncodingColor.YCbCrRatio444 }); Width = image.Width; Height = image.Height; diff --git a/src/Synercoding.FileFormats.Pdf/Internals/ByteSizes.cs b/src/Synercoding.FileFormats.Pdf/Internals/ByteSizes.cs index 07daa5b..234f02f 100644 --- a/src/Synercoding.FileFormats.Pdf/Internals/ByteSizes.cs +++ b/src/Synercoding.FileFormats.Pdf/Internals/ByteSizes.cs @@ -1,4 +1,3 @@ -using System; using System.Globalization; namespace Synercoding.FileFormats.Pdf.Internals; diff --git a/src/Synercoding.FileFormats.Pdf/Internals/Map.cs b/src/Synercoding.FileFormats.Pdf/Internals/Map.cs index 1fd6969..3ff2fa7 100644 --- a/src/Synercoding.FileFormats.Pdf/Internals/Map.cs +++ b/src/Synercoding.FileFormats.Pdf/Internals/Map.cs @@ -1,6 +1,4 @@ -using System; using System.Collections; -using System.Collections.Generic; namespace Synercoding.FileFormats.Pdf.Internals; diff --git a/src/Synercoding.FileFormats.Pdf/Internals/PageContentContext.cs b/src/Synercoding.FileFormats.Pdf/Internals/PageContentContext.cs index 385621d..1174e7d 100644 --- a/src/Synercoding.FileFormats.Pdf/Internals/PageContentContext.cs +++ b/src/Synercoding.FileFormats.Pdf/Internals/PageContentContext.cs @@ -1,8 +1,6 @@ using Synercoding.FileFormats.Pdf.LowLevel; using Synercoding.FileFormats.Pdf.LowLevel.Colors; using Synercoding.FileFormats.Pdf.LowLevel.Graphics; -using System; -using System.Threading.Tasks; namespace Synercoding.FileFormats.Pdf.Internals; diff --git a/src/Synercoding.FileFormats.Pdf/Internals/ShapesContentContext.cs b/src/Synercoding.FileFormats.Pdf/Internals/ShapesContentContext.cs index e553b40..5715ee8 100644 --- a/src/Synercoding.FileFormats.Pdf/Internals/ShapesContentContext.cs +++ b/src/Synercoding.FileFormats.Pdf/Internals/ShapesContentContext.cs @@ -1,8 +1,6 @@ using Synercoding.FileFormats.Pdf.LowLevel; using Synercoding.FileFormats.Pdf.LowLevel.Colors; using Synercoding.FileFormats.Pdf.LowLevel.Graphics; -using System; -using System.Threading.Tasks; namespace Synercoding.FileFormats.Pdf.Internals; diff --git a/src/Synercoding.FileFormats.Pdf/Internals/SpanHelper.cs b/src/Synercoding.FileFormats.Pdf/Internals/SpanHelper.cs index dbdbd45..abe8b3b 100644 --- a/src/Synercoding.FileFormats.Pdf/Internals/SpanHelper.cs +++ b/src/Synercoding.FileFormats.Pdf/Internals/SpanHelper.cs @@ -1,5 +1,3 @@ -using System; - namespace Synercoding.FileFormats.Pdf.Internals; internal static class SpanHelper diff --git a/src/Synercoding.FileFormats.Pdf/Internals/StringHelper.cs b/src/Synercoding.FileFormats.Pdf/Internals/StringHelper.cs index 81f2d1d..5ff7d2a 100644 --- a/src/Synercoding.FileFormats.Pdf/Internals/StringHelper.cs +++ b/src/Synercoding.FileFormats.Pdf/Internals/StringHelper.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using System.Text; namespace Synercoding.FileFormats.Pdf.Internals; diff --git a/src/Synercoding.FileFormats.Pdf/Internals/TextContentContext.cs b/src/Synercoding.FileFormats.Pdf/Internals/TextContentContext.cs index e9fe4c3..9f32682 100644 --- a/src/Synercoding.FileFormats.Pdf/Internals/TextContentContext.cs +++ b/src/Synercoding.FileFormats.Pdf/Internals/TextContentContext.cs @@ -2,8 +2,6 @@ using Synercoding.FileFormats.Pdf.LowLevel.Colors; using Synercoding.FileFormats.Pdf.LowLevel.Graphics; using Synercoding.FileFormats.Pdf.LowLevel.Text; -using System; -using System.Threading.Tasks; namespace Synercoding.FileFormats.Pdf.Internals; diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/CmykColor.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/CmykColor.cs index 4dba62c..1698764 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/CmykColor.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/CmykColor.cs @@ -1,5 +1,4 @@ using Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces; -using System; namespace Synercoding.FileFormats.Pdf.LowLevel.Colors; diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/Color.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/Color.cs index 6b709ea..dd7bd58 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/Color.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/Color.cs @@ -1,5 +1,4 @@ using Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces; -using System; namespace Synercoding.FileFormats.Pdf.LowLevel.Colors; diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/ColorSpace.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/ColorSpace.cs index 32c4b46..0d4dd19 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/ColorSpace.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/ColorSpace.cs @@ -1,5 +1,3 @@ -using System; - namespace Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces; /// diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/DeviceCMYK.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/DeviceCMYK.cs index ab1a463..0804c75 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/DeviceCMYK.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/DeviceCMYK.cs @@ -1,5 +1,3 @@ -using System; - namespace Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces; /// diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/DeviceGray.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/DeviceGray.cs index b8899c6..261cb6c 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/DeviceGray.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/DeviceGray.cs @@ -1,5 +1,3 @@ -using System; - namespace Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces; /// diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/DeviceRGB.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/DeviceRGB.cs index 4395d48..ce674b6 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/DeviceRGB.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/DeviceRGB.cs @@ -1,5 +1,3 @@ -using System; - namespace Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces; /// diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/Separation.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/Separation.cs index fa84040..b70b503 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/Separation.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/ColorSpaces/Separation.cs @@ -1,5 +1,3 @@ -using System; - namespace Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces; /// diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/GrayColor.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/GrayColor.cs index ec920d1..8655e31 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/GrayColor.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/GrayColor.cs @@ -1,5 +1,4 @@ using Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces; -using System; namespace Synercoding.FileFormats.Pdf.LowLevel.Colors; diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/RgbColor.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/RgbColor.cs index 13d205a..079905f 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/RgbColor.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/RgbColor.cs @@ -1,5 +1,4 @@ using Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces; -using System; namespace Synercoding.FileFormats.Pdf.LowLevel.Colors; diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/SpotColor.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/SpotColor.cs index 9226516..6c02235 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/SpotColor.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Colors/SpotColor.cs @@ -1,5 +1,4 @@ using Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces; -using System; namespace Synercoding.FileFormats.Pdf.LowLevel.Colors; diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/ContentStream.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/ContentStream.cs index ec6c0d9..a662912 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/ContentStream.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/ContentStream.cs @@ -4,11 +4,6 @@ using Synercoding.FileFormats.Pdf.LowLevel.Graphics; using Synercoding.FileFormats.Pdf.LowLevel.Internal; using Synercoding.FileFormats.Pdf.LowLevel.Text; -using Synercoding.Primitives; -using Synercoding.Primitives.Extensions; -using System; -using System.IO; -using System.Linq; using Color = Synercoding.FileFormats.Pdf.LowLevel.Colors.Color; using Point = Synercoding.Primitives.Point; diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Extensions/PdfStreamExtensions.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Extensions/PdfStreamExtensions.cs index f833746..fd48eb0 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Extensions/PdfStreamExtensions.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Extensions/PdfStreamExtensions.cs @@ -1,7 +1,3 @@ -using Synercoding.Primitives; -using System; -using System.IO; - namespace Synercoding.FileFormats.Pdf.LowLevel.Extensions; /// @@ -259,8 +255,16 @@ public static PdfStream WriteStringLiteral(this PdfStream stream, string value) stream.Write('\\').Write(')'); else if (c == '\\') stream.Write('\\').Write('\\'); - else if (c > 0x7F && c < 0x200) - stream.Write('\\').Write(_toOctal(c)); + else if (c > 0x7F && c <= 0xFF) + { + var octal = _toOctal(c); + _ = octal switch + { + < 10 => stream.Write('\\').Write('0').Write('0').Write(octal), + < 100 => stream.Write('\\').Write('0').Write(octal), + _ => stream.Write('\\').Write(octal) + }; + } else if (c <= 0x7F) stream.Write(c); else diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Extensions/StreamFilterExtensions.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Extensions/StreamFilterExtensions.cs index c1252da..fd39a5f 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Extensions/StreamFilterExtensions.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Extensions/StreamFilterExtensions.cs @@ -1,5 +1,3 @@ -using System; - namespace Synercoding.FileFormats.Pdf.LowLevel.Extensions; internal static class StreamFilterExtensions diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Graphics/Dash.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Graphics/Dash.cs index e3fe6dc..d29f8c1 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Graphics/Dash.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Graphics/Dash.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; - namespace Synercoding.FileFormats.Pdf.LowLevel.Graphics; /// diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Internal/PageResources.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Internal/PageResources.cs index e2884dd..7fc484e 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Internal/PageResources.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Internal/PageResources.cs @@ -2,9 +2,6 @@ using Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces; using Synercoding.FileFormats.Pdf.LowLevel.Text; using Synercoding.FileFormats.Pdf.LowLevel.XRef; -using System; -using System.Collections.Generic; -using System.Linq; namespace Synercoding.FileFormats.Pdf.LowLevel.Internal; diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Internal/PageTree.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Internal/PageTree.cs index ac14daf..453af39 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Internal/PageTree.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Internal/PageTree.cs @@ -1,5 +1,3 @@ -using System.Collections.Generic; - namespace Synercoding.FileFormats.Pdf.LowLevel.Internal; internal class PageTree diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/ObjectStream.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/ObjectStream.cs index a79d055..cacc7af 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/ObjectStream.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/ObjectStream.cs @@ -3,9 +3,6 @@ using Synercoding.FileFormats.Pdf.LowLevel.Internal; using Synercoding.FileFormats.Pdf.LowLevel.Text; using Synercoding.FileFormats.Pdf.LowLevel.XRef; -using System; -using System.IO; -using System.Linq; namespace Synercoding.FileFormats.Pdf.LowLevel; @@ -124,6 +121,7 @@ public ObjectStream Write(PdfPage page) .WriteIfNotNull(PdfName.Get("CropBox"), page.CropBox) .WriteIfNotNull(PdfName.Get("BleedBox"), page.BleedBox) .WriteIfNotNull(PdfName.Get("TrimBox"), page.TrimBox) + .WriteIfNotNull(PdfName.Get("ArtBox"), page.ArtBox) .WriteIfNotNull(PdfName.Get("Rotate"), (int?)page.Rotation); // Resources diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/PdfDictionary.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/PdfDictionary.cs index 04690b6..844001d 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/PdfDictionary.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/PdfDictionary.cs @@ -1,6 +1,4 @@ using Synercoding.FileFormats.Pdf.LowLevel.Extensions; -using Synercoding.Primitives; -using System; namespace Synercoding.FileFormats.Pdf.LowLevel; diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/PdfName.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/PdfName.cs index 0b9d09d..b01164f 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/PdfName.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/PdfName.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; using System.Text; namespace Synercoding.FileFormats.Pdf.LowLevel; @@ -96,25 +93,13 @@ private static string _encode(string input) // 0xff because only ascii is supported in pdf names var encoded = c switch { - // Pdf reserved characters - ' ' => "#20", - '#' => "#23", - '%' => "#25", - '(' => "#28", - ')' => "#29", - '/' => "#2f", - '<' => "#3c", - '>' => "#3e", - '[' => "#5b", - ']' => "#5d", - '{' => "#7b", - '}' => "#7d", + (char)0 => throw new InvalidOperationException("NULL character is not allowed in a pdf name."), + var cc when cc >= 'a' && cc <= 'z' => cc.ToString(), + var cc when cc >= 'A' && cc <= 'Z' => cc.ToString(), + var cc when cc >= '0' && cc <= '9' => cc.ToString(), // special characters var cc when cc < 16 => $"#0{Convert.ToString(cc, 16)}", - var cc when cc < 32 => '#' + Convert.ToString(cc, 16), - var cc when cc > 126 => '#' + Convert.ToString(cc, 16), - // "readable characters" - var cc => cc.ToString() + var cc => '#' + Convert.ToString(cc, 16), }; pdfName.Append(encoded); } diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/PdfStream.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/PdfStream.cs index d974a92..567b152 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/PdfStream.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/PdfStream.cs @@ -1,7 +1,5 @@ using Synercoding.FileFormats.Pdf.Internals; -using System; using System.Globalization; -using System.IO; using System.Text; namespace Synercoding.FileFormats.Pdf.LowLevel; diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Text/Font.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Text/Font.cs index 7474620..8309aeb 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Text/Font.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Text/Font.cs @@ -1,5 +1,3 @@ -using System; - namespace Synercoding.FileFormats.Pdf.LowLevel.Text; /// diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/Text/Type1StandardFont.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/Text/Type1StandardFont.cs index d843635..04cc318 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/Text/Type1StandardFont.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/Text/Type1StandardFont.cs @@ -1,5 +1,3 @@ -using System; - namespace Synercoding.FileFormats.Pdf.LowLevel.Text; /// diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/Entry.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/Entry.cs index 4968d2d..e145cdb 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/Entry.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/Entry.cs @@ -1,5 +1,3 @@ -using System; - namespace Synercoding.FileFormats.Pdf.LowLevel.XRef; internal readonly struct Entry diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/Section.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/Section.cs index eae01b1..7f4919f 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/Section.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/Section.cs @@ -1,5 +1,4 @@ using Synercoding.FileFormats.Pdf.Internals; -using System; namespace Synercoding.FileFormats.Pdf.LowLevel.XRef; diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/Table.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/Table.cs index 9820ef1..81f8063 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/Table.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/Table.cs @@ -1,5 +1,3 @@ -using System; - namespace Synercoding.FileFormats.Pdf.LowLevel.XRef; internal class Table diff --git a/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/TableBuilder.cs b/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/TableBuilder.cs index d5ec713..f6b104b 100644 --- a/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/TableBuilder.cs +++ b/src/Synercoding.FileFormats.Pdf/LowLevel/XRef/TableBuilder.cs @@ -1,6 +1,4 @@ using Synercoding.FileFormats.Pdf.LowLevel.Internal; -using System.Collections.Generic; -using System.Linq; namespace Synercoding.FileFormats.Pdf.LowLevel.XRef; diff --git a/src/Synercoding.FileFormats.Pdf/Matrix.cs b/src/Synercoding.FileFormats.Pdf/Matrix.cs index b7707ae..005ded7 100644 --- a/src/Synercoding.FileFormats.Pdf/Matrix.cs +++ b/src/Synercoding.FileFormats.Pdf/Matrix.cs @@ -1,4 +1,3 @@ -using System; using System.Runtime.CompilerServices; namespace Synercoding.FileFormats.Pdf; diff --git a/src/Synercoding.FileFormats.Pdf/PackageDetails.props b/src/Synercoding.FileFormats.Pdf/PackageDetails.props index cd0ccfe..3a425b4 100644 --- a/src/Synercoding.FileFormats.Pdf/PackageDetails.props +++ b/src/Synercoding.FileFormats.Pdf/PackageDetails.props @@ -10,7 +10,7 @@ Synercoding.FileFormats.Pdf Synercoding.FileFormats.Pdf Contains classes which makes it easy to quickly create a pdf file. - Rewritten most of the API surface to provide a uniform way to interact with the content. + A fix with octal literal string encoding, and rewritten pdfname encoding, renamed art to artbox, and encoded artbox in resulting pdf. diff --git a/src/Synercoding.FileFormats.Pdf/PdfPage.cs b/src/Synercoding.FileFormats.Pdf/PdfPage.cs index 74d1729..80a3096 100644 --- a/src/Synercoding.FileFormats.Pdf/PdfPage.cs +++ b/src/Synercoding.FileFormats.Pdf/PdfPage.cs @@ -2,9 +2,6 @@ using Synercoding.FileFormats.Pdf.LowLevel; using Synercoding.FileFormats.Pdf.LowLevel.Internal; using Synercoding.FileFormats.Pdf.LowLevel.XRef; -using Synercoding.Primitives; -using Synercoding.Primitives.Extensions; -using System; namespace Synercoding.FileFormats.Pdf; @@ -61,13 +58,8 @@ public PageRotation? Rotation set { const string ARGUMENT_OUT_OF_RANGE_MESSAGE = "The provided value can only be increments of 90."; -#if SUPPORTS_TYPED_ENUM_ISDEFINED if (value is not null && !Enum.IsDefined(value.Value)) throw new ArgumentOutOfRangeException(nameof(Rotation), value, ARGUMENT_OUT_OF_RANGE_MESSAGE); -#else - if (value is not null && !Enum.IsDefined(typeof(PageRotation), value.Value)) - throw new ArgumentOutOfRangeException(nameof(Rotation), value, ARGUMENT_OUT_OF_RANGE_MESSAGE); -#endif _rotation = value; } @@ -96,7 +88,7 @@ public PageRotation? Rotation /// /// The art box of the /// - public Rectangle? Art { get; set; } + public Rectangle? ArtBox { get; set; } /// public void Dispose() diff --git a/src/Synercoding.FileFormats.Pdf/PdfWriter.cs b/src/Synercoding.FileFormats.Pdf/PdfWriter.cs index 1cecde9..0d685d5 100644 --- a/src/Synercoding.FileFormats.Pdf/PdfWriter.cs +++ b/src/Synercoding.FileFormats.Pdf/PdfWriter.cs @@ -3,10 +3,7 @@ using Synercoding.FileFormats.Pdf.LowLevel.Extensions; using Synercoding.FileFormats.Pdf.LowLevel.Internal; using Synercoding.FileFormats.Pdf.LowLevel.XRef; -using System; -using System.IO; using System.Reflection; -using System.Threading.Tasks; namespace Synercoding.FileFormats.Pdf; diff --git a/src/Synercoding.FileFormats.Pdf/Synercoding.FileFormats.Pdf.csproj b/src/Synercoding.FileFormats.Pdf/Synercoding.FileFormats.Pdf.csproj index fd772e4..e8eaaf9 100644 --- a/src/Synercoding.FileFormats.Pdf/Synercoding.FileFormats.Pdf.csproj +++ b/src/Synercoding.FileFormats.Pdf/Synercoding.FileFormats.Pdf.csproj @@ -4,7 +4,6 @@ - diff --git a/src/Synercoding.FileFormats.Pdf/System/IsExternalInit.cs b/src/Synercoding.FileFormats.Pdf/System/IsExternalInit.cs deleted file mode 100644 index c89fa7a..0000000 --- a/src/Synercoding.FileFormats.Pdf/System/IsExternalInit.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#if SUPPORTS_INIT -using System.Runtime.CompilerServices; - -[assembly: TypeForwardedTo(typeof(IsExternalInit))] -#else -using System.ComponentModel; - -namespace System.Runtime.CompilerServices -{ - /// - /// Reserved to be used by the compiler for tracking metadata. - /// This class should not be used by developers in source code. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - internal static class IsExternalInit - { - } -} -#endif \ No newline at end of file diff --git a/src/Synercoding.FileFormats.Pdf/System/MemberNotNull.cs b/src/Synercoding.FileFormats.Pdf/System/MemberNotNull.cs deleted file mode 100644 index ad250f9..0000000 --- a/src/Synercoding.FileFormats.Pdf/System/MemberNotNull.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#if SUPPORTS_MEMBERNOTNULL -using System.Runtime.CompilerServices; - -[assembly: TypeForwardedTo(typeof(System.Diagnostics.CodeAnalysis.MemberNotNullAttribute))] -[assembly: TypeForwardedTo(typeof(System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute))] -#else -namespace System.Diagnostics.CodeAnalysis -{ - /// Specifies that the method or property will ensure that the listed field and property members have not-null values. - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] - internal sealed class MemberNotNullAttribute : Attribute - { - /// Initializes the attribute with a field or property member. - /// - /// The field or property member that is promised to be not-null. - /// - public MemberNotNullAttribute(string member) => Members = new[] { member }; - - /// Initializes the attribute with the list of field and property members. - /// - /// The list of field and property members that are promised to be not-null. - /// - public MemberNotNullAttribute(params string[] members) => Members = members; - - /// Gets field or property member names. - public string[] Members { get; } - } - - /// Specifies that the method or property will ensure that the listed field and property members have not-null values when returning with the specified return value condition. - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] - internal sealed class MemberNotNullWhenAttribute : Attribute - { - /// Initializes the attribute with the specified return value condition and a field or property member. - /// - /// The return value condition. If the method returns this value, the associated parameter will not be null. - /// - /// - /// The field or property member that is promised to be not-null. - /// - public MemberNotNullWhenAttribute(bool returnValue, string member) - { - ReturnValue = returnValue; - Members = new[] { member }; - } - - /// Initializes the attribute with the specified return value condition and list of field and property members. - /// - /// The return value condition. If the method returns this value, the associated parameter will not be null. - /// - /// - /// The list of field and property members that are promised to be not-null. - /// - public MemberNotNullWhenAttribute(bool returnValue, params string[] members) - { - ReturnValue = returnValue; - Members = members; - } - - /// Gets the return value condition. - public bool ReturnValue { get; } - - /// Gets field or property member names. - public string[] Members { get; } - } -} -#endif \ No newline at end of file