diff --git a/Build/1 build libs.bat b/Build/1 build libs.bat index 55b848afd..bdc8b034a 100644 --- a/Build/1 build libs.bat +++ b/Build/1 build libs.bat @@ -5,7 +5,7 @@ CD %~dp0 echo Set params... set verb=/verbosity:minimal -set msbuild=C:\Windows\Microsoft.Net\Framework\v4.0.30319\MSBuild.exe +set msbuild="C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\bin\MSBuild.exe" set c_proj=..\Source\HtmlRenderer\HtmlRenderer.csproj set wf_proj=..\Source\HtmlRenderer.WinForms\HtmlRenderer.WinForms.csproj @@ -24,80 +24,47 @@ set wpf_out=..\..\Build\%wpf_rel% set mono_out=..\..\Build\%mono_rel% set pdfs_out=..\..\Build\%pdfs_rel% -set t_20=Configuration=Release;TargetFrameworkVersion=v2.0 -set t_30=Configuration=Release;TargetFrameworkVersion=v3.0 -set t_35=Configuration=Release;TargetFrameworkVersion=v3.5;TargetFrameworkProfile=client -set t_40=Configuration=Release;TargetFrameworkVersion=v4.0;TargetFrameworkProfile=client -set t_45=Configuration=Release;TargetFrameworkVersion=v4.5 +set t_48=Configuration=Release;TargetFrameworkVersion=v4.8 -set t_mono_20=%t_20%;DefineConstants=MONO -set t_mono_35=%t_35%;DefineConstants=MONO -set t_mono_40=%t_40%;DefineConstants=MONO -set t_mono_45=%t_45%;DefineConstants=MONO +set t_mono_48=%t_48%;DefineConstants=MONO echo. echo. echo - BUILD Core... echo. -%msbuild% %c_proj% /t:rebuild /p:%t_20%;OutputPath=%c_out%\NET20 %verb% -%msbuild% %c_proj% /t:rebuild /p:%t_30%;OutputPath=%c_out%\NET30 %verb% -%msbuild% %c_proj% /t:rebuild /p:%t_35%;OutputPath=%c_out%\NET35 %verb% -%msbuild% %c_proj% /t:rebuild /p:%t_40%;OutputPath=%c_out%\NET40 %verb% -%msbuild% %c_proj% /t:rebuild /p:%t_45%;OutputPath=%c_out%\NET45 %verb% +%msbuild% %c_proj% /t:rebuild /p:%t_48%;OutputPath=%c_out%\NET48 %verb% echo. echo. echo - BUILD WinForms... echo. -%msbuild% %wf_proj% /t:rebuild /p:%t_20%;OutputPath=%wf_out%_t\NET20 %verb% -%msbuild% %wf_proj% /t:rebuild /p:%t_35%;OutputPath=%wf_out%_t\NET35 %verb% -%msbuild% %wf_proj% /t:rebuild /p:%t_40%;OutputPath=%wf_out%_t\NET40 %verb% -%msbuild% %wf_proj% /t:rebuild /p:%t_45%;OutputPath=%wf_out%_t\NET45 %verb% -xcopy %wf_rel%_t\NET20\HtmlRenderer.WinForms.* %wf_rel%\NET20 /I -xcopy %wf_rel%_t\NET35\HtmlRenderer.WinForms.* %wf_rel%\NET35 /I -xcopy %wf_rel%_t\NET40\HtmlRenderer.WinForms.* %wf_rel%\NET40 /I -xcopy %wf_rel%_t\NET45\HtmlRenderer.WinForms.* %wf_rel%\NET45 /I +%msbuild% %wf_proj% /t:rebuild /p:%t_48%;OutputPath=%wf_out%_t\NET48 %verb% +xcopy %wf_rel%_t\NET48\HtmlRenderer.WinForms.* %wf_rel%\NET48 /I rmdir %wf_rel%_t /s /q echo. echo. echo - BUILD WPF... echo. -%msbuild% %wpf_proj% /t:rebuild /p:%t_30%;OutputPath=%wpf_out%_t\NET30 %verb% -%msbuild% %wpf_proj% /t:rebuild /p:%t_35%;OutputPath=%wpf_out%_t\NET35 %verb% -%msbuild% %wpf_proj% /t:rebuild /p:%t_40%;OutputPath=%wpf_out%_t\NET40 %verb% -%msbuild% %wpf_proj% /t:rebuild /p:%t_45%;OutputPath=%wpf_out%_t\NET45 %verb% -xcopy %wpf_rel%_t\NET30\HtmlRenderer.WPF.* %wpf_rel%\NET30 /I -xcopy %wpf_rel%_t\NET35\HtmlRenderer.WPF.* %wpf_rel%\NET35 /I -xcopy %wpf_rel%_t\NET40\HtmlRenderer.WPF.* %wpf_rel%\NET40 /I -xcopy %wpf_rel%_t\NET45\HtmlRenderer.WPF.* %wpf_rel%\NET45 /I +%msbuild% %wpf_proj% /t:rebuild /p:%t_48%;OutputPath=%wpf_out%_t\NET48 %verb% +xcopy %wpf_rel%_t\NET48\HtmlRenderer.WPF.* %wpf_rel%\NET48 /I rmdir %wpf_rel%_t /s /q echo. echo. echo - BUILD Mono... echo. -%msbuild% %wf_proj% /t:rebuild /p:%t_mono_20%;OutputPath=%mono_out%_t\NET20 %verb% -%msbuild% %wf_proj% /t:rebuild /p:%t_mono_35%;OutputPath=%mono_out%_t\NET35 %verb% -%msbuild% %wf_proj% /t:rebuild /p:%t_mono_40%;OutputPath=%mono_out%_t\NET40 %verb% -%msbuild% %wf_proj% /t:rebuild /p:%t_mono_45%;OutputPath=%mono_out%_t\NET45 %verb% -xcopy %mono_rel%_t\NET20\HtmlRenderer.WinForms.* %mono_rel%\NET20 /I -xcopy %mono_rel%_t\NET35\HtmlRenderer.WinForms.* %mono_rel%\NET35 /I -xcopy %mono_rel%_t\NET40\HtmlRenderer.WinForms.* %mono_rel%\NET40 /I -xcopy %mono_rel%_t\NET45\HtmlRenderer.WinForms.* %mono_rel%\NET45 /I + +%msbuild% %wf_proj% /t:rebuild /p:%t_mono_48%;OutputPath=%mono_out%_t\NET48 %verb% + +xcopy %mono_rel%_t\NET48\HtmlRenderer.WinForms.* %mono_rel%\NET48 /I rmdir %mono_rel%_t /s /q echo. echo. echo - BUILD PdfSharp... echo. -%msbuild% %pdfs_proj% /t:rebuild /p:%t_20%;OutputPath=%pdfs_out%_t\NET20 %verb% -%msbuild% %pdfs_proj% /t:rebuild /p:%t_35%;OutputPath=%pdfs_out%_t\NET35 %verb% -%msbuild% %pdfs_proj% /t:rebuild /p:%t_40%;OutputPath=%pdfs_out%_t\NET40 %verb% -%msbuild% %pdfs_proj% /t:rebuild /p:%t_45%;OutputPath=%pdfs_out%_t\NET45 %verb% -xcopy %pdfs_rel%_t\NET20\HtmlRenderer.PdfSharp.* %pdfs_rel%\NET20 /I -xcopy %pdfs_rel%_t\NET35\HtmlRenderer.PdfSharp.* %pdfs_rel%\NET35 /I -xcopy %pdfs_rel%_t\NET40\HtmlRenderer.PdfSharp.* %pdfs_rel%\NET40 /I -xcopy %pdfs_rel%_t\NET45\HtmlRenderer.PdfSharp.* %pdfs_rel%\NET45 /I +%msbuild% %pdfs_proj% /t:rebuild /p:%t_48%;OutputPath=%pdfs_out%_t\NET48 %verb% +xcopy %pdfs_rel%_t\NET48\HtmlRenderer.PdfSharp.* %pdfs_rel%\NET48 /I rmdir %pdfs_rel%_t /s /q \ No newline at end of file diff --git a/Build/2 build demo.bat b/Build/2 build demo.bat index 61310b3f7..fb0135c5d 100644 --- a/Build/2 build demo.bat +++ b/Build/2 build demo.bat @@ -3,30 +3,30 @@ CD %~dp0 set verb=/verbosity:minimal -set msbuild=C:\Windows\Microsoft.Net\Framework\v4.0.30319\MSBuild.exe +set msbuild="C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\bin\MSBuild.exe" set t_20=Configuration=Release;TargetFrameworkVersion=v2.0 -set t_40=Configuration=Release;TargetFrameworkVersion=v4.0;TargetFrameworkProfile=client -set t_mono_20=%t_20%;DefineConstants=MONO +set t_48=Configuration=Release;TargetFrameworkVersion=v4.8 +set t_mono_20=%t_48%;DefineConstants=MONO echo. echo. echo - BUILD WinForms... echo. -%msbuild% ..\Source\Demo\WinForms\HtmlRenderer.Demo.WinForms.csproj /t:rebuild /p:%t_20%;OutputPath=..\..\..\Build\Release\Demo\WinForms %verb% +%msbuild% ..\Source\Demo\WinForms\HtmlRenderer.Demo.WinForms.csproj /t:rebuild /p:%t_48%;OutputPath=..\..\..\Build\Release\Demo\WinForms %verb% echo. echo. echo - BUILD Mono... echo. -%msbuild% ..\Source\Demo\WinForms\HtmlRenderer.Demo.WinForms.csproj /t:rebuild /p:%t_mono_20%;OutputPath=..\..\..\Build\Release\Demo\Mono %verb% +%msbuild% ..\Source\Demo\WinForms\HtmlRenderer.Demo.WinForms.csproj /t:rebuild /p:%t_mono_48%;OutputPath=..\..\..\Build\Release\Demo\Mono %verb% echo. echo. echo - BUILD WPF... echo. -%msbuild% ..\Source\Demo\WPF\HtmlRenderer.Demo.WPF.csproj /t:rebuild /p:%t_40%;OutputPath=..\..\..\Build\Release\Demo\WPF %verb% +%msbuild% ..\Source\Demo\WPF\HtmlRenderer.Demo.WPF.csproj /t:rebuild /p:%t_48%;OutputPath=..\..\..\Build\Release\Demo\WPF %verb% echo. echo - Handle outputs... diff --git a/Build/3 archive.bat b/Build/3 archive.bat index 033aac66a..6f6930d31 100644 --- a/Build/3 archive.bat +++ b/Build/3 archive.bat @@ -11,7 +11,7 @@ echo. echo. echo - Git clone... echo. -"C:\Program Files (x86)\Git\bin\git.exe" clone -q --branch=v1.5 https://github.com/ArthurHub/HTML-Renderer.git Release\git +"C:\Program Files (x86)\Git\bin\git.exe" clone -q --branch=v6.2 https://github.com/ArthurHub/HTML-Renderer.git Release\git xcopy Release\git\Source Release\Source /I /E rmdir Release\git /s /q diff --git a/Build/NuGet.exe b/Build/NuGet.exe index 3ffdd33c6..ed048fe88 100644 Binary files a/Build/NuGet.exe and b/Build/NuGet.exe differ diff --git a/Build/NuGet/HtmlRenderer.Core.nuspec b/Build/NuGet/HtmlRenderer.Core.nuspec index 25e8783ea..c059af5fc 100644 --- a/Build/NuGet/HtmlRenderer.Core.nuspec +++ b/Build/NuGet/HtmlRenderer.Core.nuspec @@ -7,7 +7,7 @@ Arthur Teplitzki Arthur Teplitzki https://htmlrenderer.codeplex.com/license - https://htmlrenderer.codeplex.com/ + https://github.com/dem-v/HTML-Renderer/ https://github.com/ArthurHub/HTML-Renderer/blob/master/html.ico?raw=true false @@ -24,15 +24,7 @@ html render renderer draw core - - - - - - - - - - + + \ No newline at end of file diff --git a/Build/NuGet/HtmlRenderer.Mono.nuspec b/Build/NuGet/HtmlRenderer.Mono.nuspec index 11840a00c..4f2ec4b85 100644 --- a/Build/NuGet/HtmlRenderer.Mono.nuspec +++ b/Build/NuGet/HtmlRenderer.Mono.nuspec @@ -7,7 +7,7 @@ Arthur Teplitzki Arthur Teplitzki https://htmlrenderer.codeplex.com/license - https://htmlrenderer.codeplex.com/ + https://github.com/dem-v/HTML-Renderer/ https://github.com/ArthurHub/HTML-Renderer/blob/master/html.ico?raw=true false @@ -39,18 +39,12 @@ - + - - - - - - - - + + \ No newline at end of file diff --git a/Build/NuGet/HtmlRenderer.PdfSharp.nuspec b/Build/NuGet/HtmlRenderer.PdfSharp.nuspec index 84e5efada..25aa912a5 100644 --- a/Build/NuGet/HtmlRenderer.PdfSharp.nuspec +++ b/Build/NuGet/HtmlRenderer.PdfSharp.nuspec @@ -7,7 +7,7 @@ Arthur Teplitzki Arthur Teplitzki https://htmlrenderer.codeplex.com/license - https://htmlrenderer.codeplex.com/ + https://github.com/dem-v/HTML-Renderer/ https://github.com/ArthurHub/HTML-Renderer/blob/master/html.ico?raw=true false @@ -34,19 +34,13 @@ - - + + - - - - - - - - + + \ No newline at end of file diff --git a/Build/NuGet/HtmlRenderer.WPF.nuspec b/Build/NuGet/HtmlRenderer.WPF.nuspec index f3b20bcee..5d7530747 100644 --- a/Build/NuGet/HtmlRenderer.WPF.nuspec +++ b/Build/NuGet/HtmlRenderer.WPF.nuspec @@ -7,7 +7,7 @@ Arthur Teplitzki Arthur Teplitzki https://htmlrenderer.codeplex.com/license - https://htmlrenderer.codeplex.com/ + https://github.com/dem-v/HTML-Renderer/ https://github.com/ArthurHub/HTML-Renderer/blob/master/html.ico?raw=true false @@ -38,18 +38,12 @@ - + - - - - - - - - + + \ No newline at end of file diff --git a/Build/NuGet/HtmlRenderer.WinForms.nuspec b/Build/NuGet/HtmlRenderer.WinForms.nuspec index 37fcfe31b..b296f3a86 100644 --- a/Build/NuGet/HtmlRenderer.WinForms.nuspec +++ b/Build/NuGet/HtmlRenderer.WinForms.nuspec @@ -7,7 +7,7 @@ Arthur Teplitzki Arthur Teplitzki https://htmlrenderer.codeplex.com/license - https://htmlrenderer.codeplex.com/ + https://github.com/dem-v/HTML-Renderer/ https://github.com/ArthurHub/HTML-Renderer/blob/master/html.ico?raw=true false @@ -39,18 +39,12 @@ - + - - - - - - - - + + \ No newline at end of file diff --git a/Source/.nuget/NuGet.exe b/Source/.nuget/NuGet.exe index c41a0d0de..ed048fe88 100644 Binary files a/Source/.nuget/NuGet.exe and b/Source/.nuget/NuGet.exe differ 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/PerfSamples/1.Big table.htm b/Source/Demo/Common/PerfSamples/1.Big table.htm index 9aad29719..947d4b18a 100644 --- a/Source/Demo/Common/PerfSamples/1.Big table.htm +++ b/Source/Demo/Common/PerfSamples/1.Big table.htm @@ -3082,6 +3082,6 @@

