From fd1be7d468c40e7e0d1db41f0875ddb9131ff719 Mon Sep 17 00:00:00 2001 From: Lionel Vallet Date: Sun, 15 Aug 2021 10:40:16 +0200 Subject: [PATCH 1/2] .NET Standard --- icon.png | Bin 0 -> 4213 bytes src/BuildAll-PdfSharp.sln | 81 +------- .../PdfSharp.Charting.csproj | 86 ++++----- .../Properties/AssemblyInfo.cs | 4 +- src/PdfSharp/Drawing/XFontSource.cs | 178 ++++++++---------- src/PdfSharp/PdfSharp.csproj | 92 ++++----- src/PdfSharp/Properties/AssemblyInfo.cs | 4 +- src/PdfSharp/root/ProductVersionInfo.cs | 10 +- 8 files changed, 167 insertions(+), 288 deletions(-) create mode 100644 icon.png diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..c006a7ec98d8a157bbd42a8e2673e5f964ea3778 GIT binary patch literal 4213 zcmV-*5Q^`KP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{c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932<%~ zLu~!SQ*R*X`2g1zqR)Z9CfKUR)fQ9_z79$n{)FX;8UEFkFveV;{P#G{Y!d%J58vKAex5M$1DDzvAKz%gN6DAxfKf#VtWa60h4 z{!g@ShzC1V+gl3MU|{w(@UCAqjwOiwJ=|!JRm+B83II(BV$8IMlKT+R0*aV044s~k z<{g9g{z3D>e|h-5+uZp4;m_4d6`B2V4d4ujWBlF@GF*a?B0S4IT+_yrXVtGn7$OoP zIH+93!+OrW?wH2a+zcIJU{Z7h^+hW#H5xyfQtj_RzhC;dt%9Hl4H05MOBGOpFSm-3 zRC(^RhxA{00i0vvdIU`yseMu}kkUj>7r6bNWClQEL}I{_mU>^Of|znzD+lVb2**RJ z&)s1E@H*lvwCS*=kDLSWW8mg0-^Hyggf}gwKhYBmgQdckWw$}Q#l-NXFXOHqU@}OFasy&^!qKg-uyy#|O!O(-g4!VG~U7m(g$|(WV@;tZ{;javCj(m@?^m7TCfs?mvQ6uBw z^nC3W78g`iewM1j)H3BzsBd#`2pzN`+qtbwXmxtv*PBh}@;TF%B6gHN9cqfy4gEz+ z62qD{gD5GGMU6HsiWPUY|8FQ&)w3Wak7b0&Kk1n52x@|j`;a`A2AC$~+6ccpVlTv1 z_E#eOIKlN?s}`~-T~uzo_6-hRePwOwoAxfkz`!TXv*I}oT>8f=nLch<8EvvLtUP1i zJ2L@oOg`%ruQf2b9DpoueC(uj2Y72!8|f)Dbnbq{KHg2weEn|#1m|rW^5 - - + - Debug - AnyCPU - {6F98A822-41B0-4C7A-85A6-E95C1D3E88EF} - Library - Properties - PdfSharp + netstandard2.0 + $(DefineConstants);CORE;CORE_WITH_GDI PdfSharp.Charting - v3.5 - 512 - SAK - SAK - SAK - SAK - - - - true - full - false - bin\Debug\ - TRACE;DEBUG;CORE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE;CORE - prompt - 4 - bin\Release\PdfSharp.Charting.xml - - + PDFSharp.Charting.NetStandard2 + 0 + 1.51.5185 + false + false + false + false + false + false + false + PdfSharp.Charting + false + https://github.com/LionelVallet/PDFsharp true - - StrongnameKey.snk + empira Software GmbH, Lionel Vallet + PDFSharp, NET, Standard, Core, PDF, Charting + true + icon.png + PDFsharp is the Open Source .NET library that easily creates and processes PDF documents on the fly from any .NET language. The same drawing routines can be used to create PDF documents, draw on the screen, or send output to any printer. + +This is the .NET Standard version of the PDFsharp PDF Core package. See Project Information for details. + LICENSE - - + @@ -143,21 +128,20 @@ - - - {5a6055bc-bf86-4fdd-9f62-0109db7a303b} PdfSharp - - + + + True + + + + True + + + \ No newline at end of file diff --git a/src/PdfSharp.Charting/Properties/AssemblyInfo.cs b/src/PdfSharp.Charting/Properties/AssemblyInfo.cs index 136e51f3..8c42b1a0 100644 --- a/src/PdfSharp.Charting/Properties/AssemblyInfo.cs +++ b/src/PdfSharp.Charting/Properties/AssemblyInfo.cs @@ -37,13 +37,13 @@ // [assembly: AssemblyTitle("PDFsharp Charting")] [assembly: AssemblyVersion(PdfSharp.ProductVersionInfo.Version)] -[assembly: AssemblyDescription("A .NET charting library based on PDFsharp.")] +[assembly: AssemblyDescription("A .NET charting library based on PDFsharp. (.NET Standard)")] [assembly: AssemblyConfiguration(PdfSharp.ProductVersionInfo.Configuration)] [assembly: AssemblyCompany(PdfSharp.ProductVersionInfo.Company)] #if DEBUG [assembly: AssemblyProduct(PdfSharp.ProductVersionInfo.Product + " (Debug Build)")] #else - [assembly: AssemblyProduct(PdfSharp.ProductVersionInfo.Product)] + [assembly: AssemblyProduct("PDFSharp.Charting.NetStandard2")] #endif [assembly: AssemblyCopyright(PdfSharp.ProductVersionInfo.Copyright)] [assembly: AssemblyTrademark(PdfSharp.ProductVersionInfo.Trademark)] diff --git a/src/PdfSharp/Drawing/XFontSource.cs b/src/PdfSharp/Drawing/XFontSource.cs index 6b3a5781..07115dae 100644 --- a/src/PdfSharp/Drawing/XFontSource.cs +++ b/src/PdfSharp/Drawing/XFontSource.cs @@ -37,16 +37,11 @@ using GdiFont = System.Drawing.Font; using GdiFontStyle = System.Drawing.FontStyle; #endif -#if WPF -using System.Windows; -using System.Windows.Documents; -using System.Windows.Media; -using WpfFontFamily = System.Windows.Media.FontFamily; -using WpfTypeface = System.Windows.Media.Typeface; -using WpfGlyphTypeface = System.Windows.Media.GlyphTypeface; -#endif using PdfSharp.Internal; using PdfSharp.Fonts.OpenType; +using System.Collections.Generic; +using System.Reflection; +using System.Linq; namespace PdfSharp.Drawing { @@ -66,6 +61,66 @@ internal class XFontSource // Signature of a true type collection font. const uint ttcf = 0x66637474; + /// + /// (fontName, fileName) + /// + internal static Dictionary FontFilePaths = new Dictionary(); + static XFontSource() + { + var searchingPaths = new List(); + // Application + var executingPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + searchingPaths.Add(executingPath); + // Windows + var systemFontsPath = Environment.GetFolderPath(Environment.SpecialFolder.Fonts); + if (!string.IsNullOrWhiteSpace(systemFontsPath)) + { + searchingPaths.Add(systemFontsPath); + } + else + { + // Debian + searchingPaths.Add("/usr/share/fonts/truetype"); + //searchingPaths.Add("/usr/share/X11/fonts"); + //searchingPaths.Add("/usr/X11R6/lib/X11/fonts"); + //searchingPaths.Add("~/.fonts"); + } + + foreach (var searchingPath in searchingPaths) + { + // TODO: *.ttc not supported yet! + var fileNames = new List(); + try + { + fileNames = Directory.GetFiles(searchingPath, "*.ttf", SearchOption.AllDirectories).ToList(); + } + catch (Exception ex) + { + Debug.WriteLine(ex); + continue; + } + + foreach (var fileName in fileNames) + { + try + { + var fontCollection = new System.Drawing.Text.PrivateFontCollection(); + fontCollection.AddFontFile(fileName); + var fontName = fontCollection.Families[0].Name; + if (!FontFilePaths.ContainsKey(fontName)) + { + FontFilePaths.Add(fontName, fileName); + Debug.WriteLine($"Add font {fontName}: {fileName}"); + } + } + catch (Exception ex) + { + Debug.WriteLine(ex); + } + } + } + } + XFontSource(byte[] bytes, ulong key) { _fontName = null; @@ -90,7 +145,6 @@ public static XFontSource GetOrCreateFrom(byte[] bytes) return fontSource; } -#if CORE || GDI internal static XFontSource GetOrCreateFromGdi(string typefaceKey, GdiFont gdiFont) { byte[] bytes = ReadFontBytesFromGdi(gdiFont); @@ -100,100 +154,30 @@ internal static XFontSource GetOrCreateFromGdi(string typefaceKey, GdiFont gdiFo static byte[] ReadFontBytesFromGdi(GdiFont gdiFont) { - // Weird: LastError is always 123 or 127. Comment out Debug.Assert. - int error = Marshal.GetLastWin32Error(); - //Debug.Assert(error == 0); - error = Marshal.GetLastWin32Error(); - //Debug.Assert(error == 0); - - IntPtr hfont = gdiFont.ToHfont(); -#if true - IntPtr hdc = NativeMethods.GetDC(IntPtr.Zero); -#else - NativeMethods.LOGFONT logFont = new NativeMethods.LOGFONT(); - logFont.lfHeight = 30; - logFont.lfWidth = 0; - logFont.lfEscapement = 0; - logFont.lfOrientation = 0; - logFont.lfWeight = 400; - logFont.lfItalic = 0; - logFont.lfUnderline = 0; - logFont.lfStrikeOut = 0; - logFont.lfCharSet = 0; - logFont.lfOutPrecision = 0; - logFont.lfClipPrecision = 0; - logFont.lfQuality = 0; - logFont.lfPitchAndFamily = 0; - logFont.lfFaceName = "Arial"; - - gdiFont.ToLogFont(logFont); - - hfont = NativeMethods.CreateFontIndirect(logFont); - - - // IntPtr hdc = NativeMethods.CreateDC("DISPLAY", null, null, IntPtr.Zero); - IntPtr hdc = NativeMethods.CreateCompatibleDC(IntPtr.Zero); -#endif - error = Marshal.GetLastWin32Error(); - //Debug.Assert(error == 0); - - IntPtr oldFont = NativeMethods.SelectObject(hdc, hfont); - error = Marshal.GetLastWin32Error(); - //Debug.Assert(error == 0); - - // Get size of the font file. - bool isTtcf = false; - // In Azure I get 0xc0000022 - int size = NativeMethods.GetFontData(hdc, 0, 0, null, 0); - - // Check for ntstatus.h: #define STATUS_ACCESS_DENIED ((NTSTATUS)0xC0000022L) - if ((uint)size == 0xc0000022) - throw new InvalidOperationException("Microsoft Azure returns STATUS_ACCESS_DENIED ((NTSTATUS)0xC0000022L) from GetFontData. This is a bug in Azure. You must implement a FontResolver to circumvent this issue."); - - if (size == NativeMethods.GDI_ERROR) + var assembly = Assembly.GetAssembly(typeof(XFontSource)); + var fontName = gdiFont.Name; + Stream fontStream = null; { - // Assume that the font file is a true type collection. - size = NativeMethods.GetFontData(hdc, ttcf, 0, null, 0); - isTtcf = true; + if (FontFilePaths.ContainsKey(fontName)) + { + var fileName = FontFilePaths[fontName]; + fontStream = File.OpenRead(fileName); + Debug.WriteLine($"{fileName} retrieved."); + } } - error = Marshal.GetLastWin32Error(); - //Debug.Assert(error == 0); - - if (size == 0) - throw new InvalidOperationException("Cannot retrieve font data."); - - byte[] bytes = new byte[size]; - int effectiveSize = NativeMethods.GetFontData(hdc, isTtcf ? ttcf : 0, 0, bytes, size); - Debug.Assert(size == effectiveSize); - // Clean up. - NativeMethods.SelectObject(hdc, oldFont); - NativeMethods.ReleaseDC(IntPtr.Zero, hdc); - return bytes; - } -#endif - -#if WPF && !SILVERLIGHT - internal static XFontSource GetOrCreateFromWpf(string typefaceKey, WpfGlyphTypeface wpfGlyphTypeface) - { - byte[] bytes = ReadFontBytesFromWpf(wpfGlyphTypeface); - XFontSource fontSource = GetOrCreateFrom(typefaceKey, bytes); - return fontSource; - } - - internal static byte[] ReadFontBytesFromWpf(WpfGlyphTypeface wpfGlyphTypeface) - { - using (Stream fontStream = wpfGlyphTypeface.GetFontStream()) + // 3.default + if (fontStream == null) { - if (fontStream == null) - throw new InvalidOperationException("Cannot retrieve font data."); - int size = (int)fontStream.Length; - byte[] bytes = new byte[size]; - fontStream.Read(bytes, 0, size); - return bytes; + fontStream = assembly.GetManifestResourceStream($"PdfSharp.Assets.stsong.ttf"); + Debug.WriteLine($"{fontName} not found, replaced by default stsong.ttf"); } + + // to output + var fontData = new byte[fontStream.Length]; + fontStream.Read(fontData, 0, (int)fontStream.Length); + return fontData; } -#endif static XFontSource GetOrCreateFrom(string typefaceKey, byte[] fontBytes) { diff --git a/src/PdfSharp/PdfSharp.csproj b/src/PdfSharp/PdfSharp.csproj index cdae9caf..96548b98 100644 --- a/src/PdfSharp/PdfSharp.csproj +++ b/src/PdfSharp/PdfSharp.csproj @@ -1,55 +1,31 @@ - - - - - Debug - AnyCPU - {5A6055BC-BF86-4FDD-9F62-0109DB7A303B} - Library - Properties - PdfSharp - PdfSharp - v3.5 - 512 - SAK - SAK - SAK - SAK - - - - true - full - false - bin\Debug\ - TRACE;DEBUG;CORE;CORE_WITH_GDI - prompt - 4 - false - true - false - - - pdbonly - true - bin\Release\ - TRACE;CORE;CORE_WITH_GDI - prompt - 4 - false - bin\Release\PdfSharp.xml - + + netstandard2.0 + $(DefineConstants);CORE;CORE_WITH_GDI + false + false + false + false + false + false + false + false + true + https://github.com/LionelVallet/PDFsharp + 0 + 1.51.5185 + empira Software GmbH, Lionel Vallet + PDFSharp.NetStandard2 + PDFSharp, NET, Standard, Core, PDF, Creation true - - StrongnameKey.snk + true + icon.png + PDFsharp is the Open Source .NET library that easily creates and processes PDF documents on the fly from any .NET language. The same drawing routines can be used to create PDF documents, draw on the screen, or send output to any printer. + +This is the .NET Standard version of the PDFsharp PDF Core package. See Project Information for details. + LICENSE - - - - - @@ -414,6 +390,14 @@ ResGen + + True + + + + True + + @@ -424,12 +408,8 @@ - - + + + + \ No newline at end of file diff --git a/src/PdfSharp/Properties/AssemblyInfo.cs b/src/PdfSharp/Properties/AssemblyInfo.cs index 37640488..4bc37cb8 100644 --- a/src/PdfSharp/Properties/AssemblyInfo.cs +++ b/src/PdfSharp/Properties/AssemblyInfo.cs @@ -37,13 +37,13 @@ [assembly: AssemblyTitle(PdfSharp.VersionInfo.Title)] [assembly: AssemblyVersion(PdfSharp.VersionInfo.Version)] -[assembly: AssemblyDescription(PdfSharp.VersionInfo.Description)] +[assembly: AssemblyDescription("A .NET library for processing PDF. (.NET Standard)")] [assembly: AssemblyConfiguration(PdfSharp.VersionInfo.Configuration)] [assembly: AssemblyCompany(PdfSharp.VersionInfo.Company)] #if DEBUG [assembly: AssemblyProduct(PdfSharp.ProductVersionInfo.Product + " (Debug Build)")] #else - [assembly: AssemblyProduct(PdfSharp.ProductVersionInfo.Product)] + [assembly: AssemblyProduct("PDFSharp.NetStandard2")] #endif [assembly: AssemblyCopyright(PdfSharp.VersionInfo.Copyright)] [assembly: AssemblyTrademark(PdfSharp.VersionInfo.Trademark)] diff --git a/src/PdfSharp/root/ProductVersionInfo.cs b/src/PdfSharp/root/ProductVersionInfo.cs index 0e284769..5ef81d11 100644 --- a/src/PdfSharp/root/ProductVersionInfo.cs +++ b/src/PdfSharp/root/ProductVersionInfo.cs @@ -39,12 +39,12 @@ public static class ProductVersionInfo /// /// The title of the product. /// - public const string Title = "PDFsharp"; + public const string Title = "PDFSharp"; /// /// A characteristic description of the product. /// - public const string Description = "A .NET library for processing PDF."; + public const string Description = "A .NET library for processing PDF. (.NET Standard) "; /// /// The PDF producer information string. @@ -85,7 +85,7 @@ public static class ProductVersionInfo /// /// The name the product. /// - public const string Product = "PDFsharp"; + public const string Product = "PDFSharp.NetStandard"; /// /// The copyright information. @@ -149,13 +149,13 @@ public static class ProductVersionInfo /// or characters that are invalid in an URL. In general, they follow the same rules as .NET namespaces do. /// So Foo.Bar is a valid ID, Foo! and Foo Bar are not. /// - public const string NuGetID = "PDFsharp"; + public const string NuGetID = "PDFSharp.NetStandard"; /// /// Nuspec Doc: The human-friendly title of the package displayed in the Manage NuGet Packages dialog. /// If none is specified, the ID is used instead. /// - public const string NuGetTitle = "PDFsharp"; + public const string NuGetTitle = "PDFSharp.NetStandard"; /// /// Nuspec Doc: A comma-separated list of authors of the package code. From 3bde3d889bd503a6578d606580e84bca5aca9fe7 Mon Sep 17 00:00:00 2001 From: Llewellyn Pritchard Date: Fri, 18 Feb 2022 14:52:49 +0200 Subject: [PATCH 2/2] Encrypt hex literals when needed --- src/PdfSharp/Pdf.Internal/PdfEncoders.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PdfSharp/Pdf.Internal/PdfEncoders.cs b/src/PdfSharp/Pdf.Internal/PdfEncoders.cs index 661d4dc6..a2fb9195 100644 --- a/src/PdfSharp/Pdf.Internal/PdfEncoders.cs +++ b/src/PdfSharp/Pdf.Internal/PdfEncoders.cs @@ -398,6 +398,7 @@ public static byte[] FormatStringLiteral(byte[] bytes, bool unicode, bool prefix } else { + securityHandler?.EncryptBytes(bytes); pdf.Append('<'); for (int idx = 0; idx < count; idx++) pdf.AppendFormat("{0:X2}", bytes[idx]);