diff --git a/.gitignore b/.gitignore index ce3a150ad..bc78471db 100644 --- a/.gitignore +++ b/.gitignore @@ -1,29 +1,90 @@ -# Build Folders (you can keep bin if you'd like, to store dlls and pdbs) -[Bb]in/ -[Oo]bj/ - -# mstest test results -TestResults - ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. +## +## Get latest from `dotnet new gitignore` + +# dotenv files +.env # User-specific files +*.rsuser *.suo *.user +*.userosscache *.sln.docstates +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + # Build results [Dd]ebug/ +[Dd]ebugPublic/ [Rr]elease/ +[Rr]eleases/ x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio *_i.c *_p.c +*_h.h *.ilk *.meta *.obj +*.iobj *.pch *.pdb +*.ipdb *.pgc *.pgd *.rsp @@ -32,35 +93,84 @@ x64/ *.tli *.tlh *.tmp +*.tmp_proj +*_wpftmp.csproj *.log +*.tlog *.vspscc *.vssscc .builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* # Visual C++ cache files ipch/ *.aps *.ncb +*.opendb *.opensdf *.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb # Visual Studio profiler *.psess *.vsp *.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ # Guidance Automation Toolkit *.gpState # ReSharper is a .NET coding add-in -_ReSharper* +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml # NCrunch -*.ncrunch* +_NCrunch_* .*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ -# Installshield output folder -[Ee]xpress +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ # DocProject is a documentation generator add-in DocProject/buildhelp/ @@ -73,38 +183,302 @@ DocProject/Help/Html2 DocProject/Help/html # Click-Once directory -publish +publish/ # Publish Web Output -*.Publish.xml +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ -# NuGet Packages Directory -packages +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets -# Windows Azure Build Output -csx +# Microsoft Azure Build Output +csx/ *.build.csdef -# Windows Store app package directory +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ # Others -[Bb]in -[Oo]bj -sql -TestResults -[Tt]est[Rr]esult* -*.Cache -ClientBin -[Ss]tyle[Cc]op.* +ClientBin/ ~$* +*~ *.dbmdl -Generated_Code #added for RIA/Silverlight projects +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea/ + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/main/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/main/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk -*.DotSettings \ No newline at end of file +# Vim temporary swap files +*.swp diff --git a/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj b/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj index 7413cc397..7b4635d22 100644 --- a/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj +++ b/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj @@ -1,59 +1,41 @@ - - - + - Debug - AnyCPU - {2390B71F-9400-47F4-B23A-7F2649C87D35} + net8.0-windows Library - Properties TheArtOfDev.HtmlRenderer.Demo.Common HtmlRendererDemoCommon - v2.0 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + HtmlRenderer.Demo.Common + HtmlRenderer.Demo.Common + Copyright © 2013 + 1.0.0.0 + 1.0.0.0 - - - - + + + + + + + + + + + + - - + Resources.resx True True - - - - - - + PublicResXFileCodeGenerator Resources.Designer.cs Designer @@ -147,10 +129,7 @@ - - {FE611685-391F-4E3E-B27E-D3150E51E49B} - HtmlRenderer - + @@ -167,12 +146,8 @@ - - + + + + \ No newline at end of file diff --git a/Source/Demo/Common/Properties/AssemblyInfo.cs b/Source/Demo/Common/Properties/AssemblyInfo.cs index bb96bf22f..703cf62ef 100644 --- a/Source/Demo/Common/Properties/AssemblyInfo.cs +++ b/Source/Demo/Common/Properties/AssemblyInfo.cs @@ -1,16 +1,5 @@ using System.Reflection; using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("HtmlRenderer.Demo.Common")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("HtmlRenderer.Demo.Common")] -[assembly: AssemblyCopyright("Copyright © 2013")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -23,17 +12,3 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("5d5516c9-aa2c-44cc-883c-467ff9a3d9b9")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Source/Demo/Common/Properties/Resources.Designer.cs b/Source/Demo/Common/Properties/Resources.Designer.cs index 8b1aa6a38..5c0bc0a7c 100644 --- a/Source/Demo/Common/Properties/Resources.Designer.cs +++ b/Source/Demo/Common/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34014 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -19,7 +19,7 @@ namespace TheArtOfDev.HtmlRenderer.Demo.Common.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { diff --git a/Source/Demo/Common/Resources.cs b/Source/Demo/Common/Resources.cs index 6370c567c..a9ebf3c06 100644 --- a/Source/Demo/Common/Resources.cs +++ b/Source/Demo/Common/Resources.cs @@ -40,7 +40,7 @@ public static byte[] CustomFont public static Stream Comment16 { - get { return GetManifestResourceStream("comment16.gif"); } + get { return GetManifestResourceStream("comment16.png"); } } public static Stream Event16 @@ -70,17 +70,17 @@ public static Stream Image32 public static Stream Method16 { - get { return GetManifestResourceStream("method16.gif"); } + get { return GetManifestResourceStream("method16.png"); } } public static Stream Property16 { - get { return GetManifestResourceStream("property16.gif"); } + get { return GetManifestResourceStream("property16.png"); } } public static Stream WebPallete { - get { return GetManifestResourceStream("web_pallete.gif"); } + get { return GetManifestResourceStream("web_pallete.png"); } } public static string Tooltip diff --git a/Source/Demo/Common/Resources/comment16.png b/Source/Demo/Common/Resources/comment16.png new file mode 100644 index 000000000..4b013c825 Binary files /dev/null and b/Source/Demo/Common/Resources/comment16.png differ diff --git a/Source/Demo/Common/Resources/delete16.png b/Source/Demo/Common/Resources/delete16.png new file mode 100644 index 000000000..a6f0dc58e Binary files /dev/null and b/Source/Demo/Common/Resources/delete16.png differ diff --git a/Source/Demo/Common/Resources/delete32.png b/Source/Demo/Common/Resources/delete32.png new file mode 100644 index 000000000..af5b7778d Binary files /dev/null and b/Source/Demo/Common/Resources/delete32.png differ diff --git a/Source/Demo/Common/Resources/method16.png b/Source/Demo/Common/Resources/method16.png new file mode 100644 index 000000000..8cb691bce Binary files /dev/null and b/Source/Demo/Common/Resources/method16.png differ diff --git a/Source/Demo/Common/Resources/property16.png b/Source/Demo/Common/Resources/property16.png new file mode 100644 index 000000000..328e5f694 Binary files /dev/null and b/Source/Demo/Common/Resources/property16.png differ diff --git a/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj b/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj index 8c26cdcc4..f72db3a54 100644 --- a/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj +++ b/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj @@ -1,119 +1,23 @@ - - - + - Debug - AnyCPU - {F02E0216-4AE3-474F-9381-FCB93411CDB0} + net8.0-windows WinExe - Properties TheArtOfDev.HtmlRenderer.Demo.WPF HtmlRendererWpfDemo - v4.0 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - ..\..\ true - - - x86 - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - + true + true html.ico - - - - - - - - - ..\..\packages\Extended.Wpf.Toolkit.2.2.1\lib\net40\Xceed.Wpf.DataGrid.dll - - - ..\..\packages\Extended.Wpf.Toolkit.2.2.1\lib\net40\Xceed.Wpf.Toolkit.dll - - - - - MSBuild:Compile - Designer - - - GenerateImageWindow.xaml - - - SampleWindow.xaml - - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - DemoWindow.xaml - Code - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - - - - MainControl.xaml - - - Code - + - - {7e4e8db5-85ad-4388-bdcb-38c6f423b8b0} - HtmlRenderer.WPF - - - {fe611685-391f-4e3e-b27e-d3150e51e49b} - HtmlRenderer - - - {2390B71F-9400-47F4-B23A-7F2649C87D35} - HtmlRenderer.Demo.Common - + + + @@ -121,10 +25,6 @@ - - - - @@ -132,18 +32,4 @@ - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - \ No newline at end of file diff --git a/Source/Demo/WPF/Properties/AssemblyInfo.cs b/Source/Demo/WPF/Properties/AssemblyInfo.cs deleted file mode 100644 index d5c8b4eb2..000000000 --- a/Source/Demo/WPF/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("HTML Renderer WPF Demo")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("HTML Renderer WPF Demo")] -[assembly: AssemblyCopyright("Copyright © 2013")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) - )] - - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Source/Demo/WPF/app.config b/Source/Demo/WPF/app.config new file mode 100644 index 000000000..3e0e37cfc --- /dev/null +++ b/Source/Demo/WPF/app.config @@ -0,0 +1,3 @@ + + + diff --git a/Source/Demo/WPF/packages.config b/Source/Demo/WPF/packages.config deleted file mode 100644 index d3eaa3c6b..000000000 --- a/Source/Demo/WPF/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Source/Demo/WinForms/DemoForm.cs b/Source/Demo/WinForms/DemoForm.cs index 3e7287b70..17447f061 100644 --- a/Source/Demo/WinForms/DemoForm.cs +++ b/Source/Demo/WinForms/DemoForm.cs @@ -148,7 +148,14 @@ private void OnGeneratePdf_Click(object sender, EventArgs e) var tmpFile = Path.GetTempFileName(); tmpFile = Path.GetFileNameWithoutExtension(tmpFile) + ".pdf"; doc.Save(tmpFile); - Process.Start(tmpFile); + var process = new Process + { + StartInfo = new ProcessStartInfo(tmpFile) + { + UseShellExecute = true + } + }; + process.Start(); } /// diff --git a/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj b/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj index 95dafc2f1..af082c426 100644 --- a/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj +++ b/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj @@ -1,21 +1,9 @@ - - + - Debug - AnyCPU - 8.0.50727 - 2.0 - {8AD34FE8-8382-4A8A-B3AA-A0392ED42423} + net8.0-windows WinExe - Properties TheArtOfDev.HtmlRenderer.Demo.WinForms HtmlRendererWinFormsDemo - v2.0 - - - - - 2.0 publish\ true Disk @@ -31,106 +19,17 @@ false false true - - ..\..\ true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - AllRules.ruleset - x86 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + true + true AllRules.ruleset - x86 - false - - html.ico - - ..\..\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.dll - True - - - ..\..\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.Charting.dll - True - - - - - - - - - - Form - - - GenerateImageForm.cs - - - + UserControl - - MainControl.cs - - - Form - - - PerfForm.cs - - - Form - - - DemoForm.cs - - - - - GenerateImageForm.cs - - - MainControl.cs - - - PerfForm.cs - Designer - - - Designer - DemoForm.cs - - - Form - - - SampleForm.cs - - - - - Designer - SampleForm.cs - @@ -150,37 +49,14 @@ - - {ca249f5d-9285-40a6-b217-5889ef79fd7e} - HtmlRenderer.PdfSharp - - - {1b058920-24b4-4140-8ae7-c8c6c38ca52d} - HtmlRenderer.WinForms - - - {fe611685-391f-4e3e-b27e-d3150e51e49b} - HtmlRenderer - - - {2390b71f-9400-47f4-b23a-7f2649c87d35} - HtmlRenderer.Demo.Common - + + + + - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - @@ -188,11 +64,4 @@ - \ No newline at end of file diff --git a/Source/Demo/WinForms/Program.cs b/Source/Demo/WinForms/Program.cs index f01eb6d0a..7421b29fb 100644 --- a/Source/Demo/WinForms/Program.cs +++ b/Source/Demo/WinForms/Program.cs @@ -10,6 +10,7 @@ // - Sun Tsu, // "The Art of War" +using PdfSharp.Fonts; using System; using System.Globalization; using System.IO; @@ -27,7 +28,8 @@ internal static class Program private static void Main() { AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly; - + GlobalFontSettings.UseWindowsFontsUnderWindows = true; + GlobalFontSettings.FontResolver = new SubstitutingFontResolver(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new DemoForm()); diff --git a/Source/Demo/WinForms/Properties/AssemblyInfo.cs b/Source/Demo/WinForms/Properties/AssemblyInfo.cs deleted file mode 100644 index 2719715e7..000000000 --- a/Source/Demo/WinForms/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("HTML Renderer WinForms Demo")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("HTML Renderer WinForms Demo")] -[assembly: AssemblyCopyright("Copyright © 2008")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("3098581d-210a-4748-bcda-4b9a6b34a91a")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/Source/Demo/WinForms/SubstitutingFontResolver.cs b/Source/Demo/WinForms/SubstitutingFontResolver.cs new file mode 100644 index 000000000..db7754758 --- /dev/null +++ b/Source/Demo/WinForms/SubstitutingFontResolver.cs @@ -0,0 +1,359 @@ +using PdfSharp.Fonts; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace TheArtOfDev.HtmlRenderer.Demo.WinForms +{ + /// + /// The SubstitutingFontResolver tries to find some standard Windows fonts. + /// When used under Windows, it searches "C:\Windows\Fonts". + /// When used under WSL, it searches "/mnt/c/Windows/Fonts". + /// It also searches substitute fonts in folders that are used by common Linux distributions. + /// When used under MacOS, Android, Xamarin, ... it will probably find no fonts. + /// When you ask for Arial, it may return FreeSans under Linux if Arial cannot be found. + /// When you ask for Times New Roman, it may return FreeSerif under Linux if Times New Roman cannot be found. + /// Because of font substitutions, the look of PDF files will vary depending on the configuration of the + /// computer that runs the app. + /// Usage tips: + /// * Set a fallback font resolver like FailsafeFontResolver to avoid exceptions if no font can be found. + /// * If you need a specific font, create a font resolver that includes that font as a resource. + /// * Use SubstitutingFontResolver to play around and evaluate PDFsharp, but better do not use it when distributing apps to the public. + /// + class SubstitutingFontResolver : IFontResolver + { + class TypefaceInfo + { + public string FontFaceName { get; } + + public FontSimulation Simulation { get; } + + public string WindowsFileName { get; } + + public string LinuxFileName { get; } + + public string[] LinuxSubstituteFaceNames { get; } + + internal TypefaceInfo( + string fontFaceName, + FontSimulation fontSimulation, + string windowsFileName, + string linuxFileName = null!, + params string[] linuxSubstituteFaceNames) + { + FontFaceName = fontFaceName; + Simulation = fontSimulation; + WindowsFileName = windowsFileName; + LinuxFileName = linuxFileName; + LinuxSubstituteFaceNames = linuxSubstituteFaceNames; + } + + [Flags] + public enum FontSimulation + { + None = 0, + Bold = 1, + Italic = 2, + Both = Bold | Italic + } + } + + static readonly List TypefaceInfos = + [ + // ReSharper disable StringLiteralTypo + + new("Arial", TypefaceInfo.FontSimulation.None, "arial", "Arial", "FreeSans"), + new("Arial Black", TypefaceInfo.FontSimulation.None, "ariblk", "Arial-Black"), + new("Arial Bold", TypefaceInfo.FontSimulation.None, "arialbd", "Arial-Bold", "FreeSansBold"), + new("Arial Italic", TypefaceInfo.FontSimulation.None, "ariali", "Arial-Italic", "FreeSansOblique"), + new("Arial Bold Italic", TypefaceInfo.FontSimulation.None, "arialbi", "Arial-BoldItalic", "FreeSansBoldOblique"), + + new("Times New Roman", TypefaceInfo.FontSimulation.None, "times", "TimesNewRoman", "FreeSerif"), + new("Times New Roman Bold", TypefaceInfo.FontSimulation.None, "timesbd", "TimesNewRoman-Bold", "FreeSerifBold"), + new("Times New Roman Italic", TypefaceInfo.FontSimulation.None, "timesi", "TimesNewRoman-Italic", "FreeSerifItalic"), + new("Times New Roman Bold Italic", TypefaceInfo.FontSimulation.None, "timesbi", "TimesNewRoman-BoldItalic", "FreeSerifBoldItalic"), + + new("Courier New", TypefaceInfo.FontSimulation.None, "cour", "Courier-Bold", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "FreeMono"), + new("Courier New Bold", TypefaceInfo.FontSimulation.None, "courbd", "CourierNew-Bold", "DejaVu Sans Mono Bold", "Bitstream Vera Sans Mono Bold", "FreeMonoBold"), + new("Courier New Italic", TypefaceInfo.FontSimulation.None, "couri", "CourierNew-Italic", "DejaVu Sans Mono Oblique", "Bitstream Vera Sans Mono Italic", "FreeMonoOblique"), + new("Courier New Bold Italic", TypefaceInfo.FontSimulation.None, "courbi", "CourierNew-BoldItalic", "DejaVu Sans Mono Bold Oblique", "Bitstream Vera Sans Mono Bold Italic", "FreeMonoBoldOblique"), + + new("Verdana", TypefaceInfo.FontSimulation.None, "verdana", "Verdana", "DejaVu Sans", "Bitstream Vera Sans", "FreeSans"), + new("Verdana Bold", TypefaceInfo.FontSimulation.None, "verdanab", "Verdana-Bold", "DejaVu Sans Bold", "Bitstream Vera Sans Bold", "FreeSansBold"), + new("Verdana Italic", TypefaceInfo.FontSimulation.None, "verdanai", "Verdana-Italic", "DejaVu Sans Oblique", "Bitstream Vera Sans Italic", "FreeSansOblique"), + new("Verdana Bold Italic", TypefaceInfo.FontSimulation.None, "verdanaz", "Verdana-BoldItalic", "DejaVu Sans Bold Oblique", "Bitstream Vera Sans Bold Italic", "FreeSansBoldOblique"), + + new("Lucida Console", TypefaceInfo.FontSimulation.None, "lucon", "LucidaConsole", "DejaVu Sans Mono"), + new("Lucida Console Bold", TypefaceInfo.FontSimulation.Bold, "lucon", "LucidaConsole", "DejaVu Sans Mono"), + new("Lucida Console Italic", TypefaceInfo.FontSimulation.Italic, "lucon", "LucidaConsole", "DejaVu Sans Mono"), + new("Lucida Console Bold Italic", TypefaceInfo.FontSimulation.Both, "lucon", "LucidaConsole", "DejaVu Sans Mono"), + + new("Symbol", TypefaceInfo.FontSimulation.None, "symbol", "", "Noto Sans Symbols Regular"), // Noto Symbols may not replace exactly + new("Symbol Bold", TypefaceInfo.FontSimulation.Bold, "symbol", "", "Noto Sans Symbols Regular"), // Noto Symbols may not replace exactly + new("Symbol Italic", TypefaceInfo.FontSimulation.Italic, "symbol", "", "Noto Sans Symbols Regular"), // Noto Symbols may not replace exactly + new("Symbol Bold Italic", TypefaceInfo.FontSimulation.Both, "symbol", "", "Noto Sans Symbols Regular"), // Noto Symbols may not replace exactly + new("Segoe UI", TypefaceInfo.FontSimulation.None, "segoeui", "SegoeUI", "DejaVu Sans"), + new("Tahoma", TypefaceInfo.FontSimulation.None, "tahoma", "Tahoma", "DejaVu Sans"), +#if true + //new("Wingdings", "wingding"), // No Linux substitute + + // Linux Substitute Fonts + // TODO_OLD Nimbus and Liberation are only readily available as OTF. + + // Ubuntu packages: fonts-dejavu fonts-dejavu-core fonts-dejavu-extra + new("DejaVu Sans", TypefaceInfo.FontSimulation.None, "DejaVuSans"), + new("DejaVu Sans Bold", TypefaceInfo.FontSimulation.None, "DejaVuSans-Bold"), + new("DejaVu Sans Oblique", TypefaceInfo.FontSimulation.None, "DejaVuSans-Oblique"), + new("DejaVu Sans Bold Oblique", TypefaceInfo.FontSimulation.None, "DejaVuSans-BoldOblique"), + new("DejaVu Sans Mono", TypefaceInfo.FontSimulation.None, "DejaVuSansMono"), + new("DejaVu Sans Mono Bold", TypefaceInfo.FontSimulation.None, "DejaVuSansMono-Bold"), + new("DejaVu Sans Mono Oblique", TypefaceInfo.FontSimulation.None, "DejaVuSansMono-Oblique"), + new("DejaVu Sans Mono Bold Oblique", TypefaceInfo.FontSimulation.None, "DejaVuSansMono-BoldOblique"), + + // Ubuntu packages: fonts-freefont-ttf + new("FreeSans", TypefaceInfo.FontSimulation.None, "FreeSans"), + new("FreeSansBold", TypefaceInfo.FontSimulation.None, "FreeSansBold"), + new("FreeSansOblique", TypefaceInfo.FontSimulation.None, "FreeSansOblique"), + new("FreeSansBoldOblique", TypefaceInfo.FontSimulation.None, "FreeSansBoldOblique"), + new("FreeMono", TypefaceInfo.FontSimulation.None, "FreeMono"), + new("FreeMonoBold", TypefaceInfo.FontSimulation.None, "FreeMonoBold"), + new("FreeMonoOblique", TypefaceInfo.FontSimulation.None, "FreeMonoOblique"), + new("FreeMonoBoldOblique", TypefaceInfo.FontSimulation.None, "FreeMonoBoldOblique"), + new("FreeSerif", TypefaceInfo.FontSimulation.None, "FreeSerif"), + new("FreeSerifBold", TypefaceInfo.FontSimulation.None, "FreeSerifBold"), + new("FreeSerifItalic", TypefaceInfo.FontSimulation.None, "FreeSerifItalic"), + new("FreeSerifBoldItalic", TypefaceInfo.FontSimulation.None, "FreeSerifBoldItalic"), + + // Ubuntu packages: ttf-bitstream-vera + new("Bitstream Vera Sans", TypefaceInfo.FontSimulation.None, "Vera"), + new("Bitstream Vera Sans Bold", TypefaceInfo.FontSimulation.None, "VeraBd"), + new("Bitstream Vera Sans Italic", TypefaceInfo.FontSimulation.None, "VeraIt"), + new("Bitstream Vera Sans Bold Italic", TypefaceInfo.FontSimulation.None, "VeraBI"), + new("Bitstream Vera Sans Mono", TypefaceInfo.FontSimulation.None, "VeraMono"), + new("Bitstream Vera Sans Mono Bold", TypefaceInfo.FontSimulation.None, "VeraMoBd"), + new("Bitstream Vera Sans Mono Italic", TypefaceInfo.FontSimulation.None, "VeraMoIt"), + new("Bitstream Vera Sans Mono Bold Italic", TypefaceInfo.FontSimulation.None, "VeraMoBI"), + + // Ubuntu packages: fonts-noto-core + new("Noto Sans Symbols Regular", TypefaceInfo.FontSimulation.None, "NotoSansSymbols-Regular"), + new("Noto Sans Symbols Bold", TypefaceInfo.FontSimulation.None, "NotoSansSymbols-Bold") +#endif + // ReSharper restore StringLiteralTypo + ]; + + static SubstitutingFontResolver() + { + var fcp = Environment.GetEnvironmentVariable("FONTCONFIG_PATH"); + if (fcp is not null && !LinuxFontLocations.Contains(fcp)) + LinuxFontLocations.Add(fcp); + } + + // Returns a FontResolverInfo... + public FontResolverInfo? ResolveTypeface(string familyName, bool isBold, bool isItalic) + { + var typefaces = TypefaceInfos.Where(f => f.FontFaceName.StartsWith(familyName, StringComparison.OrdinalIgnoreCase)); + var baseFamily = TypefaceInfos.FirstOrDefault(); + + if (isBold) + typefaces = typefaces.Where(f => f.FontFaceName.Contains("bold", StringComparison.OrdinalIgnoreCase) || f.FontFaceName.Contains("heavy", StringComparison.OrdinalIgnoreCase)); + + if (isItalic) + typefaces = typefaces.Where(f => f.FontFaceName.Contains("italic", StringComparison.OrdinalIgnoreCase) || f.FontFaceName.Contains("oblique", StringComparison.OrdinalIgnoreCase)); + + var family = typefaces.FirstOrDefault(); +#if true + if (family is not null) + return new FontResolverInfo(family.WindowsFileName, + (family.Simulation & TypefaceInfo.FontSimulation.Bold) != 0, + (family.Simulation & TypefaceInfo.FontSimulation.Italic) != 0); +#else + if (family is not null) + return new FontResolverInfo(family.WindowsFileName, false, false); +#endif + + // Return null if there is no exact match. + //if (baseFamily is not null) + // return new FontResolverInfo(baseFamily.WindowsFileName, isBold, isItalic); + + return null; + } + + public byte[]? GetFont(string faceName) + { + //if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + // return GetFontWindows(faceName); + + //if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + // return GetFontLinux(faceName); + + if (_isWindows == null) + { +#if NET462 + _isWindows = true; +#else + // May be too simple. + _isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); +#endif + } + + if (_isLinux == null) + { +#if NET462 + _isLinux = false; +#else + // May be too simple. + _isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux); +#endif + } + + if (_isWindows.Value) + { + return GetWindowsFontFace(faceName); + } + else if (_isLinux.Value) + { + return GetLinuxFontFace(faceName); + } + else + { + return GetWindowsFontFace(faceName); + } + } + bool? _isWindows; + bool? _isLinux; + + byte[]? GetWindowsFontFace(string faceName) + { + foreach (var fontLocation in WindowsFontLocations) + { + var filepath = Path.Combine(fontLocation, faceName + ".ttf"); + if (File.Exists(filepath)) + return File.ReadAllBytes(filepath); + } + return null; + } + + static readonly List WindowsFontLocations = + [ + @"C:\Windows\Fonts", + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + @"Microsoft\Windows\Fonts") + ]; + + byte[]? GetLinuxFontFace(string faceName) + { + // TODO_OLD Query fontconfig. + // Fontconfig is the de facto standard for indexing and managing fonts on linux. + // Example command that should return a full file path to FreeSansBoldOblique.ttf: + // fc-match -f '%{file}\n' 'FreeSans:Bold:Oblique:fontformat=TrueType' : file + // + // Caveat: fc-match *always* returns a "next best" match or default font, even if it’s bad. + // Caveat: some preprocessing/refactoring needed to produce a pattern fc-match can understand. + // Caveat: fontconfig needs additional configuration to know about WSL having Windows Fonts available at /mnt/c/Windows/Fonts. + + foreach (var fontLocation in LinuxFontLocations) + { + if (!Directory.Exists(fontLocation)) + continue; + + var fontPath = FindFileRecursive(fontLocation, faceName); + if (fontPath is not null && File.Exists(fontPath)) + return File.ReadAllBytes(fontPath); + } + + return null; + } + + static readonly List LinuxFontLocations = + [ + "/mnt/c/Windows/Fonts", // WSL first or substitutes will be found. + "/usr/share/fonts", + "/usr/share/X11/fonts", + "/usr/X11R6/lib/X11/fonts", + // TODO_OLD Avoid calling Environment.GetFolderPath twice. + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".fonts"), + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".local/share/fonts") + ]; + + /// + /// Finds filename candidates recursively on Linux, as organizing fonts into arbitrary subdirectories is allowed. + /// + string? FindFileRecursive(string basePath, string faceName) + { + var filenameCandidates = FaceNameToFilenameCandidates(faceName); + + foreach (var file in Directory.GetFiles(basePath).Select(Path.GetFileName)) + foreach (var filenameCandidate in filenameCandidates) + { + // Most programs treat fonts case-sensitive on Linux. We ignore case because we also target WSL. + if (!String.IsNullOrEmpty(file) && file.Equals(filenameCandidate, StringComparison.OrdinalIgnoreCase)) + return Path.Combine(basePath, filenameCandidate); + } + + // Linux allows arbitrary subdirectories for organizing fonts. + foreach (var directory in Directory.GetDirectories(basePath).Select(Path.GetFileName)) + { + if (String.IsNullOrEmpty(directory)) + continue; + + var file = FindFileRecursive(Path.Combine(basePath, directory), faceName); + if (file is not null) + return file; + } + + return null; + } + + /// + /// Generates filename candidates for Linux systems. + /// + string[] FaceNameToFilenameCandidates(string faceName) + { + const string fileExtension = ".ttf"; + // TODO_OLD OTF Fonts are popular on Linux too. + + var candidates = new List + { + faceName + fileExtension // We need to look for Windows face name too in case of WSL or copied files. + }; + + var family = TypefaceInfos.FirstOrDefault(f => f.WindowsFileName == faceName); + if (family is null) + return candidates.ToArray(); + + if (!String.IsNullOrEmpty(family.LinuxFileName)) + candidates.Add(family.LinuxFileName + fileExtension); + candidates.Add(family.FontFaceName + fileExtension); + + // Add substitute fonts as last candidates. + foreach (var replacement in family.LinuxSubstituteFaceNames) + { + var replacementFamily = TypefaceInfos.FirstOrDefault(f => f.FontFaceName == replacement); + if (replacementFamily is null) + continue; + + candidates.Add(replacementFamily.FontFaceName + fileExtension); + if (!String.IsNullOrEmpty(replacementFamily.WindowsFileName)) + candidates.Add(replacementFamily.WindowsFileName + fileExtension); + if (!String.IsNullOrEmpty(replacementFamily.LinuxFileName)) + candidates.Add(replacementFamily.LinuxFileName + fileExtension); + } + + return candidates.ToArray(); + } + } + +#if !NET6_0_OR_GREATER + static class StringExtensions + { + /// + /// String.Contains implementation for .NET Framework and .NET Standard as an extension method. + /// + internal static bool Contains(this string s, string value, StringComparison comparisonType) => s.IndexOf(value, comparisonType) >= 0; + } +#endif +} diff --git a/Source/Demo/WinForms/app.config b/Source/Demo/WinForms/app.config new file mode 100644 index 000000000..3e0e37cfc --- /dev/null +++ b/Source/Demo/WinForms/app.config @@ -0,0 +1,3 @@ + + + diff --git a/Source/Demo/WinForms/packages.config b/Source/Demo/WinForms/packages.config deleted file mode 100644 index 2f092fd78..000000000 --- a/Source/Demo/WinForms/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Source/HtmlRenderer.PdfSharp/Adapters/PdfSharpAdapter.cs b/Source/HtmlRenderer.PdfSharp/Adapters/PdfSharpAdapter.cs index e5fa309c0..c2460c13a 100644 --- a/Source/HtmlRenderer.PdfSharp/Adapters/PdfSharpAdapter.cs +++ b/Source/HtmlRenderer.PdfSharp/Adapters/PdfSharpAdapter.cs @@ -64,7 +64,7 @@ protected override RColor GetColorInt(string colorName) { try { - var color = Color.FromKnownColor((KnownColor)System.Enum.Parse(typeof(KnownColor), colorName, true)); + var color = Color.FromName(colorName); return Utils.Convert(color); } catch @@ -119,14 +119,14 @@ protected override RImage ImageFromStreamInt(Stream memoryStream) protected override RFont CreateFontInt(string family, double size, RFontStyle style) { - var fontStyle = (XFontStyle)((int)style); + var fontStyle = (XFontStyleEx)((int)style); var xFont = new XFont(family, size, fontStyle, new XPdfFontOptions(PdfFontEncoding.Unicode)); return new FontAdapter(xFont); } protected override RFont CreateFontInt(RFontFamily family, double size, RFontStyle style) { - var fontStyle = (XFontStyle)((int)style); + var fontStyle = (XFontStyleEx)((int)style); var xFont = new XFont(((FontFamilyAdapter)family).FontFamily.Name, size, fontStyle, new XPdfFontOptions(PdfFontEncoding.Unicode)); return new FontAdapter(xFont); } diff --git a/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj b/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj index ef0fd7acc..5893e7327 100644 --- a/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj +++ b/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj @@ -1,90 +1,19 @@ - - - + - Debug - AnyCPU - {CA249F5D-9285-40A6-B217-5889EF79FD7E} + netstandard2.0 Library - Properties TheArtOfDev.HtmlRenderer.PdfSharp - HtmlRenderer.PdfSharp - v2.0 - 512 ..\ true - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - ..\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.dll - True - - - ..\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.Charting.dll - True - - - - - - Properties\SharedAssemblyInfo.cs - - - - - - - - - - - - - - - - - {fe611685-391f-4e3e-b27e-d3150e51e49b} - HtmlRenderer - + + - + - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - \ No newline at end of file diff --git a/Source/HtmlRenderer.PdfSharp/packages.config b/Source/HtmlRenderer.PdfSharp/packages.config deleted file mode 100644 index 2f092fd78..000000000 --- a/Source/HtmlRenderer.PdfSharp/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj b/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj index 80c4b97f9..47b9648c2 100644 --- a/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj +++ b/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj @@ -1,85 +1,23 @@ - - - + - Debug - AnyCPU - {7E4E8DB5-85AD-4388-BDCB-38C6F423B8B0} - library - Properties + net8.0-windows + Library TheArtOfDev.HtmlRenderer.WPF - HtmlRenderer.WPF - v3.0 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 + true + true - pdbonly - true bin\Release.WPF.Net35\ - TRACE - prompt - 4 - - - - - - - - - - - {fe611685-391f-4e3e-b27e-d3150e51e49b} - HtmlRenderer - + Properties\SharedAssemblyInfo.cs - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj b/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj index ce1a98759..f5c3ce1bb 100644 --- a/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj +++ b/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj @@ -1,23 +1,9 @@ - - + - Debug - AnyCPU - 8.0.50727 - 2.0 - {1B058920-24B4-4140-8AE7-C8C6C38CA52D} + net8.0-windows Library - Properties TheArtOfDev.HtmlRenderer.WinForms - HtmlRenderer.WinForms - - - v2.0 - - - - - 2.0 + publish\ true Disk @@ -33,64 +19,31 @@ false false true - - + true + true - true - full - false bin\DebugNet20\ - DEBUG;TRACE - prompt - 4 - false AllRules.ruleset - pdbonly - true bin\ReleaseNet20\ - TRACE - prompt - 4 AllRules.ruleset - - - - - - Properties\SharedAssemblyInfo.cs - - - - - - - - - - - - + Component - + Component - - + Component - - - - + @@ -110,17 +63,6 @@ - - {fe611685-391f-4e3e-b27e-d3150e51e49b} - HtmlRenderer - + - - \ No newline at end of file diff --git a/Source/HtmlRenderer/Core/Parse/RegexParserHelper.cs b/Source/HtmlRenderer/Core/Parse/RegexParserHelper.cs deleted file mode 100644 index 86a690b50..000000000 --- a/Source/HtmlRenderer/Core/Parse/RegexParserHelper.cs +++ /dev/null @@ -1,227 +0,0 @@ -// "Therefore those skilled at the unorthodox -// are infinite as heaven and earth, -// inexhaustible as the great rivers. -// When they come to an end, -// they bagin again, -// like the days and months; -// they die and are reborn, -// like the four seasons." -// -// - Sun Tsu, -// "The Art of War" - -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace HtmlRenderer.Parse -{ - /// - /// Collection of regular expressions used when parsing - /// - internal static class RegexParserHelper - { - #region Fields and Consts - - /// - /// Extracts CSS style comments; e.g. /* comment */ - /// - public const string CssComments = @"/\*[^*/]*\*/"; - - /// - /// Extracts the media types from a media at-rule; e.g. @media print, 3d, screen { - /// - public const string CssMediaTypes = @"@media[^\{\}]*\{"; - - /// - /// Extracts defined blocks in CSS. - /// WARNING: Blocks will include blocks inside at-rules. - /// - public const string CssBlocks = @"[^\{\}]*\{[^\{\}]*\}"; - - /// - /// Extracts a number; e.g. 5, 6, 7.5, 0.9 - /// - public const string CssNumber = @"{[0-9]+|[0-9]*\.[0-9]+}"; - - /// - /// Extracts css percentages from the string; e.g. 100% .5% 5.4% - /// - public const string CssPercentage = @"([0-9]+|[0-9]*\.[0-9]+)\%"; //TODO: Check if works fine - - /// - /// Extracts CSS lengths; e.g. 9px 3pt .89em - /// - public const string CssLength = @"([0-9]+|[0-9]*\.[0-9]+)(em|ex|px|in|cm|mm|pt|pc)"; - - /// - /// Extracts CSS colors; e.g. black white #fff #fe98cd rgb(5,5,5) rgb(45%, 0, 0) - /// - public const string CssColors = @"(#\S{6}|#\S{3}|rgb\(\s*[0-9]{1,3}\%?\s*\,\s*[0-9]{1,3}\%?\s*\,\s*[0-9]{1,3}\%?\s*\)|maroon|red|orange|yellow|olive|purple|fuchsia|white|lime|green|navy|blue|aqua|teal|black|silver|gray)"; - - /// - /// Extracts line-height values (normal, numbers, lengths, percentages) - /// - public const string CssLineHeight = "(normal|" + CssNumber + "|" + CssLength + "|" + CssPercentage + ")"; - - /// - /// Extracts CSS border styles; e.g. solid none dotted - /// - public const string CssBorderStyle = @"(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)"; - - /// - /// Extracts CSS border widthe; e.g. 1px thin 3em - /// - public const string CssBorderWidth = "(" + CssLength + "|thin|medium|thick)"; - - /// - /// Extracts font-family values - /// - public const string CssFontFamily = "(\"[^\"]*\"|'[^']*'|\\S+\\s*)(\\s*\\,\\s*(\"[^\"]*\"|'[^']*'|\\S+))*"; - - /// - /// Extracts CSS font-styles; e.g. normal italic oblique - /// - public const string CssFontStyle = "(normal|italic|oblique)"; - - /// - /// Extracts CSS font-variant values; e.g. normal, small-caps - /// - public const string CssFontVariant = "(normal|small-caps)"; - - /// - /// Extracts font-weight values; e.g. normal, bold, bolder... - /// - public const string CssFontWeight = "(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)"; - - /// - /// Exracts font sizes: xx-small, larger, small, 34pt, 30%, 2em - /// - public const string CssFontSize = "(" + CssLength + "|" + CssPercentage + "|xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller)"; - - /// - /// Gets the font-size[/line-height]? on the font shorthand property. - /// Check http://www.w3.org/TR/CSS21/fonts.html#font-shorthand - /// - public const string CssFontSizeAndLineHeight = CssFontSize + @"(\/" + CssLineHeight + @")?(\s|$)"; - - /// - /// Extracts HTML tags - /// - public const string HtmlTag = @"<[^<>]*>"; - - /// - /// Extracts attributes from a HTML tag; e.g. att=value, att="value" - /// - public const string HmlTagAttributes = "(?\\b\\w+\\b)\\s*=\\s*(?\"[^\"]*\"|'[^']*'|[^\"'<>\\s]+)"; - - /// - /// the regexes cache that is used by the parser so not to create regex each time - /// - private static readonly Dictionary _regexes = new Dictionary(); - - #endregion - - - /// - /// Get CSS at rule from the given stylesheet. - /// - /// the stylesheet data to retrieve the rule from - /// the index to start the search for the rule, on return will be the value of the end of the found rule - /// the found at rule or null if not exists - public static string GetCssAtRules(string stylesheet, ref int startIdx) - { - startIdx = stylesheet.IndexOf('@', startIdx); - if (startIdx > -1) - { - int count = 1; - int endIdx = stylesheet.IndexOf('{', startIdx); - if (endIdx > -1) - { - while (count > 0 && endIdx < stylesheet.Length) - { - endIdx++; - if (stylesheet[endIdx] == '{') - { - count++; - } - else if (stylesheet[endIdx] == '}') - { - count--; - } - } - if (endIdx < stylesheet.Length) - { - var atrule = stylesheet.Substring(startIdx, endIdx - startIdx + 1); - startIdx = endIdx; - return atrule; - } - } - } - return null; - } - - /// - /// Extracts matches from the specified source - /// - /// Regular expression to extract matches - /// Source to extract matches - /// Collection of matches - public static MatchCollection Match(string regex, string source) - { - var r = GetRegex(regex); - return r.Matches(source); - } - - /// - /// Searches the specified regex on the source - /// - /// - /// - /// - public static string Search(string regex, string source) - { - int position; - return Search(regex, source, out position); - } - - /// - /// Searches the specified regex on the source - /// - /// - /// - /// - /// - public static string Search(string regex, string source, out int position) - { - MatchCollection matches = Match(regex, source); - - if (matches.Count > 0) - { - position = matches[0].Index; - return matches[0].Value; - } - else - { - position = -1; - } - - return null; - } - - /// - /// Get regex instance for the given regex string. - /// - /// the regex string to use - /// the regex instance - private static Regex GetRegex(string regex) - { - Regex r; - if (!_regexes.TryGetValue(regex, out r)) - { - r = new Regex(regex, RegexOptions.IgnoreCase | RegexOptions.Singleline); - _regexes[regex] = r; - } - return r; - } - } -} diff --git a/Source/HtmlRenderer/HtmlRenderer.csproj b/Source/HtmlRenderer/HtmlRenderer.csproj index 74549b41d..a8ed63171 100644 --- a/Source/HtmlRenderer/HtmlRenderer.csproj +++ b/Source/HtmlRenderer/HtmlRenderer.csproj @@ -1,37 +1,9 @@ - - - + - Debug - AnyCPU - {FE611685-391F-4E3E-B27E-D3150E51E49B} + netstandard2.0 Library - Properties TheArtOfDev.HtmlRenderer - HtmlRenderer - v2.0 - 512 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - @@ -43,87 +15,5 @@ Properties\SharedAssemblyInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Source/SharedAssemblyInfo.cs b/Source/SharedAssemblyInfo.cs index d5336037f..349b7db5e 100644 --- a/Source/SharedAssemblyInfo.cs +++ b/Source/SharedAssemblyInfo.cs @@ -5,11 +5,11 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("HTML Renderer")] +//[assembly: AssemblyTitle("HTML Renderer")] [assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Open source hosted on CodePlex")] -[assembly: AssemblyProduct("HTML Renderer")] +//[assembly: AssemblyConfiguration("")] +//[assembly: AssemblyCompany("Open source hosted on CodePlex")] +//[assembly: AssemblyProduct("HTML Renderer")] [assembly: AssemblyCopyright("Copyright © 2008")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -26,4 +26,4 @@ // Version information for an assembly consists of the following four values: -[assembly: AssemblyVersion("1.5.1.0")] \ No newline at end of file +//[assembly: AssemblyVersion("1.5.1.0")] \ No newline at end of file