- - Intro - - - -

- HTML Renderer Project - $$Platform$$ -
- Release $$Release$$ -

-
-

- - - - - -
- - - Everything you see on this panel (see samples on the left) is custom-painted - by the HTML Renderer, including tables, images, links and videos.
- This project allows you to have the rich format power of HTML on your desktop applications - without WebBrowser control or MSHTML.
- The library is 100% managed code without any external dependencies, the only - requirement is .NET 2.0 or higher, including support for Client Profile. -
-

-

- Text selection (copy to clipboard) -

-
- The rendered html has full support for text selection including drag-and-drop - and copy to clipboard of rich html and plain text to handle paste - operation to editor that support rich or/and plain text.
- Additionally there is a context-menu with select all, copy text, copy image, - save image, open link, copy link url, open video, copy video url. + + + + + + Intro + + + +

+ HTML Renderer Project - $$Platform$$ +
+ Release $$Release$$ +

+
+

+

+
+
+ HTML Icon +
+
+ Everything you see on this panel (see samples on the left) is custom-painted + by the HTML Renderer, including tables, images, links and videos.
+ This project allows you to have the rich format power of HTML on your desktop applications + without WebBrowser control or MSHTML.
+ The library is 100% managed code without any external dependencies, the only + requirement is .NET 2.0 or higher, including support for Client Profile. +
+
-

