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
7 changes: 1 addition & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Features>strict</Features>
</PropertyGroup>

<PropertyGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)','net5.0'))">
<DefineConstants>$(DefineConstants);SUPPORTS_MEMBERNOTNULL</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_INIT</DefineConstants>
<DefineConstants>$(DefineConstants);SUPPORTS_TYPED_ENUM_ISDEFINED</DefineConstants>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

</Project>
18 changes: 16 additions & 2 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,22 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Update="SixLabors.ImageSharp" Version="2.1.*" />
<PackageReference Update="Synercoding.Primitives" Version="1.0.0-rc09" />
<PackageReference Update="SixLabors.ImageSharp" Version="3.0.*" />
</ItemGroup>

<!-- Disable auto imports/usings from ImageSharp -->
<ItemGroup>
<Using Remove="SixLabors.ImageSharp" />
<Using Remove="SixLabors.ImageSharp.PixelFormats" />
<Using Remove="SixLabors.ImageSharp.Processing" />
</ItemGroup>

<!-- For ease of use -->
<ItemGroup>
<PackageReference Include="Synercoding.Primitives" Version="1.0.0-rc09" />
<Using Static="true" Include="Synercoding.Primitives.ValueCreator" />
<Using Include="Synercoding.Primitives" />
<Using Include="Synercoding.Primitives.Extensions" />
</ItemGroup>

</Project>
5 changes: 0 additions & 5 deletions samples/Synercoding.FileFormats.Pdf.ConsoleTester/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileDirectory)..\Directory.Build.props</MSBuildAllProjects>
<SynercodingProjectCategory>src</SynercodingProjectCategory>
</PropertyGroup>
Expand Down
2 changes: 0 additions & 2 deletions src/Synercoding.FileFormats.Pdf/DocumentInformation.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Synercoding.FileFormats.Pdf.LowLevel;
using System;
using System.Collections.Generic;

namespace Synercoding.FileFormats.Pdf;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Threading.Tasks;

namespace Synercoding.FileFormats.Pdf.Extensions;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Synercoding.Primitives;
using Synercoding.Primitives.Extensions;

namespace Synercoding.FileFormats.Pdf.Extensions;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Synercoding.Primitives;

namespace Synercoding.FileFormats.Pdf.Extensions;

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/Synercoding.FileFormats.Pdf/GraphicState.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 0 additions & 2 deletions src/Synercoding.FileFormats.Pdf/IContentContext.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 0 additions & 2 deletions src/Synercoding.FileFormats.Pdf/IPageContentContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Synercoding.FileFormats.Pdf.LowLevel;
using System;
using System.Threading.Tasks;

namespace Synercoding.FileFormats.Pdf;

Expand Down
4 changes: 1 addition & 3 deletions src/Synercoding.FileFormats.Pdf/Image.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/Synercoding.FileFormats.Pdf/Internals/ByteSizes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Globalization;

namespace Synercoding.FileFormats.Pdf.Internals;
Expand Down
2 changes: 0 additions & 2 deletions src/Synercoding.FileFormats.Pdf/Internals/Map.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;

namespace Synercoding.FileFormats.Pdf.Internals;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 0 additions & 2 deletions src/Synercoding.FileFormats.Pdf/Internals/SpanHelper.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Synercoding.FileFormats.Pdf.Internals;

internal static class SpanHelper
Expand Down
1 change: 0 additions & 1 deletion src/Synercoding.FileFormats.Pdf/Internals/StringHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Generic;
using System.Text;

namespace Synercoding.FileFormats.Pdf.Internals;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces;
using System;

namespace Synercoding.FileFormats.Pdf.LowLevel.Colors;

Expand Down
1 change: 0 additions & 1 deletion src/Synercoding.FileFormats.Pdf/LowLevel/Colors/Color.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces;
using System;

namespace Synercoding.FileFormats.Pdf.LowLevel.Colors;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces;
using System;

namespace Synercoding.FileFormats.Pdf.LowLevel.Colors;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces;
using System;

namespace Synercoding.FileFormats.Pdf.LowLevel.Colors;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Synercoding.FileFormats.Pdf.LowLevel.Colors.ColorSpaces;
using System;

namespace Synercoding.FileFormats.Pdf.LowLevel.Colors;

Expand Down
5 changes: 0 additions & 5 deletions src/Synercoding.FileFormats.Pdf/LowLevel/ContentStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using Synercoding.Primitives;
using System;
using System.IO;

namespace Synercoding.FileFormats.Pdf.LowLevel.Extensions;

/// <summary>
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Synercoding.FileFormats.Pdf.LowLevel.Extensions;

internal static class StreamFilterExtensions
Expand Down
2 changes: 0 additions & 2 deletions src/Synercoding.FileFormats.Pdf/LowLevel/Graphics/Dash.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections.Generic;

namespace Synercoding.FileFormats.Pdf.LowLevel.Graphics;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions src/Synercoding.FileFormats.Pdf/LowLevel/Internal/PageTree.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System.Collections.Generic;

namespace Synercoding.FileFormats.Pdf.LowLevel.Internal;

internal class PageTree
Expand Down
4 changes: 1 addition & 3 deletions src/Synercoding.FileFormats.Pdf/LowLevel/ObjectStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/Synercoding.FileFormats.Pdf/LowLevel/PdfDictionary.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Synercoding.FileFormats.Pdf.LowLevel.Extensions;
using Synercoding.Primitives;
using System;

namespace Synercoding.FileFormats.Pdf.LowLevel;

Expand Down
25 changes: 5 additions & 20 deletions src/Synercoding.FileFormats.Pdf/LowLevel/PdfName.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Synercoding.FileFormats.Pdf.LowLevel;
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 0 additions & 2 deletions src/Synercoding.FileFormats.Pdf/LowLevel/PdfStream.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/Synercoding.FileFormats.Pdf/LowLevel/Text/Font.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using System;

namespace Synercoding.FileFormats.Pdf.LowLevel.Text;

/// <summary>
Expand Down
Loading