From 31afc9b36a8353992e21c335a68a98695d51c032 Mon Sep 17 00:00:00 2001 From: Bela Istok Date: Thu, 10 Jul 2025 18:24:20 -0500 Subject: [PATCH 1/4] Update .gitignore for build artifacts and tools Enhanced .gitignore to include entries for dotenv files, Visual Studio cache, NUnit test results, and various project-specific files. Removed or commented out several existing entries and added new sections for Tye, StyleCop, and CodeRush. Updated Azure publishing settings and improved overall coverage of ignored files to streamline development. --- .gitignore | 434 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 404 insertions(+), 30 deletions(-) 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 From 7457e0d5d6daa4f3c15c82ce335ce51484979bad Mon Sep 17 00:00:00 2001 From: Bela Istok Date: Thu, 10 Jul 2025 18:26:01 -0500 Subject: [PATCH 2/4] Update projects to target .NET Framework 4.8 - Changed `TargetFrameworkVersion` to 4.8 in multiple .csproj files for HtmlRenderer components. - Added `Prefer32Bit` property to project files. - Updated `Resources.Designer.cs` to use StronglyTypedResourceBuilder version 17.0.0.0. - Updated `packages.config` to reference PDFsharp version 1.50.5147. - Added new `app.config` files for HtmlRenderer.Demo.WPF and HtmlRenderer.Demo.WinForms. - Upgraded project files to use MSBuild Tools Version 12.0. --- .../Demo/Common/HtmlRenderer.Demo.Common.csproj | 6 ++++-- .../Common/Properties/Resources.Designer.cs | 4 ++-- Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj | 7 +++++-- Source/Demo/WPF/app.config | 3 +++ .../WinForms/HtmlRenderer.Demo.WinForms.csproj | 3 ++- Source/Demo/WinForms/app.config | 3 +++ .../HtmlRenderer.PdfSharp.csproj | 17 +++++++++-------- Source/HtmlRenderer.PdfSharp/packages.config | 2 +- Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj | 6 ++++-- .../HtmlRenderer.WinForms.csproj | 6 ++++-- Source/HtmlRenderer/HtmlRenderer.csproj | 7 +++++-- 11 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 Source/Demo/WPF/app.config create mode 100644 Source/Demo/WinForms/app.config diff --git a/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj b/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj index 7413cc397..61cf71256 100644 --- a/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj +++ b/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,7 +9,7 @@ Properties TheArtOfDev.HtmlRenderer.Demo.Common HtmlRendererDemoCommon - v2.0 + v4.8 512 @@ -21,6 +21,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -29,6 +30,7 @@ TRACE prompt 4 + false 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/WPF/HtmlRenderer.Demo.WPF.csproj b/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj index 8c26cdcc4..d23e99825 100644 --- a/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj +++ b/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,7 +9,7 @@ Properties TheArtOfDev.HtmlRenderer.Demo.WPF HtmlRendererWpfDemo - v4.0 + v4.8 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 @@ -26,6 +26,7 @@ DEBUG;TRACE prompt 4 + false AnyCPU @@ -35,6 +36,7 @@ TRACE prompt 4 + false html.ico @@ -122,6 +124,7 @@ + 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/WinForms/HtmlRenderer.Demo.WinForms.csproj b/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj index 95dafc2f1..b2ff454c5 100644 --- a/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj +++ b/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj @@ -10,7 +10,7 @@ Properties TheArtOfDev.HtmlRenderer.Demo.WinForms HtmlRendererWinFormsDemo - v2.0 + v4.8 @@ -171,6 +171,7 @@ + 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/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj b/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj index ef0fd7acc..6fb24d71b 100644 --- a/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj +++ b/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,10 +9,11 @@ Properties TheArtOfDev.HtmlRenderer.PdfSharp HtmlRenderer.PdfSharp - v2.0 + v4.8 512 ..\ true + true @@ -22,6 +23,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -30,15 +32,14 @@ TRACE prompt 4 + false - - ..\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.dll - True + + ..\packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.dll - - ..\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.Charting.dll - True + + ..\packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.Charting.dll diff --git a/Source/HtmlRenderer.PdfSharp/packages.config b/Source/HtmlRenderer.PdfSharp/packages.config index 2f092fd78..053aabfed 100644 --- a/Source/HtmlRenderer.PdfSharp/packages.config +++ b/Source/HtmlRenderer.PdfSharp/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj b/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj index 80c4b97f9..fb433413f 100644 --- a/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj +++ b/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,7 +9,7 @@ Properties TheArtOfDev.HtmlRenderer.WPF HtmlRenderer.WPF - v3.0 + v4.8 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 @@ -24,6 +24,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -32,6 +33,7 @@ TRACE prompt 4 + false diff --git a/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj b/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj index ce1a98759..bbb93fc7f 100644 --- a/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj +++ b/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -12,7 +12,7 @@ HtmlRenderer.WinForms - v2.0 + v4.8 @@ -46,6 +46,7 @@ 4 false AllRules.ruleset + false pdbonly @@ -55,6 +56,7 @@ prompt 4 AllRules.ruleset + false diff --git a/Source/HtmlRenderer/HtmlRenderer.csproj b/Source/HtmlRenderer/HtmlRenderer.csproj index 74549b41d..412190082 100644 --- a/Source/HtmlRenderer/HtmlRenderer.csproj +++ b/Source/HtmlRenderer/HtmlRenderer.csproj @@ -1,5 +1,5 @@  - + Debug @@ -9,8 +9,9 @@ Properties TheArtOfDev.HtmlRenderer HtmlRenderer - v2.0 + v4.8 512 + true @@ -20,6 +21,7 @@ DEBUG;TRACE prompt 4 + false pdbonly @@ -28,6 +30,7 @@ TRACE prompt 4 + false From 0b8804369cf97c2f73faf4e1322e286ea287fd9f Mon Sep 17 00:00:00 2001 From: Bela Istok Date: Thu, 10 Jul 2025 23:02:58 -0500 Subject: [PATCH 3/4] Add five new binary image files This commit introduces five binary image files: comment16.png, delete16.png, delete32.png, method16.png, and property16.png. because the core version do not support gif images --- Source/Demo/Common/Resources/comment16.png | Bin 0 -> 545 bytes Source/Demo/Common/Resources/delete16.png | Bin 0 -> 583 bytes Source/Demo/Common/Resources/delete32.png | Bin 0 -> 1179 bytes Source/Demo/Common/Resources/method16.png | Bin 0 -> 522 bytes Source/Demo/Common/Resources/property16.png | Bin 0 -> 678 bytes 5 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Source/Demo/Common/Resources/comment16.png create mode 100644 Source/Demo/Common/Resources/delete16.png create mode 100644 Source/Demo/Common/Resources/delete32.png create mode 100644 Source/Demo/Common/Resources/method16.png create mode 100644 Source/Demo/Common/Resources/property16.png diff --git a/Source/Demo/Common/Resources/comment16.png b/Source/Demo/Common/Resources/comment16.png new file mode 100644 index 0000000000000000000000000000000000000000..4b013c8257ed308ec964377868e71c96d70841a7 GIT binary patch literal 545 zcmV++0^a?JP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0k%m*K~y+Tm6E?p z8(|!WpF1H*@v@YJ94%EOBHU0>iX2!)nOb$)c0$Ct13`4B0=F#;W$>h60+Rx3+Ee8kR zX*Ajt3d<5tf}^8tQ7mRr)%QRuoO?yRZn3tui(!CU zAUn=D<+26b^#qT*AC1f2-cM4gDdeT46{%K>u)lx7{k`22bcf!=aawF{e&OV#NiJ8A zf*u?nmqoLA$>L&~Y<3Dwn+P`II3D%-HRtD-?CktN*FQ5q|LM60{hXauMWynUQYp*A zLYhkDHyax!s;V+KmwC}b1_|g@I+3^_8kMP5ee!vI=&I!K!4tLG6?f@lCmQ_G00000NkvXXu0mjf6ngGv literal 0 HcmV?d00001 diff --git a/Source/Demo/Common/Resources/delete16.png b/Source/Demo/Common/Resources/delete16.png new file mode 100644 index 0000000000000000000000000000000000000000..a6f0dc58e70a8435ccbfcdea7d17818250c6702e GIT binary patch literal 583 zcmV-N0=WH&P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0o+MMK~y+Tm6Abd z(or18KYu4Y{%pcJdv|zgm#9E?{Rft9-h>GTnTJ702Zt1~9XhNaJ1H@dQ0TBgq`(e! zScCq96^*PbHJNP-i_x*m~d*9#FnvEs^xtBQ^3Wu1Sn$#Er z2f%(~Uz%S{mXpi0f3@X#Q9nW#va(xI8V3OXz~}SP>R2QnCfV8E843})kVl;(nYf>z zUazZlt=VWIbRkMl(1hH6*iPJ95 zGbb*WYowWr0)#H)<0sDm=$>|Ibu6Oc=y@583J|)G(WM8}ejG4&eU3t*z}3qh+JD+? ze%>CM&Oir37czP`O08DIFbq~!SJYl6n`i6edp6!|3_L~MK@gOlG} zo1J0ae?y(zk8Ro7d?3W}-(%H<>cBd&Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1TaZNK~z{r#g;!v zTVE8%Kko;|n}pK$9zt|7fh?(0aVjYk5d_CTCzV<;6slQ7p-?i4LkX3FI63O*D1snP zj-_4NxA{_+yrSe?2h*z#x5F~p?=!U4{7L=Qy70SYv{t}z z99^we5ke4)#Ym-62qBCnr~gn50Hu`P+S)=&Nh}tlR;vLJi^Z6knIV}>{woNjl=gj} zv$HckfBuYZ+vIY&W`MP|HIm6Bx3{+qfcq*Ii+xu^DWyHnk%9t9_mk@J^>JkL>kqIL?Qr4Df@ybm&^L-=!o<4a~#Lv$&)8MfBw9wnr%IBe0;1A z4-c_zn@A+mRE=0HMzvaHadDAMCesx{N~uew5&#z$7hGOmvb40snDz?(P^E7-&EM zJbLtqTrNkUP(Ufg@bEB7DPF#O$GZ-Q8Uy zl}hpb`*&_`ZlFFLS65d&c<`XF;PeXsP^naOrBY#VaF9eI!RY8Hi9`Yb*LA5>D&b4o zFM#7XdTwrxtE($a(?ke?=XnSrNF)+``}U1|K95o=G(>2Cjg1Xm|2U(gqga*&z`J+v z$Ye5Dmc_$|50O%m&*xjWcU35WQmLd54h{e?O_OLeitD;8EiExNHpcq;y0NmdLOPws zG);Wp$8nrcRruu;IF6%(8NXllVzJnGPy&7Y_)%|eZUW%@KKuLozkD}(R-jxi>$SBt zsAq0j7M|xZKR@3V9AJEW+<5)^HPo-{U~eyV1&~te)zwv$QjIm=_j&yIF;i1hO}_V) z&1Q|+*;$5$hC)q6M*yXie)Hx{Be)O(Ap}xN78VwI-t7R>)6>TF^);zfibA2#YHm_T zfRmFGE-x>e06foQVqzlnMYFTBgX_9PqfyG`a@Q(!1lZf#BN~l1nl5O-TrSt@+Eqdb zqf{ypkH;w%i>>B{+5k>ZPjx&VZ(5U5lFepAXCEl|2k?C#DP_khv;mx-pEEEp0QHxS z`Vl;P_N>J-oIZT`fMr>H`SPXJ1f2kaKc9F!j%8UWrAVjKWV6}6vJWJLFlJ|GdH?=> zs|h***tX5x-5uB0*HkJM0A9R!(dyQhCMG7JK3%Q0wwo|`^Xuov%*+hS%gg^L`!H$) t2qdM{_4)tbg3}A&cd4xhez*QOz)#Ik4a0}beV+gT002ovPDHLkV1n6igP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0iQ`kK~y+TrIJlc z8$keupV{VMHJF1jUu}tzNQ(t8g8w7XL!r=1p}n6!1p9l%`75H|tmWmICXyMPa5ucqEKp3-I{i6Y^7e?7x>1aXzAB=@bn?uB1^k zVC-#-%w&e1r#%FYg0Ry(U^*rh$6(;~0A0bZOTkS{$G*}V?qzsn7ck;`LAVm`r# z)O%cxrL(sWa#tWt*tP`H6uf&CLnwjo#K-#2^`_*|P5q=!av_NW*Mb3f{boVXPUfen~U< zXb=EBtrKzgQTu0NIwlj@&#gBAsAj7ye_Em6-_P8S@Ax|d7`8$D+Zdkbp4$ZgwLdi$ z$Ct>Jb2JY2i6`QChrG>FwTaA1^)WiCD!(dM^0r>kik3gI9quhS1@~ literal 0 HcmV?d00001 diff --git a/Source/Demo/Common/Resources/property16.png b/Source/Demo/Common/Resources/property16.png new file mode 100644 index 0000000000000000000000000000000000000000..328e5f694902f897f91b1263cb192abcd6e760a0 GIT binary patch literal 678 zcmV;X0$KfuP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0y{}WK~y+TrITGq z(@_}4fBUzD%sxeGq)KlPCT=)4zxL^TyZEQfX&2ECUN}7GJ*d5(V*R8CM9JW z-L8C`pDj#IsndZ_gh(KacfyUK^gP}Eev;Rvtu(NIct=j=BzJGOV5&`B(xX8wk-0g> z$Go&!V=UxsXZ}DsO8jDgjLhBKGc{o{ZJ^cS0U#345{rgd2>IBO9OTMLI~hpUne3Qm_Kwuth#XB3_n3JMKeuYX0_HXY&l#10j$qNq3dq^%PGW3e9dpK&~g4(k&o zl@42PVk!wmV&a>P%GhL72Hg?qb%mtIwfYgXi$;qHN>Ax&w!V+w1Ay$@yhKUG*4?+v zF%VZ1VUeGHk#8QgR!g9%s=g^sM=y#tDbafcVS)DNEz7hOpXp!u4TGVWWOX&A6aWAK M07*qoM6N<$f`4>0{Qv*} literal 0 HcmV?d00001 From c7b05487fe311e586df7cca80ff9d931361d0782 Mon Sep 17 00:00:00 2001 From: Bela Istok Date: Thu, 10 Jul 2025 23:03:41 -0500 Subject: [PATCH 4/4] Net 8 Project Migration --- .../Common/HtmlRenderer.Demo.Common.csproj | 79 ++-- Source/Demo/Common/Properties/AssemblyInfo.cs | 25 -- Source/Demo/Common/Resources.cs | 8 +- Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj | 133 +------ Source/Demo/WPF/Properties/AssemblyInfo.cs | 56 --- Source/Demo/WPF/packages.config | 4 - Source/Demo/WinForms/DemoForm.cs | 9 +- .../HtmlRenderer.Demo.WinForms.csproj | 150 +------- Source/Demo/WinForms/Program.cs | 4 +- .../Demo/WinForms/Properties/AssemblyInfo.cs | 36 -- .../Demo/WinForms/SubstitutingFontResolver.cs | 359 ++++++++++++++++++ Source/Demo/WinForms/packages.config | 4 - .../Adapters/PdfSharpAdapter.cs | 6 +- .../HtmlRenderer.PdfSharp.csproj | 82 +--- Source/HtmlRenderer.PdfSharp/packages.config | 4 - .../HtmlRenderer.WPF/HtmlRenderer.WPF.csproj | 76 +--- .../HtmlRenderer.WinForms.csproj | 80 +--- .../Core/Parse/RegexParserHelper.cs | 227 ----------- Source/HtmlRenderer/HtmlRenderer.csproj | 117 +----- Source/SharedAssemblyInfo.cs | 10 +- 20 files changed, 448 insertions(+), 1021 deletions(-) delete mode 100644 Source/Demo/WPF/Properties/AssemblyInfo.cs delete mode 100644 Source/Demo/WPF/packages.config delete mode 100644 Source/Demo/WinForms/Properties/AssemblyInfo.cs create mode 100644 Source/Demo/WinForms/SubstitutingFontResolver.cs delete mode 100644 Source/Demo/WinForms/packages.config delete mode 100644 Source/HtmlRenderer.PdfSharp/packages.config delete mode 100644 Source/HtmlRenderer/Core/Parse/RegexParserHelper.cs diff --git a/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj b/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj index 61cf71256..7b4635d22 100644 --- a/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj +++ b/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj @@ -1,61 +1,41 @@ - - - + - Debug - AnyCPU - {2390B71F-9400-47F4-B23A-7F2649C87D35} + net8.0-windows Library - Properties TheArtOfDev.HtmlRenderer.Demo.Common HtmlRendererDemoCommon - v4.8 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false + 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 @@ -149,10 +129,7 @@ - - {FE611685-391F-4E3E-B27E-D3150E51E49B} - HtmlRenderer - + @@ -169,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/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/WPF/HtmlRenderer.Demo.WPF.csproj b/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj index d23e99825..f72db3a54 100644 --- a/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj +++ b/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj @@ -1,121 +1,23 @@ - - - + - Debug - AnyCPU - {F02E0216-4AE3-474F-9381-FCB93411CDB0} + net8.0-windows WinExe - Properties TheArtOfDev.HtmlRenderer.Demo.WPF HtmlRendererWpfDemo - v4.8 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - ..\..\ true - - - x86 - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - + 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 - + + + @@ -123,11 +25,6 @@ - - - - - @@ -135,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/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 b2ff454c5..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 - v4.8 - - - - - 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,38 +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}. - - - @@ -189,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/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 6fb24d71b..5893e7327 100644 --- a/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj +++ b/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj @@ -1,91 +1,19 @@ - - - + - Debug - AnyCPU - {CA249F5D-9285-40A6-B217-5889EF79FD7E} + netstandard2.0 Library - Properties TheArtOfDev.HtmlRenderer.PdfSharp - HtmlRenderer.PdfSharp - v4.8 - 512 ..\ true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - ..\packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.dll - - - ..\packages\PDFsharp.1.50.5147\lib\net20\PdfSharp.Charting.dll - - - - - - 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 053aabfed..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 fb433413f..47b9648c2 100644 --- a/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj +++ b/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj @@ -1,87 +1,23 @@ - - - + - Debug - AnyCPU - {7E4E8DB5-85AD-4388-BDCB-38C6F423B8B0} - library - Properties + net8.0-windows + Library TheArtOfDev.HtmlRenderer.WPF - HtmlRenderer.WPF - v4.8 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false + true + true - pdbonly - true bin\Release.WPF.Net35\ - TRACE - prompt - 4 - false - - - - - - - - - - - {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 bbb93fc7f..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 - - - v4.8 - - - - - 2.0 + publish\ true Disk @@ -33,66 +19,31 @@ false false true - - + true + true - true - full - false bin\DebugNet20\ - DEBUG;TRACE - prompt - 4 - false AllRules.ruleset - false - pdbonly - true bin\ReleaseNet20\ - TRACE - prompt - 4 AllRules.ruleset - false - - - - - - Properties\SharedAssemblyInfo.cs - - - - - - - - - - - - + Component - + Component - - + Component - - - - + @@ -112,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 412190082..a8ed63171 100644 --- a/Source/HtmlRenderer/HtmlRenderer.csproj +++ b/Source/HtmlRenderer/HtmlRenderer.csproj @@ -1,40 +1,9 @@ - - - + - Debug - AnyCPU - {FE611685-391F-4E3E-B27E-D3150E51E49B} + netstandard2.0 Library - Properties TheArtOfDev.HtmlRenderer - HtmlRenderer - v4.8 - 512 - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - @@ -46,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