- Cascading Style Sheets (CSS) support -

-
- The core layout engine of the renderer was builded according to CSS Level 2 specification, - so you can use Cascading Style Sheets to format your html documents.
- Additionally there are a couple extensions: Gradients on backgrounds and - rounded corners. -
-

- WinForms controls -

-
- It comes with handy WinForms controls (see Sample Form): -
-
    -
  • HtmlPanel - The control where you are reading this, panel with scrollbars.
  • -
  • HtmlLabel - Same as html panel but without scrollbars and optional - auto size.
  • -
  • HtmlToolTip - For ToolTip with rich html.
  • -
-

- Benefits -

-
    -
  • 100% managed code and no external dependencies.
  • -
  • Supports .NET 2.0 or higher including Client Profile.
  • -
  • Handles "real world" malformed HTML, it doesn't have to be XHTML.
  • -
  • Lightweight (~300K).
  • -
  • High performance and low memory footprint.
  • -
  • Extendable and configurable.
  • -
-

- Limitations -

-
    -
  • All HTML end tags marked as - optional should be there. No problem with tags marked as forbidden.
  • -
-
-

- On the roadmap

- Of course it's not quite finished yet. Here are some of the important things to - do. -
    -
  • Better performance
  • -
  • Support of position CSS property
  • -
  • Support of height and min-height CSS property
  • -
  • Better tables support, especially layouts
  • -
  • Support image align
  • -
  • Handle :hover selector
  • -
  • Selection by shift+arrows
  • -
  • Better HTML tag parsing (optional closing tags)
  • -
  • More styles support
  • -
-

- Vision -

-
    -
  • Most complete static HTML Renderer (no java script).
  • -
  • Commercial web browser performance level.
  • -
-
-

- 2012 - Arthur Teplitzki -

-
- http://TheArtOfDev.com -
-

- 2009 - Jose Manuel Menendez Poo -

-
- www.menendezpoo.com -
+

+

+ Text selection (copy to clipboard) +

+
+ The rendered html has full support for text selection including drag-and-drop + and copy to clipboard of rich html and plain text to handle paste + operation to editor that support rich or/and plain text.
+ Additionally there is a context-menu with select all, copy text, copy image, + save image, open link, copy link url, open video, copy video url. +
+

+ Cascading Style Sheets (CSS) support +

+
+ The core layout engine of the renderer was builded according to CSS Level 2 specification, + so you can use Cascading Style Sheets to format your html documents.
+ Additionally there are a couple extensions: Gradients on backgrounds and + rounded corners. +
+

+ WinForms controls +

+
+ It comes with handy WinForms controls (see Sample Form): +
+
    +
  • HtmlPanel - The control where you are reading this, panel with scrollbars.
  • +
  • + HtmlLabel - Same as html panel but without scrollbars and optional + auto size. +
  • +
  • HtmlToolTip - For ToolTip with rich html.
  • +
+

+ Benefits +

+
    +
  • 100% managed code and no external dependencies.
  • +
  • Supports .NET 2.0 or higher including Client Profile.
  • +
  • Handles "real world" malformed HTML, it doesn't have to be XHTML.
  • +
  • Lightweight (~300K).
  • +
  • High performance and low memory footprint.
  • +
  • Extendable and configurable.
  • +
+

+ Limitations +

+
    +
  • + All HTML end tags marked as + optional + should be there. No problem with tags marked as forbidden. +
  • +
+
+

+ On the roadmap +

+ Of course it's not quite finished yet. Here are some of the important things to + do. +
    +
  • Better performance
  • +
  • Support of position CSS property
  • +
  • Support of height and min-height CSS property
  • +
  • Better tables support, especially layouts
  • +
  • Support image align
  • +
  • Handle :hover selector
  • +
  • Selection by shift+arrows
  • +
  • Better HTML tag parsing (optional closing tags)
  • +
  • More styles support
  • +
+

+ Vision +

+
    +
  • Most complete static HTML Renderer (no java script).
  • +
  • Commercial web browser performance level.
  • +
+
+

+ 2012 - Arthur Teplitzki +

+
+ http://TheArtOfDev.com +
+

+ 2009 - Jose Manuel Menendez Poo +

+
+ www.menendezpoo.com
- + +
+ \ No newline at end of file diff --git a/Source/Demo/Common/Samples/07.Additional features.htm b/Source/Demo/Common/Samples/07.Additional features.htm index 764e9511c..868a181d1 100644 --- a/Source/Demo/Common/Samples/07.Additional features.htm +++ b/Source/Demo/Common/Samples/07.Additional features.htm @@ -1,170 +1,218 @@ - - - Additional features - - - - -

- Additional features -

-
-

- There are some additional features that you may already discovered about the renderer - core engine.

-

- Graphic features

-

- I have always wanted the W3C to add this features to the CSS spec (and so far, not - there yet :)

-
    -
  • Gradients on backgrounds
  • -
  • Rounded corners
  • -
-

- And I think many many web designers would agree. Is it so hard or what?.

-

- Background Gradients

-

- It is a simple two color linear gradient, achieved by the adding of two CSS properties:

-
    -
  1. background-gradient: (#Color) - Second color of the gradient background, - the first one is given by background-color. Not inherited.
  2. -
  3. background-gradient-angle: (number) - Angle (in degrees, clockwise) of - the gradient. Not inherited. Initial value:90
  4. -
- Some examples - - - - - - - - - - - - - - - - -
- - - - -
- 0 degrees - - 45 degrees - - 90 degrees - - 135 degrees - - 180 degrees -
-

- Rounded corners

-

- As you may already know, CSS is based on a - Box Model, where every box has it's own set of properties. Since we are - talking abound boxes, why not to make them with rounded corners, almost every - website you visit nowadays makes use of rounded corners, where a not very nice trick - with images and tables must be used.

-

- In this renderer, the rounded corners are achieved by adding this CSS properties:

-
    -
  • corner-ne-radius: (length) Indicates the radius of the north-east corner. - Not ineritted
  • -
  • corner-se-radius: (length) Indicates the radius of the south-east corner. - Not ineritted
  • -
  • corner-sw-radius: (length) Indicates the radius of the south-west corner. - Not ineritted
  • -
  • corner-nw-radius: (length) Indicates the radius of the north-west corner. - Not ineritted
  • -
  • corner-radius: (length){1,4} Shorthand for the other corner properties. - Not ineritted
  • -
- - Some examples - - - - - - - - - -
-

-

-

-

-
- c1 - - c2 - - c3 - - c4 - - c5 -
-
.c1, .c2, .c3, .c4, .c5 { background-color:olive; border:0px; color:white; vertical-align:middle; }
-.c1  { corner-radius: 0px }
-.c2  { corner-radius: 10px }
-.c3  { corner-radius: 0px 10px 10px 0px }
-.c4  { corner-radius: 18px }
-.c5  { corner-radius: 10px; border: outset #bb0 2px; }
-
- - \ No newline at end of file + + +

+ Additional features +

+
+

+ There are some additional features that you may already discovered about the renderer + core engine. +

+

+ Graphic features +

+

+ I have always wanted the W3C to add this features to the CSS spec (and so far, not + there yet :) +

+
    +
  • Gradients on backgrounds
  • +
  • Rounded corners
  • +
+

+ And I think many many web designers would agree. Is it so hard or what?. +

+

+ Background Gradients +

+

+ It is a simple two color linear gradient, achieved by the adding of two CSS properties: +

+
    +
  1. + background-image: linear-gradient(angle, color1, color2) - Creates a gradient background + with the specified colors and angle. Not inherited. +
  2. +
  3. + angle - Angle (in degrees, clockwise) of + the gradient. Not inherited. Example: 90deg +
  4. +
+ Some examples + + + + + + + + + + + + + + + + +
+ + + + +
+ 0 degrees + + 45 degrees + + 90 degrees + + 135 degrees + + 180 degrees +
+

+ Rounded corners +

+

+ As you may already know, CSS is based on a + Box Model + , where every box has it's own set of properties. Since we are + talking abound boxes, why not to make them with rounded corners, almost every + website you visit nowadays makes use of rounded corners, where a not very nice trick + with images and tables must be used. +

+

+ In this renderer, the rounded corners are achieved by adding this CSS properties: +

+
    +
  • + border-top-right-radius: (length) Indicates the radius of the top-right corner. + Not inherited +
  • +
  • + border-bottom-right-radius: (length) Indicates the radius of the bottom-right corner. + Not inherited +
  • +
  • + border-bottom-left-radius: (length) Indicates the radius of the bottom-left corner. + Not inherited +
  • +
  • + border-top-left-radius: (length) Indicates the radius of the top-left corner. + Not inherited +
  • +
  • + border-radius: (length){1,4} Shorthand for the other corner properties. + Not inherited +
  • +
+ + Some examples + + + + + + + + + +
+

+

+

+

+
+ c1 + + c2 + + c3 + + c4 + + c5 +
+
.c1, .c2, .c3, .c4, .c5 { background-color:olive; border:0px; color:white; vertical-align:middle; }
+.c1  { border-radius: 0px }
+.c2  { border-radius: 10px }
+.c3  { border-radius: 0px 10px 10px 0px }
+.c4  { border-radius: 18px }
+.c5  { border-radius: 10px; border: outset #bb0 2px; }
+
+ + diff --git a/Source/Demo/Common/TestSamples/12.Text.htm b/Source/Demo/Common/TestSamples/12.Text.htm index c53a43609..df663ec34 100644 --- a/Source/Demo/Common/TestSamples/12.Text.htm +++ b/Source/Demo/Common/TestSamples/12.Text.htm @@ -54,7 +54,7 @@

Transparent text

elementum dolor ac mauris. Ut tristique. In varius volutpat metus. Integer leo dolor, tristique a, dignissim ac, iaculis eget, elit. Donec arcu.

-

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ornare mollis elit. Integer_sagittis_Fusce_elementum_commodo_felis_Vivamus_lacinia_eleifend_libero_Donec lacus. diff --git a/Source/Demo/Common/TestSamples/13.Tables.htm b/Source/Demo/Common/TestSamples/13.Tables.htm index 70d454067..00951dac8 100644 --- a/Source/Demo/Common/TestSamples/13.Tables.htm +++ b/Source/Demo/Common/TestSamples/13.Tables.htm @@ -1,209 +1,243 @@ - - - - - -
- + .table1 td { + border-width: 1px; + border-style: solid; + border-color: blue; + } + + + +
+
+ + + + + + + +
+ Cell One Cell One Cell this text is not visible +
+ Cell Three + + Cell Four +
+
+ + + + +
+ + + + + +
Left Inner Cell OneRight Inner Cell Two
+
+
+ + + + + +
+ Fixed width column + + column without a width so should take all the space but be close to the left column +
+
+ + - - - - - -
Cell One Cell One Cell this text is not visible -
Cell Three + + A: Cell Four + + 1
-
- - -
- - - - - -
Left Inner Cell OneRight Inner Cell Two
-
-
- - - - -
Fixed width column + B: column without a width so should take all the space but be close to the left column + + 2
-
- - - - - - - - - - - - - - - -
- A: - 1 -
- B: - 2 -
- C: - 3 -
-
- - - - -
- - - -
- Nuance -
- df
+ C:
sdfsdf - sdfsd + + 3
-
- - - - - - - - -
a - LongStringLongStringLongStringLongStringLongStringLongStringLongString - text -
-
- - - - - - - - - - - - - -
Title -
Word 1 - Word 2 - Word 3 -
-
- + +
+
+ + + + +
+ + + + + + +
+ + Nuance +
+ df +
+
+ sdfsdf + + sdfsd +
+
+ + - - - -
Word1Word1 Word1Word1Word1 + + a Word 2 + + LongStringLongStringLongStringLongStringLongStringLongStringLongString Word3Word3Word3Word3 Word3Word3Word3Word3Word3Word3Word3Word3Word3 + + text
-
- + +
+
+ + - - - + -
Word1 Word1Word1 - Word 2 - Word3Word3Word3 Word3 - + Title +
-
- + + - - - - - -
Container + + Word 1
Type + + Word 2 $Type + + Word 3
-
- - - - - -
this is a long message this is a long message this is a long messagethis is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message
-
- - - - - - - - - -
-
- - - - - - - - - -
-
- - \ No newline at end of file + + +
+ + + + + + +
+ Word1Word1 Word1Word1Word1 + + Word 2 + + Word3Word3Word3Word3 Word3Word3Word3Word3Word3Word3Word3Word3Word3 +
+
+ + + + + + +
+ Word1 Word1Word1 + + Word 2 + + Word3Word3Word3 Word3 +
+
+ + + + + + + + +
+ Container +
+ Type + + $Type +
+
+ + + + + +
this is a long message this is a long message this is a long messagethis is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message this is a long message
+
+ + + + + + + + + +
+
+ + + + + + + + + +
+
+ + diff --git a/Source/Demo/Common/TestSamples/16.Borders.htm b/Source/Demo/Common/TestSamples/16.Borders.htm index 6fae0757c..27f160928 100644 --- a/Source/Demo/Common/TestSamples/16.Borders.htm +++ b/Source/Demo/Common/TestSamples/16.Borders.htm @@ -1,46 +1,52 @@ - - -
-

-

- simple border 1px -
-

-

-

- simple border 3px -
-

-

-

- border 1px with corner-radius 5px -
-

-

-

- border 2px with corner-radius 10px -
-

-

-

- dotted border 1px -
-

-

-

- dotted border 3px -
-

-

-

- dashed border 1px -
-

-

-

- dashed border 2px with corner-radius 10px -
-

-
- - \ No newline at end of file + + + + + + Borders Demo + + +
+

+

+ simple border 1px +
+

+

+

+ simple border 3px +
+

+

+

+ border 1px with border-radius 5px +
+

+

+

+ border 2px with border-radius 10px +
+

+

+

+ dotted border 1px +
+

+

+

+ dotted border 3px +
+

+

+

+ dashed border 1px +
+

+

+

+ dashed border 2px with border-radius 10px +
+

+
+ + 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..12d66b297 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 @@ -63,17 +63,84 @@ html.ico - - ..\..\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.dll - True + + ..\..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll - - ..\..\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.Charting.dll - True + + ..\..\packages\Microsoft.Extensions.DependencyInjection.8.0.1\lib\net462\Microsoft.Extensions.DependencyInjection.dll + + + ..\..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\..\packages\Microsoft.Extensions.Logging.8.0.1\lib\net462\Microsoft.Extensions.Logging.dll + + + ..\..\packages\Microsoft.Extensions.Logging.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\..\packages\Microsoft.Extensions.Options.8.0.2\lib\net462\Microsoft.Extensions.Options.dll + + + ..\..\packages\Microsoft.Extensions.Primitives.8.0.0\lib\net462\Microsoft.Extensions.Primitives.dll + + + ..\..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.dll + + + ..\..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.BarCodes.dll + + + ..\..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.Charting.dll + + + ..\..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.Cryptography.dll + + + ..\..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.Quality.dll + + + ..\..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.Shared.dll + + + ..\..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.Snippets.dll + + + ..\..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.System.dll + + + ..\..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.WPFonts.dll + + ..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + ..\..\packages\System.Diagnostics.DiagnosticSource.8.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll + + + ..\..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + + ..\..\packages\System.Security.Cryptography.Pkcs.8.0.1\lib\net462\System.Security.Cryptography.Pkcs.dll + + + ..\..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + ..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + @@ -171,6 +238,7 @@ + diff --git a/Source/Demo/WinForms/HtmlRenderingHelper.cs b/Source/Demo/WinForms/HtmlRenderingHelper.cs index 8ca593314..ed8c3ad1f 100644 --- a/Source/Demo/WinForms/HtmlRenderingHelper.cs +++ b/Source/Demo/WinForms/HtmlRenderingHelper.cs @@ -14,6 +14,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Drawing.Imaging; using System.IO; using System.Threading; using TheArtOfDev.HtmlRenderer.Core.Entities; @@ -30,8 +31,12 @@ internal static class HtmlRenderingHelper ///
private static readonly Dictionary _imageCache = new Dictionary(StringComparer.OrdinalIgnoreCase); - #endregion + /// + /// Cache for PDF resource images + /// + private static readonly Dictionary _pdfImageCache = new Dictionary(StringComparer.OrdinalIgnoreCase); + #endregion /// /// Check if currently running in mono. @@ -61,37 +66,69 @@ public static Bitmap CreateImageForTransparentBackground() /// public static Image TryLoadResourceImage(string src) { + if (string.IsNullOrEmpty(src)) + return null; + Image image; if (!_imageCache.TryGetValue(src, out image)) { - var imageStream = DemoUtils.GetImageStream(src); - if (imageStream != null) + try { - image = Image.FromStream(imageStream); - _imageCache[src] = image; + var imageStream = DemoUtils.GetImageStream(src); + if (imageStream != null) + { + image = Image.FromStream(imageStream); + _imageCache[src] = image; + } + } + catch (Exception ex) + { + Console.WriteLine($"Failed to load image '{src}': {ex.Message}"); + return null; } } return image; } /// - /// Get image by resource key. + /// Get XImage by resource key safely for PDF generation. /// public static XImage TryLoadResourceXImage(string src) { - var img = TryLoadResourceImage(src); - XImage xImg; - - if (img == null) + if (string.IsNullOrEmpty(src)) return null; - using (var ms = new MemoryStream()) + // Check if we already have this image cached + if (_pdfImageCache.TryGetValue(src, out var cachedXImg)) + return cachedXImg; + + try { - img.Save(ms, img.RawFormat); - xImg = img != null ? XImage.FromStream(ms) : null; - } + var img = TryLoadResourceImage(src); + if (img == null) + return null; + + XImage xImg = null; + + // Convert to PNG format first to ensure compatibility with PdfSharp + using (var tempBmp = new Bitmap(img)) + using (var ms = new MemoryStream()) + { + tempBmp.Save(ms, ImageFormat.Png); + ms.Position = 0; + xImg = XImage.FromStream(ms); + + // Cache the successfully loaded XImage + _pdfImageCache[src] = xImg; + } - return xImg; + return xImg; + } + catch (Exception ex) + { + Console.WriteLine($"Failed to convert image '{src}' to XImage: {ex.Message}"); + return null; + } } /// @@ -115,56 +152,104 @@ public static void OnImageLoadPdfSharp(object sender, HtmlImageLoadEventArgs e) /// public static void ImageLoad(HtmlImageLoadEventArgs e, bool pdfSharp) { - var img = TryLoadResourceImage(e.Src); - XImage xImg = null; + object imgObj = null; - if (img != null) + try { - using (var ms = new MemoryStream()) + // Handle special case attributes + if (!e.Handled && e.Attributes != null) { - img.Save(ms, img.RawFormat); - xImg = img != null ? XImage.FromStream(ms) : null; - } - } - - object imgObj; - if (pdfSharp) - imgObj = xImg; - else - imgObj = img; - - if (!e.Handled && e.Attributes != null) - { - if (e.Attributes.ContainsKey("byevent")) - { - int delay; - if (Int32.TryParse(e.Attributes["byevent"], out delay)) + if (e.Attributes.ContainsKey("byevent")) { - e.Handled = true; - ThreadPool.QueueUserWorkItem(state => + if (Int32.TryParse(e.Attributes["byevent"], out int delay)) { - Thread.Sleep(delay); - e.Callback("https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-snc7/c0.44.403.403/p403x403/318890_10151195988833836_1081776452_n.jpg"); - }); - return; + e.Handled = true; + ThreadPool.QueueUserWorkItem(state => + { + Thread.Sleep(delay); + try + { + e.Callback("https://fbcdn-sphotos-a-a.akamaihd.net/hphotos-ak-snc7/c0.44.403.403/p403x403/318890_10151195988833836_1081776452_n.jpg"); + } + catch { /* Ignore callback errors */ } + }); + return; + } + else + { + e.Callback("http://sphotos-a.xx.fbcdn.net/hphotos-ash4/c22.0.403.403/p403x403/263440_10152243591765596_773620816_n.jpg"); + return; + } } - else + else if (e.Attributes.ContainsKey("byrect")) { - e.Callback("http://sphotos-a.xx.fbcdn.net/hphotos-ash4/c22.0.403.403/p403x403/263440_10152243591765596_773620816_n.jpg"); - return; + try + { + var split = e.Attributes["byrect"].Split(','); + var rect = new Rectangle(Int32.Parse(split[0]), Int32.Parse(split[1]), Int32.Parse(split[2]), Int32.Parse(split[3])); + + imgObj = null; + if (pdfSharp) + { + imgObj = TryLoadResourceXImage(src: "htmlicon"); + } + else + { + imgObj = TryLoadResourceImage(src: "htmlicon"); + } + + e.Callback(imgObj, rect.X, rect.Y, rect.Width, rect.Height); + return; + } + catch (Exception ex) + { + Console.WriteLine($"Error processing 'byrect' attribute: {ex.Message}"); + // Continue with normal processing if rect parsing fails + } } } - else if (e.Attributes.ContainsKey("byrect")) + + // Standard image loading + imgObj = null; + + if (pdfSharp) { - var split = e.Attributes["byrect"].Split(','); - var rect = new Rectangle(Int32.Parse(split[0]), Int32.Parse(split[1]), Int32.Parse(split[2]), Int32.Parse(split[3])); - e.Callback(imgObj ?? TryLoadResourceImage("htmlicon"), rect.X, rect.Y, rect.Width, rect.Height); - return; + imgObj = TryLoadResourceXImage(e.Src); + } + else + { + imgObj = TryLoadResourceImage(e.Src); } - } - if (img != null) - e.Callback(imgObj); + if (imgObj != null) + { + e.Callback(imgObj); + } + else + { + // If we couldn't load the image, use a default or error image + if (pdfSharp) + { + // Create a simple 1x1 pixel image for PDFs when original can't be loaded + using (var blankBmp = new Bitmap(1, 1)) + using (var g = Graphics.FromImage(blankBmp)) + { + g.Clear(Color.Transparent); + using (var ms = new MemoryStream()) + { + blankBmp.Save(ms, ImageFormat.Png); + ms.Position = 0; + e.Callback(XImage.FromStream(ms)); + } + } + } + } + } + catch (Exception ex) + { + Console.WriteLine($"Error loading image {e.Src}: {ex.Message}"); + // Don't rethrow - better to have a missing image than a broken renderer + } } } -} \ No newline at end of file +} diff --git a/Source/Demo/WinForms/Program.cs b/Source/Demo/WinForms/Program.cs index f01eb6d0a..da3022578 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,6 +28,9 @@ internal static class Program private static void Main() { AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly; + GlobalFontSettings.UseWindowsFontsUnderWindows = true; + // Assign the resolver at application startup (before any PDF generation) + GlobalFontSettings.FontResolver = new SystemFontResolver(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); diff --git a/Source/Demo/WinForms/app.config b/Source/Demo/WinForms/app.config new file mode 100644 index 000000000..39d056b45 --- /dev/null +++ b/Source/Demo/WinForms/app.config @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/Demo/WinForms/packages.config b/Source/Demo/WinForms/packages.config index 2f092fd78..86aeb02ca 100644 --- a/Source/Demo/WinForms/packages.config +++ b/Source/Demo/WinForms/packages.config @@ -1,4 +1,19 @@  - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/HtmlRenderer.PdfSharp/Adapters/PdfSharpAdapter.cs b/Source/HtmlRenderer.PdfSharp/Adapters/PdfSharpAdapter.cs index e5fa309c0..84d35340c 100644 --- a/Source/HtmlRenderer.PdfSharp/Adapters/PdfSharpAdapter.cs +++ b/Source/HtmlRenderer.PdfSharp/Adapters/PdfSharpAdapter.cs @@ -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/Adapters/SystemFontResolver.cs b/Source/HtmlRenderer.PdfSharp/Adapters/SystemFontResolver.cs new file mode 100644 index 000000000..0c94cf69b --- /dev/null +++ b/Source/HtmlRenderer.PdfSharp/Adapters/SystemFontResolver.cs @@ -0,0 +1,72 @@ +using PdfSharp.Fonts; +using System; +using System.Drawing.Text; +using System.Drawing; +using System.IO; +using System.Linq; +using Microsoft.Win32; + +public class SystemFontResolver : IFontResolver +{ + // Map font face names to font file paths + private string FindFontFile(string familyName, bool isBold, bool isItalic) + { + // Search Windows Fonts folder for the font file + string fontsPath = Environment.GetFolderPath(Environment.SpecialFolder.Fonts); + using (InstalledFontCollection fonts = new InstalledFontCollection()) + { + var fontFamily = fonts.Families.FirstOrDefault(f => f.Name.Equals(familyName, StringComparison.OrdinalIgnoreCase)); + if (fontFamily != null) + { + // Try to find the font file in the registry + string fontRegKey = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts"; + using (RegistryKey key = Registry.LocalMachine.OpenSubKey(fontRegKey)) + { + if (key != null) + { + foreach (var fontValue in key.GetValueNames()) + { + if (fontValue.StartsWith(familyName, StringComparison.OrdinalIgnoreCase)) + { + string fontFile = key.GetValue(fontValue) as string; + if (!string.IsNullOrEmpty(fontFile)) + { + string fullPath = Path.Combine(fontsPath, fontFile); + if (File.Exists(fullPath)) + return fullPath; + } + } + } + } + } + } + } + return null; + } + + public byte[] GetFont(string faceName) + { + // faceName is the unique name you return from ResolveTypeface + // For simplicity, use the faceName as the font family name + string fontFile = FindFontFile(faceName, false, false); + if (fontFile != null) + return File.ReadAllBytes(fontFile); + + // Fallback: return null if not found + return null; + } + + public FontResolverInfo ResolveTypeface(string familyName, bool isBold, bool isItalic) + { + // Try to find the font file for the requested style + string fontFile = FindFontFile(familyName, isBold, isItalic); + if (fontFile != null) + { + // Use the family name as the face name + return new FontResolverInfo(familyName); + } + + // Fallback to Arial if not found + return PlatformFontResolver.ResolveTypeface("Arial", isBold, isItalic); + } +} diff --git a/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj b/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj index ef0fd7acc..2b5702ad0 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,19 +32,87 @@ TRACE prompt 4 + false - - ..\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.dll - True + + ..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll - - ..\packages\PDFsharp.1.50.4000-beta3b\lib\net20\PdfSharp.Charting.dll - True + + ..\packages\Microsoft.Extensions.DependencyInjection.8.0.1\lib\net462\Microsoft.Extensions.DependencyInjection.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Logging.8.0.1\lib\net462\Microsoft.Extensions.Logging.dll + + + ..\packages\Microsoft.Extensions.Logging.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll + + + ..\packages\Microsoft.Extensions.Options.8.0.2\lib\net462\Microsoft.Extensions.Options.dll + + + ..\packages\Microsoft.Extensions.Primitives.8.0.0\lib\net462\Microsoft.Extensions.Primitives.dll + + + ..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.dll + + + ..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.BarCodes.dll + + + ..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.Charting.dll + + + ..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.Cryptography.dll + + + ..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.Quality.dll + + + ..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.Shared.dll + + + ..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.Snippets.dll + + + ..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.System.dll + + + ..\packages\PDFsharp.6.2.0\lib\netstandard2.0\PdfSharp.WPFonts.dll + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + ..\packages\System.Diagnostics.DiagnosticSource.8.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll + + + ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + + ..\packages\System.Security.Cryptography.Pkcs.8.0.1\lib\net462\System.Security.Cryptography.Pkcs.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + @@ -56,6 +126,7 @@ + @@ -70,6 +141,7 @@ + diff --git a/Source/HtmlRenderer.PdfSharp/Package.nuspec b/Source/HtmlRenderer.PdfSharp/Package.nuspec new file mode 100644 index 000000000..5292d9e7d --- /dev/null +++ b/Source/HtmlRenderer.PdfSharp/Package.nuspec @@ -0,0 +1,21 @@ + + + + Package + 6.2.0 + dem-v + false + MIT + + https://github.com/dem-v/HTML-Renderer/ + Package description + Summary of changes made in this release of the package. + $copyright$ + Tag1 Tag2 + + + + + + + \ No newline at end of file diff --git a/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs b/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs index 365be2d95..8373a4674 100644 --- a/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs +++ b/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs @@ -10,10 +10,13 @@ // - Sun Tsu, // "The Art of War" -using PdfSharp; -using PdfSharp.Drawing; +// Update namespace imports if needed using PdfSharp.Pdf; +using PdfSharp.Drawing; +using PdfSharp.Pdf.IO; // Add if needed for PDF IO operations +using PdfSharp.Fonts; // Add if needed for font handling using System; +using PdfSharp; using TheArtOfDev.HtmlRenderer.Core; using TheArtOfDev.HtmlRenderer.Core.Entities; using TheArtOfDev.HtmlRenderer.Core.Utils; @@ -70,6 +73,10 @@ public static CssData ParseStyleSheet(string stylesheet, bool combineWithDefault /// the generated image of the html public static PdfDocument GeneratePdf(string html, PageSize pageSize, int margin = 20, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { + + // Assign the resolver at application startup (before any PDF generation) + GlobalFontSettings.FontResolver = new SystemFontResolver(); + var config = new PdfGenerateConfig(); config.PageSize = pageSize; config.SetMargins(margin); @@ -87,6 +94,9 @@ public static PdfDocument GeneratePdf(string html, PageSize pageSize, int margin /// the generated image of the html public static PdfDocument GeneratePdf(string html, PdfGenerateConfig config, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { + // Assign the resolver at application startup (before any PDF generation) + GlobalFontSettings.FontResolver = new SystemFontResolver(); + // create PDF document to render the HTML into var document = new PdfDocument(); diff --git a/Source/HtmlRenderer.PdfSharp/app.config b/Source/HtmlRenderer.PdfSharp/app.config new file mode 100644 index 000000000..eeef23580 --- /dev/null +++ b/Source/HtmlRenderer.PdfSharp/app.config @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/HtmlRenderer.PdfSharp/packages.config b/Source/HtmlRenderer.PdfSharp/packages.config index 2f092fd78..86aeb02ca 100644 --- a/Source/HtmlRenderer.PdfSharp/packages.config +++ b/Source/HtmlRenderer.PdfSharp/packages.config @@ -1,4 +1,19 @@  - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj b/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj index 80c4b97f9..032cfa591 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,15 +33,16 @@ 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 diff --git a/Source/SharedAssemblyInfo.cs b/Source/SharedAssemblyInfo.cs index d5336037f..83858029e 100644 --- a/Source/SharedAssemblyInfo.cs +++ b/Source/SharedAssemblyInfo.cs @@ -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("6.2.0.0")] \ No newline at end of file