From f4c0f7024ebf52b43c8eec8b818ad7eff0bbcf56 Mon Sep 17 00:00:00 2001 From: mikkelxn Date: Mon, 29 Dec 2014 14:16:10 +0100 Subject: [PATCH 01/54] Make GetColorInt check if color name is valid to avoid ColorConverter throwing an exception --- .../HtmlRenderer.WPF/Adapters/WpfAdapter.cs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Source/HtmlRenderer.WPF/Adapters/WpfAdapter.cs b/Source/HtmlRenderer.WPF/Adapters/WpfAdapter.cs index 681a0748f..13f5eed55 100644 --- a/Source/HtmlRenderer.WPF/Adapters/WpfAdapter.cs +++ b/Source/HtmlRenderer.WPF/Adapters/WpfAdapter.cs @@ -11,7 +11,9 @@ // "The Art of War" using System; +using System.Collections.Generic; using System.IO; +using System.Reflection; using System.Windows; using System.Windows.Media; using System.Windows.Media.Imaging; @@ -34,8 +36,22 @@ internal sealed class WpfAdapter : RAdapter /// private static readonly WpfAdapter _instance = new WpfAdapter(); + /// + /// List of valid predefined color names in lower-case + /// + private static readonly List ValidColorNamesLc; + #endregion + static WpfAdapter() + { + ValidColorNamesLc = new List(); + var colorList = new List(typeof(Colors).GetProperties()); + foreach (var colorProp in colorList) + { + ValidColorNamesLc.Add(colorProp.Name.ToLower()); + } + } /// /// Init installed font families and set default font families mapping. @@ -61,6 +77,10 @@ public static WpfAdapter Instance protected override RColor GetColorInt(string colorName) { + // check if color name is valid to avoid ColorConverter throwing an exception + if (!ValidColorNamesLc.Contains(colorName.ToLower())) + return RColor.Empty; + var convertFromString = ColorConverter.ConvertFromString(colorName) ?? Colors.Black; return Utils.Convert((Color)convertFromString); } From 91ebb92130f77fdd0405741b886028992c56f0a4 Mon Sep 17 00:00:00 2001 From: mikkelxn Date: Tue, 30 Dec 2014 09:33:03 +0100 Subject: [PATCH 02/54] Fixed typo --- Source/Demo/Common/Resources/Tooltip.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Demo/Common/Resources/Tooltip.html b/Source/Demo/Common/Resources/Tooltip.html index 25f3464c2..85892877a 100644 --- a/Source/Demo/Common/Resources/Tooltip.html +++ b/Source/Demo/Common/Resources/Tooltip.html @@ -1,4 +1,4 @@ -HtmlPnael control showing HTML Renderer capabilities +HtmlPanel control showing HTML Renderer capabilities @@ -62,8 +62,8 @@

- opmqjeqf mj - pdkfd ddooekeh pc denopnjgcirn pe oqemmcg fla lnmaba 2.1 - + opmqjeqf mj + pdkfd ddooekeh pc denopnjgcirn pe oqemmcg fla lnmaba 2.1 - khon gac ioof phpdigja


@@ -71,9 +71,9 @@

iigm nnk frmjfl + href='https://www.google.com'>iigm nnk frmjfl ejk + data-containertype="-2" data-objectid="2471" data-objecttype="700" href='https://www.google.com'> lppf rnp rnpjihp

&ppbg;

@@ -140,7 +140,7 @@

@@ -176,7 +176,7 @@

- jcrrnagrqq + jcrrnagrqq

@@ -200,12 +200,12 @@

&ofik;

nkm: + data-objectid="3512" data-objecttype="3" href='https://www.google.com'> ogqkq lblhhk, amcdon? pm rel bll irdffld dgfgl gdine lc &opoc;ljmmblicf&eqil; qgc ng pfooch ldda aq poloknkqbj... qcagh no pqj hhaigo hf aqi hchhco pfkjoef...

@@ -225,7 +225,7 @@

@@ -247,7 +247,7 @@

- lmmacdienr + lmmacdienr

@@ -269,7 +269,7 @@

- ndlrhbegpd + ndlrhbegpd

@@ -291,7 +291,7 @@

@@ -387,7 +387,7 @@

- jffdkrloia + jffdkrloia

@@ -417,7 +417,7 @@

- ocdnikrcij + ocdnikrcij

@@ -438,7 +438,7 @@

@@ -472,7 +472,7 @@

- ngjpkefafq + ngjpkefafq

@@ -495,7 +495,7 @@

- cmjekieppq + cmjekieppq

@@ -517,7 +517,7 @@

@@ -540,7 +540,7 @@

giedc heaarh'e + href='https://www.google.com'>giedc heaarh'e dqcpcipck icdbp pk nbbk riel)

&jbhp;

@@ -573,7 +573,7 @@

fekjk rrekjm'e + href='https://www.google.com'>fekjk rrekjm'e dcolmagp abgep gb alhk rddm)

&gnpe;

hfapi: ppo kbl'd pefl dqgmdqrkdq nb rhhppnr ka {dpgrj irae}. @@ -602,7 +602,7 @@

aqckk idkjob'o + href='https://www.google.com'>aqckk idkjob'o pmqapakp migeq pcrg)

&mpib;

@@ -631,7 +631,7 @@

@@ -655,7 +655,7 @@

eefgj rhnmcr

+ href='https://www.google.com'>eefgj rhnmcr

&crmk;

@@ -671,7 +671,7 @@

ijqnna • rrgbk + mn lfrlhoc.ijqnna • rrgbk ko 2.7.2013 nn 3.57.34 nq.fpf

&ignd;

@@ -702,7 +702,7 @@

dgobg hrhlrm

+ href='https://www.google.com'>dgobg hrhlrm

&rhfd;

@@ -733,7 +733,7 @@

qpefa nflrrd

+ href='https://www.google.com'>qpefa nflrrd

&ikkb;

cpage: mornan. @@ -785,10 +785,10 @@

- obm: r´c&pjfi; pfe &lgrl;hcag enkdefl jkfalcch in iqfardi&mccr; lc clrdqbj &jmpe;amcolbiq + obm: r´c&pjfi; pfe &lgrl;hcag enkdefl jkfalcch in iqfardi&mccr; lc clrdqbj &jmpe;amcolbiq jp rdngfkc&jccl; (pidh &mrdg;qeoba&aeal; ablac eche). plj hrjmkcd rhrcfkkl ccmfa jjjbikmea... + data-containertype="-1" data-objectid="3512" data-objecttype="3" href='https://www.google.com'> rhbjp jeegip

&abdb;

@@ -826,7 +826,7 @@

cronf dhgobi

+ href='https://www.google.com'>cronf dhgobi

&mggq;

@@ -1066,7 +1066,7 @@

- foigbphcoa + foigbphcoa

@@ -1087,7 +1087,7 @@

@@ -1132,7 +1132,7 @@

- grilrdagid + grilrdagid

@@ -1154,7 +1154,7 @@

- grcohqpnor + grcohqpnor

@@ -1175,7 +1175,7 @@

@@ -1196,7 +1196,7 @@

@@ -1218,7 +1218,7 @@

- dlkgodbdcb + dlkgodbdcb

@@ -1284,7 +1284,7 @@

- erkmioomnd + erkmioomnd

@@ -1306,7 +1306,7 @@

- ljqbcalnff + ljqbcalnff

@@ -1336,7 +1336,7 @@

- hahdjkmlda + hahdjkmlda

@@ -1357,7 +1357,7 @@

gdl: hlioq fjcflcph, + href='https://www.google.com'>hlioq fjcflcph, f ahlbk ro cadqohcid qq agdal mfimik pnrk kja kf od pfkeq cq h lcnepa croq nb efkciqd:

  • 2 okilkcojphgo: djfpicickhje ljmqjni @@ -1376,7 +1376,7 @@

    farohbqrgo + href='https://www.google.com'>farohbqrgo

@@ -1399,7 +1399,7 @@

poihpkqmjj + href='https://www.google.com'>poihpkqmjj

@@ -1420,7 +1420,7 @@

@@ -1440,7 +1440,7 @@

@@ -1460,7 +1460,7 @@

@@ -1484,7 +1484,7 @@

- dfbggcmpci + dfbggcmpci

@@ -1505,7 +1505,7 @@

@@ -1526,7 +1526,7 @@

@@ -1547,7 +1547,7 @@

@@ -1568,7 +1568,7 @@

@@ -1589,7 +1589,7 @@

@@ -1610,7 +1610,7 @@

@@ -1631,7 +1631,7 @@

@@ -1652,7 +1652,7 @@

- bokbkcafha + bokbkcafha

@@ -1828,7 +1828,7 @@

+ data-objectid="3512" data-objecttype="3" href='https://www.google.com'> abnaf ajllna

@@ -1899,7 +1899,7 @@

nrg: {0} pkmcf'j bnpo apjcnfcbfg ip akmr dmgicpk jj ind faleekdg ccaeo (bhkqr jbhfgh) + href='https://www.google.com'>bhkqr jbhfgh)

@@ -1944,7 +1944,7 @@

@@ -1965,7 +1965,7 @@

@@ -1987,7 +1987,7 @@

- gjcaoddide + gjcaoddide

@@ -2029,7 +2029,7 @@

@@ -2050,7 +2050,7 @@

@@ -2071,7 +2071,7 @@

@@ -2093,7 +2093,7 @@

+ data-objectid="3512" data-objecttype="3" href='https://www.google.com'> qfplf drmjhc, eei olh ldfjb qq n hmaomb eijbocg (nkn apieq)

&kdgl;

@@ -2101,7 +2101,7 @@

- kpgbarfmmq + kpgbarfmmq

@@ -2122,7 +2122,7 @@

@@ -2143,7 +2143,7 @@

@@ -2165,7 +2165,7 @@

@@ -2207,7 +2207,7 @@

@@ -2228,7 +2228,7 @@

@@ -2249,7 +2249,7 @@

nal: &jldk;mdnmq qhk ig gpmmmhe nkqh ree gech rfobr. eqmm le bcbaob&hfda; (khobe dmqjgm), + href='https://www.google.com'>khobe dmqjgm), orkc, jep'h nrn liio fridrq r ggq aan? beode jfci peok qhapof lipm ighnok deiec fi dkgrclo bdghajgj. @@ -2447,7 +2447,7 @@

+ data-objectid="3512" data-objecttype="3" href='https://www.google.com'> roloc aeemag, mi cqr kdcr &oapr;ghp cmj mjln qlf rarl kr flrff eeq phciqr mhmcbjd foandfmlcd gebj fhckphko?&bjea; mk jfpjaoa pq kc r kendoep? h'h akjd bkinjiclb bpgo &deji;jki qpg bpna ded jnff qd jcgbr? fjdp prakprj rbfe eg pohr&gpkb;. bieaa, @@ -2585,7 +2585,7 @@

- rkiqjcqpgc + rkiqjcqpgc

@@ -2707,13 +2707,13 @@

pjmrkf - • rgmdf rq 2.7.2013 fe 5.09.21 rl.mhe bhr rmqo jhrfbrao im bmda dhijpfi - cdirfk gi kmem ihqm qdrpjn, fjre - epriip • kggei fo 2.7.2013 hm 5.10.26 fq.rpa... mk emk fphqg prab...

+ bmppeohdc lmph pjmrkf + • rgmdf rq 2.7.2013 fe 5.09.21 rl.mhe bhr rmqo jhrfbrao im bmda dhijpfi + cdirfk gi kmem ihqm qdrpjn, fjre + epriip � kggei fo 2.7.2013 hm 5.10.26 fq.rpa... mk emk fphqg prab...

@@ -2758,7 +2758,7 @@

@@ -3054,20 +3054,20 @@

- cganbif ma lrbffrkl or ehlj ehnof, pr jr qf qpr jpdfnnjf gc ddrdrphci

diff --git a/Source/Demo/Common/Resources/Tooltip.html b/Source/Demo/Common/Resources/Tooltip.html index 85892877a..1c00962e2 100644 --- a/Source/Demo/Common/Resources/Tooltip.html +++ b/Source/Demo/Common/Resources/Tooltip.html @@ -14,5 +14,5 @@
This is an HtmlToolTip and it's very COOL!!!
- You can even click on the links! + You can even click on the links!
\ No newline at end of file diff --git a/Source/Demo/Common/Samples/00.Intro.htm b/Source/Demo/Common/Samples/00.Intro.htm index ae8a64361..18c44f869 100644 --- a/Source/Demo/Common/Samples/00.Intro.htm +++ b/Source/Demo/Common/Samples/00.Intro.htm @@ -104,14 +104,11 @@

2012 - Arthur Teplitzki

- http://TheArtOfDev.com + https://TheArtOfDev.com

2009 - Jose Manuel Menendez Poo

-
- www.menendezpoo.com -
\ No newline at end of file diff --git a/Source/Demo/Common/Samples/02.Text.htm b/Source/Demo/Common/Samples/02.Text.htm index 727d1fea4..85e201024 100644 --- a/Source/Demo/Common/Samples/02.Text.htm +++ b/Source/Demo/Common/Samples/02.Text.htm @@ -2,11 +2,11 @@ Text - @@ -80,7 +80,7 @@

Justifed


Breakable lines

- http://www.google.com/sjkdhgfasdfgfg/asdfadfsgaefg/adfgafdgadfg/asdfgaedfgsdfg/dasfgasfdgasdfg/adfgadfgasfdg/adfsgafgafg/afdgaddfgadfg/afsdgafdgaddfg/afsdgafgadqfdgaeddfg + https://www.google.com/sjkdhgfasdfgfg/asdfadfsgaefg/adfgafdgadfg/asdfgaedfgsdfg/dasfgasfdgasdfg/adfgadfgasfdg/adfsgafgafg/afdgaddfgadfg/afsdgafdgaddfg/afsdgafgadqfdgaeddfg

Transparent text

diff --git a/Source/Demo/Common/Samples/04.Links.htm b/Source/Demo/Common/Samples/04.Links.htm index 05c8a5c79..e84a45f1b 100644 --- a/Source/Demo/Common/Samples/04.Links.htm +++ b/Source/Demo/Common/Samples/04.Links.htm @@ -16,7 +16,7 @@

URI href


Check the context menu options on the link as well by right clicking on it.
- This is a URI link to HTML Renderer (href="https://htmlrenderer.codeplex.com/") + This is a URI link to HTML Renderer (href="https://codeplexarchive.org/project/HtmlRenderer")

File path href

diff --git a/Source/Demo/Common/Samples/05.Images.htm b/Source/Demo/Common/Samples/05.Images.htm index 6d41f3e79..9c6c08077 100644 --- a/Source/Demo/Common/Samples/05.Images.htm +++ b/Source/Demo/Common/Samples/05.Images.htm @@ -64,7 +64,7 @@

img tag

Loaded from web: diff --git a/Source/Demo/Common/Samples/06.Embeded video.htm b/Source/Demo/Common/Samples/06.Embeded video.htm index dc64330d9..ea67b2f7f 100644 --- a/Source/Demo/Common/Samples/06.Embeded video.htm +++ b/Source/Demo/Common/Samples/06.Embeded video.htm @@ -27,7 +27,7 @@

Note: Because this technique requires server API it is currently supported - only for YouTube and + only for YouTube and Vimeo.

diff --git a/Source/Demo/Common/Samples/20.About.htm b/Source/Demo/Common/Samples/20.About.htm index 7bb3e76bf..e28d613b7 100644 --- a/Source/Demo/Common/Samples/20.About.htm +++ b/Source/Demo/Common/Samples/20.About.htm @@ -4,39 +4,33 @@ -

- About

+

About

- For updates and fixes go to HTML Renderer on - CodePlex. + For updates and fixes go to HTML Renderer on + GitHub.

For contributing go to ArthurHub/HTML-Renderer on GitHub.

- Please submit bugs and requests to - HTML Renderer Issue Tracker on CodePlex. + Please submit bugs and requests to + HTML Renderer Issue Tracker on GitHub.



-

- 2012 - Arthur Teplitzki

-
- http://TheArtOfDev.com -
-

- 2009 - Jose Manuel Menendez Poo

+

2012 - Arthur Teplitzki

- www.menendezpoo.com + https://TheArtOfDev.com
+

2009 - Jose Manuel Menendez Poo


License

- The code is under the New BSD License (BSD) license. + The code is under the New BSD License (BSD) license.
If you use the code on a commercial application, please give the developers credit for the HTML Renderer code.

@@ -44,7 +38,7 @@



- Thanks for the HTML highlighting code on the demo app to + Thanks for the HTML highlighting code on the demo app to Alun Evans

diff --git a/Source/Demo/Common/TestSamples/02.Line break.htm b/Source/Demo/Common/TestSamples/02.Line break.htm index 3eae36cce..46e3c0a70 100644 --- a/Source/Demo/Common/TestSamples/02.Line break.htm +++ b/Source/Demo/Common/TestSamples/02.Line break.htm @@ -11,11 +11,11 @@


Long line without whitespaces:
- http://www.google.com/sjkdhgfasdfgfg/asdfadfsgaefg/adfgafdgadfg/asdfgaedfgsdfg/dasfgasfdgasdfg/adfgadfgasfdg/adfsgafgafg/afdgaddfgadfg/afsdgafdgaddfg/afsdgafgadqfdgaeddfg the-end + https://www.google.com/sjkdhgfasdfgfg/asdfadfsgaefg/adfgafdgadfg/asdfgaedfgsdfg/dasfgasfdgasdfg/adfgadfgasfdg/adfsgafgafg/afdgaddfgadfg/afsdgafdgaddfg/afsdgafgadqfdgaeddfg the-end

Breakable long line without whitespaces:
- http://www.google.com/sjkdhgfasdfgfg/asdfadfsgaefg/adfgafdgadfg/asdfgaedfgsdfg/dasfgasfdgasdfg/adfgadfgasfdg/adfsgafgafg/afdgaddfgadfg/afsdgafdgaddfg/afsdgafgadqfdgaeddfg the-end + https://www.google.com/sjkdhgfasdfgfg/asdfadfsgaefg/adfgafdgadfg/asdfgaedfgsdfg/dasfgasfdgasdfg/adfgadfgasfdg/adfsgafgafg/afdgaddfgadfg/afsdgafdgaddfg/afsdgafgadqfdgaeddfg the-end


diff --git a/Source/Demo/Common/TestSamples/06.External Image.htm b/Source/Demo/Common/TestSamples/06.External Image.htm index 0492a426c..acd188ff0 100644 --- a/Source/Demo/Common/TestSamples/06.External Image.htm +++ b/Source/Demo/Common/TestSamples/06.External Image.htm @@ -8,12 +8,12 @@

From web:
- +
GIF:
- +
By event: @@ -21,6 +21,6 @@

- + \ No newline at end of file diff --git a/Source/Demo/Common/TestSamples/09.Inline.htm b/Source/Demo/Common/TestSamples/09.Inline.htm index 6a89ba426..bdafb3c87 100644 --- a/Source/Demo/Common/TestSamples/09.Inline.htm +++ b/Source/Demo/Common/TestSamples/09.Inline.htm @@ -1,18 +1,18 @@
- codePlex + gitHub

- code Plex + git Hub

- CodePlex codePlex + GitHub gitHub

- CodePlex codePlex code + GitHub gitHub code
Hello World diff --git a/Source/Demo/Common/TestSamples/10.BlockInInline.htm b/Source/Demo/Common/TestSamples/10.BlockInInline.htm index fda0edb1e..aaa579842 100644 --- a/Source/Demo/Common/TestSamples/10.BlockInInline.htm +++ b/Source/Demo/Common/TestSamples/10.BlockInInline.htm @@ -31,7 +31,7 @@

diff --git a/Source/Demo/Common/TestSamples/15.MaxWidth.htm b/Source/Demo/Common/TestSamples/15.MaxWidth.htm index d8b98e9ba..693f1d947 100644 --- a/Source/Demo/Common/TestSamples/15.MaxWidth.htm +++ b/Source/Demo/Common/TestSamples/15.MaxWidth.htm @@ -14,7 +14,7 @@

Long line without whitespaces:
- http://www.google.com/sjkdhgfasdfgfg/asdfadfsgaefg/adfgafdgadfg/asdfgaedfgsdfg/dasfgasfdgasdfg/adfgadfgasfdg/adfsgafgafg/afdgaddfgadfg/afsdgafdgaddfg/afsdgafgadqfdgaeddfg/afsdgadfgafg + https://www.google.com/sjkdhgfasdfgfg/asdfadfsgaefg/adfgafdgadfg/asdfgaedfgsdfg/dasfgasfdgasdfg/adfgadfgasfdg/adfsgafgafg/afdgaddfgadfg/afsdgafdgaddfg/afsdgafgadqfdgaeddfg/afsdgadfgafg

The text should not exceed max width:
@@ -26,10 +26,10 @@

metus. Integer leo dolor, tristique a, dignissim ac, iaculis eget, elit. Donec arcu.

The image should also be limited by size because it has: style="width:90%"
- - + +

- +

diff --git a/Source/Demo/Common/TestSamples/19.Many images.htm b/Source/Demo/Common/TestSamples/19.Many images.htm index a7cd2582c..c297b08ca 100644 --- a/Source/Demo/Common/TestSamples/19.Many images.htm +++ b/Source/Demo/Common/TestSamples/19.Many images.htm @@ -2,102 +2,102 @@

Contains many images that should not load until in scroll view

Image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- +

Another image

- + \ No newline at end of file diff --git a/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj b/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj index 8c26cdcc4..c462387a6 100644 --- a/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj +++ b/Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj @@ -135,7 +135,7 @@ - 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}. + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see https://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. diff --git a/Source/Demo/WPF/HtmlRenderingHelper.cs b/Source/Demo/WPF/HtmlRenderingHelper.cs index 5250e17fe..2fb88670e 100644 --- a/Source/Demo/WPF/HtmlRenderingHelper.cs +++ b/Source/Demo/WPF/HtmlRenderingHelper.cs @@ -136,13 +136,13 @@ public static void ImageLoad(HtmlImageLoadEventArgs e) ThreadPool.QueueUserWorkItem(state => { 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"); + e.Callback("https://images.unsplash.com/photo-1608848461950-0fe51dfc41cb?w=500&q=80"); }); return; } else { - e.Callback("http://sphotos-a.xx.fbcdn.net/hphotos-ash4/c22.0.403.403/p403x403/263440_10152243591765596_773620816_n.jpg"); + e.Callback("https://images.unsplash.com/photo-1608848461950-0fe51dfc41cb?w=500&q=80"); return; } } diff --git a/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj b/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj index 95dafc2f1..2e089e2db 100644 --- a/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj +++ b/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj @@ -177,7 +177,7 @@ - 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}. + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see https://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. diff --git a/Source/Demo/WinForms/HtmlRenderingHelper.cs b/Source/Demo/WinForms/HtmlRenderingHelper.cs index 8ca593314..6be842af6 100644 --- a/Source/Demo/WinForms/HtmlRenderingHelper.cs +++ b/Source/Demo/WinForms/HtmlRenderingHelper.cs @@ -144,13 +144,13 @@ public static void ImageLoad(HtmlImageLoadEventArgs e, bool pdfSharp) ThreadPool.QueueUserWorkItem(state => { 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"); + e.Callback("https://images.unsplash.com/photo-1608848461950-0fe51dfc41cb?w=500&q=80"); }); return; } else { - e.Callback("http://sphotos-a.xx.fbcdn.net/hphotos-ash4/c22.0.403.403/p403x403/263440_10152243591765596_773620816_n.jpg"); + e.Callback("https://images.unsplash.com/photo-1608848461950-0fe51dfc41cb?w=500&q=80"); return; } } diff --git a/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj b/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj index ef0fd7acc..1c80d52f2 100644 --- a/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj +++ b/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj @@ -76,7 +76,7 @@ - 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}. + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see https://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. diff --git a/Source/HtmlRenderer.WPF/HtmlRender.cs b/Source/HtmlRenderer.WPF/HtmlRender.cs index 77eb4a046..d9e6c65ad 100644 --- a/Source/HtmlRenderer.WPF/HtmlRender.cs +++ b/Source/HtmlRenderer.WPF/HtmlRender.cs @@ -31,7 +31,7 @@ namespace TheArtOfDev.HtmlRenderer.WPF /// /// Rendering to image
/// // TODO:a update! - /// See https://htmlrenderer.codeplex.com/wikipage?title=Image%20generation
+ /// See https://codeplexarchive.org/ProjectTab/Wiki/HtmlRenderer/Documentation/Image%20generation
/// Because of GDI text rendering issue with alpha channel clear type text rendering rendering to image requires special handling.
/// Solid color background - generate an image where the background is filled with solid color and all the html is rendered on top /// of the background color, GDI text rendering will be used. (RenderToImage method where the first argument is html string)
diff --git a/Source/HtmlRenderer.WPF/Utilities/ClipboardHelper.cs b/Source/HtmlRenderer.WPF/Utilities/ClipboardHelper.cs index aac84e249..df4f1b799 100644 --- a/Source/HtmlRenderer.WPF/Utilities/ClipboardHelper.cs +++ b/Source/HtmlRenderer.WPF/Utilities/ClipboardHelper.cs @@ -18,7 +18,7 @@ namespace TheArtOfDev.HtmlRenderer.WPF.Utilities { /// /// Helper to encode and set HTML fragment to clipboard.
- /// See http://theartofdev.com/2012/11/11/setting-html-and-plain-text-formatting-to-clipboard/.
+ /// See https://theartofdev.com/2012/11/11/setting-html-and-plain-text-formatting-to-clipboard/.
/// . ///
/// @@ -91,7 +91,7 @@ internal static class ClipboardHelper /// hello world /// ]]> /// - /// See format specification here: http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/clipboard/htmlclipboard.asp + /// See format specification here: https://msdn.microsoft.com/library/default.asp?url=/workshop/networking/clipboard/htmlclipboard.asp ///
/// /// a html fragment diff --git a/Source/HtmlRenderer.WinForms/HtmlRender.cs b/Source/HtmlRenderer.WinForms/HtmlRender.cs index 3c6ad3ca9..b7e24d81e 100644 --- a/Source/HtmlRenderer.WinForms/HtmlRender.cs +++ b/Source/HtmlRenderer.WinForms/HtmlRender.cs @@ -39,7 +39,7 @@ namespace TheArtOfDev.HtmlRenderer.WinForms /// /// /// Rendering to image
- /// See https://htmlrenderer.codeplex.com/wikipage?title=Image%20generation
+ /// See https://codeplexarchive.org/ProjectTab/Wiki/HtmlRenderer/Documentation/Image%20generation
/// Because of GDI text rendering issue with alpha channel clear type text rendering rendering to image requires special handling.
/// Solid color background - generate an image where the background is filled with solid color and all the html is rendered on top /// of the background color, GDI text rendering will be used. (RenderToImage method where the first argument is html string)
diff --git a/Source/HtmlRenderer.WinForms/MetafileExtensions.cs b/Source/HtmlRenderer.WinForms/MetafileExtensions.cs index 4b13ba607..7bc5fad25 100644 --- a/Source/HtmlRenderer.WinForms/MetafileExtensions.cs +++ b/Source/HtmlRenderer.WinForms/MetafileExtensions.cs @@ -9,7 +9,7 @@ public static class MetafileExtensions { public static void SaveAsEmf(Metafile me, string fileName) { - /* http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/12a1c749-b320-4ce9-aff7-9de0d7fd30ea + /* https://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/12a1c749-b320-4ce9-aff7-9de0d7fd30ea How to save or serialize a Metafile: Solution found by : SWAT Team member _1 Date : Friday, February 01, 2008 1:38 PM diff --git a/Source/HtmlRenderer.WinForms/Utilities/ClipboardHelper.cs b/Source/HtmlRenderer.WinForms/Utilities/ClipboardHelper.cs index dd5d3b7aa..8c34cab02 100644 --- a/Source/HtmlRenderer.WinForms/Utilities/ClipboardHelper.cs +++ b/Source/HtmlRenderer.WinForms/Utilities/ClipboardHelper.cs @@ -18,7 +18,7 @@ namespace TheArtOfDev.HtmlRenderer.WinForms.Utilities { /// /// Helper to encode and set HTML fragment to clipboard.
- /// See http://theartofdev.wordpress.com/2012/11/11/setting-html-and-plain-text-formatting-to-clipboard/.
+ /// See https://theartofdev.wordpress.com/2012/11/11/setting-html-and-plain-text-formatting-to-clipboard/.
/// . ///
/// @@ -91,7 +91,7 @@ internal static class ClipboardHelper /// hello world /// ]]> /// - /// See format specification here: http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/clipboard/htmlclipboard.asp + /// See format specification here: https://msdn.microsoft.com/library/default.asp?url=/workshop/networking/clipboard/htmlclipboard.asp ///
/// /// a html fragment diff --git a/Source/HtmlRenderer/Core/Dom/CssBoxFrame.cs b/Source/HtmlRenderer/Core/Dom/CssBoxFrame.cs index 7bb6ed57f..0b810e5fc 100644 --- a/Source/HtmlRenderer/Core/Dom/CssBoxFrame.cs +++ b/Source/HtmlRenderer/Core/Dom/CssBoxFrame.cs @@ -146,7 +146,7 @@ private void LoadYoutubeDataAsync(Uri uri) { try { - var apiUri = new Uri(string.Format("http://gdata.youtube.com/feeds/api/videos/{0}?v=2&alt=json", uri.Segments[2])); + var apiUri = new Uri(string.Format("https://gdata.youtube.com/feeds/api/videos/{0}?v=2&alt=json", uri.Segments[2])); var client = new WebClient(); client.Encoding = Encoding.UTF8; @@ -282,7 +282,7 @@ private void LoadVimeoDataAsync(Uri uri) { try { - var apiUri = new Uri(string.Format("http://vimeo.com/api/v2/video/{0}.json", uri.Segments[2])); + var apiUri = new Uri(string.Format("https://vimeo.com/api/v2/video/{0}.json", uri.Segments[2])); var client = new WebClient(); client.Encoding = Encoding.UTF8; diff --git a/Source/SharedAssemblyInfo.cs b/Source/SharedAssemblyInfo.cs index d5336037f..6cb556d7e 100644 --- a/Source/SharedAssemblyInfo.cs +++ b/Source/SharedAssemblyInfo.cs @@ -8,7 +8,7 @@ [assembly: AssemblyTitle("HTML Renderer")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Open source hosted on CodePlex")] +[assembly: AssemblyCompany("Open source hosted on GitHub")] [assembly: AssemblyProduct("HTML Renderer")] [assembly: AssemblyCopyright("Copyright © 2008")] [assembly: AssemblyTrademark("")] From c0c2f419ded22b60676de15162a942d815656e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Mon, 8 Dec 2025 10:06:40 +0100 Subject: [PATCH 31/54] Update to .NET Framewok 4.6.2 - Older .NET Framework versions are no longer supported - Update project format to SDK style --- .gitignore | 1 + Build/NuGet/HtmlRenderer.Mono.nuspec | 1 - Build/NuGet/HtmlRenderer.PdfSharp.nuspec | 1 - Build/NuGet/HtmlRenderer.WinForms.nuspec | 1 - README.md | 3 +- .../Common/HtmlRenderer.Demo.Common.csproj | 182 +++++------------- .../Common/Properties/Resources.Designer.cs | 4 +- Source/Demo/Common/Samples/00.Intro.htm | 3 +- Source/Demo/WPF/HtmlRenderer.Demo.WPF.csproj | 128 +----------- .../HtmlRenderer.Demo.WinForms.csproj | 179 +---------------- .../HtmlRenderer.PdfSharp.csproj | 81 +------- Source/HtmlRenderer.PdfSharp/packages.config | 4 - .../HtmlRenderer.WPF/HtmlRenderer.WPF.csproj | 76 +------- .../HtmlRenderer.WinForms.csproj | 111 +---------- Source/HtmlRenderer/HtmlRenderer.csproj | 118 +----------- 15 files changed, 98 insertions(+), 795 deletions(-) delete mode 100644 Source/HtmlRenderer.PdfSharp/packages.config diff --git a/.gitignore b/.gitignore index ce3a150ad..ec0fb2754 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,7 @@ x64/ *.vspscc *.vssscc .builds +.vs/ # Visual C++ cache files ipch/ diff --git a/Build/NuGet/HtmlRenderer.Mono.nuspec b/Build/NuGet/HtmlRenderer.Mono.nuspec index d1c2a67f1..bd12f9fab 100644 --- a/Build/NuGet/HtmlRenderer.Mono.nuspec +++ b/Build/NuGet/HtmlRenderer.Mono.nuspec @@ -27,7 +27,6 @@ * Support separating CSS from HTML by loading stylesheet code separately. * Support text selection, copy-paste and context menu. * Handles "real world" malformed HTML, it doesn't have to be XHTML. - * Supports .NET 2.0 or higher including Client Profile. * Lightweight, only two DLLs (~300K). * High performance and low memory footprint. * Extendable and configurable. diff --git a/Build/NuGet/HtmlRenderer.PdfSharp.nuspec b/Build/NuGet/HtmlRenderer.PdfSharp.nuspec index 71ba7dbb7..70577208a 100644 --- a/Build/NuGet/HtmlRenderer.PdfSharp.nuspec +++ b/Build/NuGet/HtmlRenderer.PdfSharp.nuspec @@ -22,7 +22,6 @@ * Extensive HTML 4.01 and CSS level 2 specifications support. * Support separating CSS from HTML by loading stylesheet code separately. * Handles "real world" malformed HTML, it doesn't have to be XHTML. - * Supports .NET 2.0 or higher including Client Profile. * Lightweight, only two DLLs (~300K). * High performance and low memory footprint. * Extendable and configurable. diff --git a/Build/NuGet/HtmlRenderer.WinForms.nuspec b/Build/NuGet/HtmlRenderer.WinForms.nuspec index c41134ca7..84ee85f01 100644 --- a/Build/NuGet/HtmlRenderer.WinForms.nuspec +++ b/Build/NuGet/HtmlRenderer.WinForms.nuspec @@ -27,7 +27,6 @@ * Support separating CSS from HTML by loading stylesheet code separately. * Support text selection, copy-paste and context menu. * Handles "real world" malformed HTML, it doesn't have to be XHTML. - * Supports .NET 2.0 or higher including Client Profile. * Lightweight, only two DLLs (~300K). * High performance and low memory footprint. * Extendable and configurable. diff --git a/README.md b/README.md index c197e39ed..379d3ee91 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ **Cross framework** (WinForms/WPF/PDF/Metro/Mono/etc.), **Multipurpose** (UI Controls / Image generation / PDF generation / etc.), **100% managed** (C#), High performance HTML Rendering library. -The library is 100% managed **C#** code without any external dependencies (no WebBrowser control, ActiveX / COM or MSHTML dll), the only requirement is **.NET 2.0 or higher**. +The library is 100% managed **C#** code without any external dependencies (no WebBrowser control, ActiveX / COM or MSHTML dll), the only requirement is **.NET Framework 4.6.2 or higher**. ![Renderer.png](https://raw.githubusercontent.com/ArthurHub/HTML-Renderer/master/Art/demo_winforms.png) @@ -38,7 +38,6 @@ The latest NuGet packages can be found on NuGet.org: * Create images/PDFs from HTML snippets. * Handles "real world" malformed HTML, it doesn't have to be XHTML. * 100% managed code and no external dependencies. -* Supports .NET 2.0 or higher including Client Profile. * Lightweight, just two DLLs (~300K). * High performance and low memory footprint. * Extendable and configurable. diff --git a/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj b/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj index 7413cc397..3f907ebe4 100644 --- a/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj +++ b/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj @@ -1,178 +1,96 @@ - - - + - Debug - AnyCPU - {2390B71F-9400-47F4-B23A-7F2649C87D35} + net462 Library - Properties TheArtOfDev.HtmlRenderer.Demo.Common HtmlRendererDemoCommon - v2.0 - 512 - + false - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - + Resources.resx True True - - - - - - - - - + PublicResXFileCodeGenerator Resources.Designer.cs Designer - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {FE611685-391F-4E3E-B27E-D3150E51E49B} - HtmlRenderer - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + - + - - \ No newline at end of file diff --git a/Source/Demo/Common/Properties/Resources.Designer.cs b/Source/Demo/Common/Properties/Resources.Designer.cs index 8b1aa6a38..f9f272e58 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", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class Resources { diff --git a/Source/Demo/Common/Samples/00.Intro.htm b/Source/Demo/Common/Samples/00.Intro.htm index 18c44f869..d310818b4 100644 --- a/Source/Demo/Common/Samples/00.Intro.htm +++ b/Source/Demo/Common/Samples/00.Intro.htm @@ -22,7 +22,7 @@

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. + requirement is .NET Framework 4.6.2 or higher, including support for Client Profile.

From f0349fd95fa2c4c8c7dc40ef8fe6edc3f9665d11 Mon Sep 17 00:00:00 2001 From: Sergio Delgado Date: Sun, 8 Mar 2015 23:28:03 +0100 Subject: [PATCH 03/54] Changes to allow custom sizes if these are not defined in PageSize --- .../PdfGenerateConfig.cs | 38 +++++++++++++++++++ Source/HtmlRenderer.PdfSharp/PdfGenerator.cs | 15 +++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/Source/HtmlRenderer.PdfSharp/PdfGenerateConfig.cs b/Source/HtmlRenderer.PdfSharp/PdfGenerateConfig.cs index acd77b4da..b095ef800 100644 --- a/Source/HtmlRenderer.PdfSharp/PdfGenerateConfig.cs +++ b/Source/HtmlRenderer.PdfSharp/PdfGenerateConfig.cs @@ -11,6 +11,7 @@ // "The Art of War" using PdfSharp; +using PdfSharp.Drawing; namespace TheArtOfDev.HtmlRenderer.PdfSharp { @@ -26,6 +27,11 @@ public sealed class PdfGenerateConfig /// private PageSize _pageSize; + /// + /// if the page size is undefined this allow you to set manually the page size + /// + private XSize _xsize; + /// /// the top margin between the page start and the text /// @@ -58,6 +64,14 @@ public PageSize PageSize set { _pageSize = value; } } + /// + /// if the page size is undefined this allow you to set manually the page size + /// + public XSize ManualPageSize { + get { return _xsize; } + set { _xsize = value; } + } + /// /// the top margin between the page start and the text /// @@ -119,5 +133,29 @@ public void SetMargins(int value) if (value > -1) _marginBottom = _marginLeft = _marginTop = _marginRight = value; } + + // The international definitions are: + // 1 inch == 25.4 mm + // 1 inch == 72 point + + /// + /// Convert the units passed in milimiters to the units used in PdfSharp + /// + /// + /// + /// + public static XSize MilimitersToUnits(double width, double height) { + return new XSize(width / 25.4 * 72, height / 25.4 * 72); + } + + /// + /// Convert the units passed in inches to the units used in PdfSharp + /// + /// + /// + /// + public static XSize InchesToUnits(double width, double height) { + return new XSize(width * 72, height * 72); + } } } \ No newline at end of file diff --git a/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs b/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs index e5f731183..aa77d2e4f 100644 --- a/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs +++ b/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs @@ -90,8 +90,13 @@ public static PdfDocument GeneratePdf(string html, PdfGenerateConfig config, Css // create PDF document to render the HTML into var document = new PdfDocument(); + XSize orgPageSize; // get the size of each page to layout the HTML in - var orgPageSize = PageSizeConverter.ToSize(config.PageSize); + if (config.PageSize != PageSize.Undefined) + orgPageSize = PageSizeConverter.ToSize(config.PageSize); + else + orgPageSize = config.ManualPageSize; + var pageSize = new XSize(orgPageSize.Width - config.MarginLeft - config.MarginRight, orgPageSize.Height - config.MarginTop - config.MarginBottom); if (!string.IsNullOrEmpty(html)) @@ -118,7 +123,13 @@ public static PdfDocument GeneratePdf(string html, PdfGenerateConfig config, Css while (scrollOffset > -container.ActualSize.Height) { var page = document.AddPage(); - page.Size = config.PageSize; + if (config.PageSize != PageSize.Undefined) { + page.Size = config.PageSize; + }else { + page.Height = config.ManualPageSize.Height; + page.Width = config.ManualPageSize.Width; + } + using (var g = XGraphics.FromPdfPage(page)) { g.IntersectClip(new XRect(config.MarginLeft, config.MarginTop, pageSize.Width, pageSize.Height)); From d97f1822a6bc11b7d418d5ac2d87b27f454c9cef Mon Sep 17 00:00:00 2001 From: Matt Schneeberger Date: Mon, 30 Mar 2015 21:19:58 -0500 Subject: [PATCH 04/54] Call base.OnMouseUp instead of base.OnMouseClick from HtmlPanel.OnMouseUp --- Source/HtmlRenderer.WinForms/HtmlPanel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/HtmlRenderer.WinForms/HtmlPanel.cs b/Source/HtmlRenderer.WinForms/HtmlPanel.cs index aa52bd3e6..bbf1accf3 100644 --- a/Source/HtmlRenderer.WinForms/HtmlPanel.cs +++ b/Source/HtmlRenderer.WinForms/HtmlPanel.cs @@ -555,7 +555,7 @@ protected override void OnMouseDown(MouseEventArgs e) /// protected override void OnMouseUp(MouseEventArgs e) { - base.OnMouseClick(e); + base.OnMouseUp(e); if (_htmlContainer != null) _htmlContainer.HandleMouseUp(this, e); } From 8181e9b9d0224b8bb9ea8bee7df9ed1546b1a45c Mon Sep 17 00:00:00 2001 From: Matt Schneeberger Date: Sun, 12 Apr 2015 05:04:20 -0500 Subject: [PATCH 05/54] OnMouseUp should call base.OnMouseUp instead of base.OnMouseClick in HtmlLabel.cs --- Source/HtmlRenderer.WinForms/HtmlLabel.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/HtmlRenderer.WinForms/HtmlLabel.cs b/Source/HtmlRenderer.WinForms/HtmlLabel.cs index d1b72542b..8853490d2 100644 --- a/Source/HtmlRenderer.WinForms/HtmlLabel.cs +++ b/Source/HtmlRenderer.WinForms/HtmlLabel.cs @@ -558,7 +558,7 @@ protected override void OnMouseLeave(EventArgs e) /// protected override void OnMouseUp(MouseEventArgs e) { - base.OnMouseClick(e); + base.OnMouseUp(e); if (_htmlContainer != null) _htmlContainer.HandleMouseUp(this, e); } From 987587ec27daa986e71d05f61defd9f8d5b10237 Mon Sep 17 00:00:00 2001 From: jfillbrook Date: Sat, 2 May 2015 15:15:17 +0100 Subject: [PATCH 06/54] Added ability to set page orientation for PdfSharp --- .../HtmlRenderer.PdfSharp/PdfGenerateConfig.cs | 14 ++++++++++++++ Source/HtmlRenderer.PdfSharp/PdfGenerator.cs | 16 +++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Source/HtmlRenderer.PdfSharp/PdfGenerateConfig.cs b/Source/HtmlRenderer.PdfSharp/PdfGenerateConfig.cs index b095ef800..b0aa0d64c 100644 --- a/Source/HtmlRenderer.PdfSharp/PdfGenerateConfig.cs +++ b/Source/HtmlRenderer.PdfSharp/PdfGenerateConfig.cs @@ -32,6 +32,11 @@ public sealed class PdfGenerateConfig /// private XSize _xsize; + /// + /// the orientation of each page of the generated pdf + /// + private PageOrientation _pageOrientation; + /// /// the top margin between the page start and the text /// @@ -72,6 +77,15 @@ public XSize ManualPageSize { set { _xsize = value; } } + /// + /// the orientation of each page of the generated pdf + /// + public PageOrientation PageOrientation + { + get { return _pageOrientation; } + set { _pageOrientation = value; } + } + /// /// the top margin between the page start and the text /// diff --git a/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs b/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs index aa77d2e4f..08b270586 100644 --- a/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs +++ b/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs @@ -96,7 +96,13 @@ public static PdfDocument GeneratePdf(string html, PdfGenerateConfig config, Css orgPageSize = PageSizeConverter.ToSize(config.PageSize); else orgPageSize = config.ManualPageSize; - + + if (config.PageOrientation == PageOrientation.Landscape) + { + // invert pagesize for landscape + orgPageSize = new XSize(orgPageSize.Height, orgPageSize.Width); + } + var pageSize = new XSize(orgPageSize.Width - config.MarginLeft - config.MarginRight, orgPageSize.Height - config.MarginTop - config.MarginBottom); if (!string.IsNullOrEmpty(html)) @@ -123,12 +129,8 @@ public static PdfDocument GeneratePdf(string html, PdfGenerateConfig config, Css while (scrollOffset > -container.ActualSize.Height) { var page = document.AddPage(); - if (config.PageSize != PageSize.Undefined) { - page.Size = config.PageSize; - }else { - page.Height = config.ManualPageSize.Height; - page.Width = config.ManualPageSize.Width; - } + page.Height = orgPageSize.Height; + page.Width = orgPageSize.Width; using (var g = XGraphics.FromPdfPage(page)) { From 2f6cc2562448493d4c1686c5f6cd0381832dd7c3 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 6 May 2015 10:32:09 +0300 Subject: [PATCH 07/54] win32 updates --- Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs b/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs index 712d72b7b..33dddd53f 100644 --- a/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs +++ b/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs @@ -141,10 +141,10 @@ public static Rectangle GetWindowRectangle(IntPtr handle) public static extern int SetBkMode(IntPtr hdc, int mode); [DllImport("gdi32.dll")] - public static extern int SelectObject(IntPtr hdc, IntPtr hgdiObj); + public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiObj); [DllImport("gdi32.dll")] - public static extern int SetTextColor(IntPtr hdc, int color); + public static extern uint SetTextColor(IntPtr hdc, int color); [DllImport("gdi32.dll", CharSet = CharSet.Unicode)] public static extern bool GetTextMetrics(IntPtr hdc, out TextMetric lptm); @@ -172,7 +172,7 @@ public static Rectangle GetWindowRectangle(IntPtr handle) [DllImport("gdi32.dll")] [return: MarshalAs(UnmanagedType.Bool)] - public static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop); + public static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, uint dwRop); [DllImport("gdi32.dll", EntryPoint = "GdiAlphaBlend")] public static extern bool AlphaBlend(IntPtr hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, IntPtr hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BlendFunction blendFunction); From c8cf25f1b1f0ed214eb7cf6d0b3c2f5ff7a29a85 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 6 May 2015 10:34:43 +0300 Subject: [PATCH 08/54] ix youtube link --- Source/Demo/Common/Samples/06.Embeded video.htm | 2 +- Source/Demo/Common/TestSamples/14.Iframes.htm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Demo/Common/Samples/06.Embeded video.htm b/Source/Demo/Common/Samples/06.Embeded video.htm index 531da5c85..dc64330d9 100644 --- a/Source/Demo/Common/Samples/06.Embeded video.htm +++ b/Source/Demo/Common/Samples/06.Embeded video.htm @@ -33,7 +33,7 @@

Example

-


From ccc164c1a061d1dc29bc3022d2583d5c9066d38a Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 6 May 2015 10:37:24 +0300 Subject: [PATCH 09/54] set version to 1.5.0.6 --- Source/SharedAssemblyInfo.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/SharedAssemblyInfo.cs b/Source/SharedAssemblyInfo.cs index d5336037f..175dafbe0 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("1.5.0.6")] \ No newline at end of file From 8bf427e1c104e4287fe97a43157c14936ecac829 Mon Sep 17 00:00:00 2001 From: Vitor Fernandes Date: Wed, 6 May 2015 16:43:22 +0100 Subject: [PATCH 10/54] feat(PdfGenerator): allow generated pages to be appended to a PdfDocument Adds a new method AddPdfPages that generates and appends pages to the specified PdfDocument. This allows the creation of a PdfDocument page by page, where each set of pages can have different layouts and allows better control of page breaks/contents. --- Source/HtmlRenderer.PdfSharp/PdfGenerator.cs | 42 ++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs b/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs index 08b270586..c8c167e05 100644 --- a/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs +++ b/Source/HtmlRenderer.PdfSharp/PdfGenerator.cs @@ -89,7 +89,44 @@ public static PdfDocument GeneratePdf(string html, PdfGenerateConfig config, Css { // create PDF document to render the HTML into var document = new PdfDocument(); - + + // add rendered PDF pages to document + AddPdfPages(document, html, config, cssData, stylesheetLoad, imageLoad); + + return document; + } + + /// + /// Create PDF pages from given HTML and appends them to the provided PDF document.
+ ///
+ /// PDF document to append pages to + /// HTML source to create PDF from + /// the page size to use for each page in the generated pdf + /// the margin to use between the HTML and the edges of each page + /// optional: the style to use for html rendering (default - use W3 default style) + /// optional: can be used to overwrite stylesheet resolution logic + /// optional: can be used to overwrite image resolution logic + /// the generated image of the html + public static void AddPdfPages(PdfDocument document, string html, PageSize pageSize, int margin = 20, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) + { + var config = new PdfGenerateConfig(); + config.PageSize = pageSize; + config.SetMargins(margin); + AddPdfPages(document, html, config, cssData, stylesheetLoad, imageLoad); + } + + /// + /// Create PDF pages from given HTML and appends them to the provided PDF document.
+ ///
+ /// PDF document to append pages to + /// HTML source to create PDF from + /// the configuration to use for the PDF generation (page size/page orientation/margins/etc.) + /// optional: the style to use for html rendering (default - use W3 default style) + /// optional: can be used to overwrite stylesheet resolution logic + /// optional: can be used to overwrite image resolution logic + /// the generated image of the html + public static void AddPdfPages(PdfDocument document, string html, PdfGenerateConfig config, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) + { XSize orgPageSize; // get the size of each page to layout the HTML in if (config.PageSize != PageSize.Undefined) @@ -146,11 +183,10 @@ public static PdfDocument GeneratePdf(string html, PdfGenerateConfig config, Css HandleLinks(document, container, orgPageSize, pageSize); } } - - return document; } + #region Private/Protected methods /// From 369c2b0bdc88c9b86408a1e954098792736fd020 Mon Sep 17 00:00:00 2001 From: Simon Stevenson Date: Tue, 12 May 2015 17:46:37 +1000 Subject: [PATCH 11/54] Fix for the last attribute without a value crashing the parser --- Source/HtmlRenderer/Core/Parse/HtmlParser.cs | 26 +++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Source/HtmlRenderer/Core/Parse/HtmlParser.cs b/Source/HtmlRenderer/Core/Parse/HtmlParser.cs index 286dee89c..f246fda82 100644 --- a/Source/HtmlRenderer/Core/Parse/HtmlParser.cs +++ b/Source/HtmlRenderer/Core/Parse/HtmlParser.cs @@ -222,27 +222,31 @@ private static void ExtractAttributes(string source, int idx, int length, out Di if (startIdx < idx + length) { var key = source.Substring(startIdx, endIdx - startIdx); + var value = ""; startIdx = endIdx + 1; while (startIdx < idx + length && (char.IsWhiteSpace(source, startIdx) || source[startIdx] == '=')) startIdx++; bool hasPChar = false; - char pChar = source[startIdx]; - if (pChar == '"' || pChar == '\'') + if (startIdx < idx + length) { - hasPChar = true; - startIdx++; - } + char pChar = source[startIdx]; + if (pChar == '"' || pChar == '\'') + { + hasPChar = true; + startIdx++; + } - endIdx = startIdx + (hasPChar ? 0 : 1); - while (endIdx < idx + length && (hasPChar ? source[endIdx] != pChar : !char.IsWhiteSpace(source, endIdx))) - endIdx++; + endIdx = startIdx + (hasPChar ? 0 : 1); + while (endIdx < idx + length && (hasPChar ? source[endIdx] != pChar : !char.IsWhiteSpace(source, endIdx))) + endIdx++; - var value = source.Substring(startIdx, endIdx - startIdx); - value = HtmlUtils.DecodeHtml(value); + value = source.Substring(startIdx, endIdx - startIdx); + value = HtmlUtils.DecodeHtml(value); + } - if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value)) + if (!string.IsNullOrEmpty(key) && (value != null)) { if (attributes == null) attributes = new Dictionary(StringComparer.InvariantCultureIgnoreCase); From e05e700f7ef6dae60adfba0f48d8a7fc53760234 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Aug 2015 21:33:43 +0900 Subject: [PATCH 12/54] (WpfAdapter.cs) fix AddFontFamily(new FontFamilyAdapter(family)); fail by a limited font. --- Source/HtmlRenderer.WPF/Adapters/WpfAdapter.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/HtmlRenderer.WPF/Adapters/WpfAdapter.cs b/Source/HtmlRenderer.WPF/Adapters/WpfAdapter.cs index 13f5eed55..117ec5ca8 100644 --- a/Source/HtmlRenderer.WPF/Adapters/WpfAdapter.cs +++ b/Source/HtmlRenderer.WPF/Adapters/WpfAdapter.cs @@ -63,7 +63,13 @@ private WpfAdapter() foreach (var family in Fonts.SystemFontFamilies) { - AddFontFamily(new FontFamilyAdapter(family)); + try + { + AddFontFamily(new FontFamilyAdapter(family)); + } + catch + { + } } } From dde63dcc5160e1af84214b05a705cca0de530967 Mon Sep 17 00:00:00 2001 From: Jerome Date: Thu, 3 Dec 2015 22:35:45 +0100 Subject: [PATCH 13/54] ENABLED SAVING HTML AS EMF FILE (VECTORIAL IMAGE): Added HtmlRender.RenderToMetafile(...) and MetafileExtensions.SaveAsEmf(...) extension method --- Source/HtmlRenderer.WinForms/HtmlRender.cs | 23 ++++++++++++ .../HtmlRenderer.WinForms.csproj | 1 + .../MetafileExtensions.cs | 37 +++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 Source/HtmlRenderer.WinForms/MetafileExtensions.cs diff --git a/Source/HtmlRenderer.WinForms/HtmlRender.cs b/Source/HtmlRenderer.WinForms/HtmlRender.cs index 2d3f349ec..3c6ad3ca9 100644 --- a/Source/HtmlRenderer.WinForms/HtmlRender.cs +++ b/Source/HtmlRenderer.WinForms/HtmlRender.cs @@ -273,6 +273,29 @@ public static SizeF RenderGdiPlus(Graphics g, string html, PointF location, Size } #if !MONO + + public static Metafile RenderToMetafile(string html, float left = 0, float top = 0, float maxWidth = 0, CssData cssData = null, + EventHandler stylesheetLoad = null, EventHandler imageLoad = null) + { + Metafile image; + IntPtr dib; + var memoryHdc = Win32Utils.CreateMemoryHdc(IntPtr.Zero, 1, 1, out dib); + try + { + image = new Metafile(memoryHdc, EmfType.EmfPlusDual, ".."); + + using (var g = Graphics.FromImage(image)) + { + Render(g, html, left, top, maxWidth, cssData, stylesheetLoad, imageLoad); + } + } + finally + { + Win32Utils.ReleaseMemoryHdc(memoryHdc, dib); + } + return image; + } + /// /// Renders the specified HTML on top of the given image.
/// will contain the rendered html in it on top of original content.
diff --git a/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj b/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj index 79b059d84..ce1a98759 100644 --- a/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj +++ b/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj @@ -87,6 +87,7 @@ Component + diff --git a/Source/HtmlRenderer.WinForms/MetafileExtensions.cs b/Source/HtmlRenderer.WinForms/MetafileExtensions.cs new file mode 100644 index 000000000..4b13ba607 --- /dev/null +++ b/Source/HtmlRenderer.WinForms/MetafileExtensions.cs @@ -0,0 +1,37 @@ +using System; +using System.Drawing.Imaging; +using System.IO; +using System.Runtime.InteropServices; + +namespace TheArtOfDev.HtmlRenderer.WinForms +{ + public static class MetafileExtensions + { + public static void SaveAsEmf(Metafile me, string fileName) + { + /* http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/12a1c749-b320-4ce9-aff7-9de0d7fd30ea + How to save or serialize a Metafile: Solution found + by : SWAT Team member _1 + Date : Friday, February 01, 2008 1:38 PM + */ + int enfMetafileHandle = me.GetHenhmetafile().ToInt32(); + int bufferSize = GetEnhMetaFileBits(enfMetafileHandle, 0, null); // Get required buffer size. + byte[] buffer = new byte[bufferSize]; // Allocate sufficient buffer + if (GetEnhMetaFileBits(enfMetafileHandle, bufferSize, buffer) <= 0) // Get raw metafile data. + throw new SystemException("Fail"); + + FileStream ms = File.Open(fileName, FileMode.Create); + ms.Write(buffer, 0, bufferSize); + ms.Close(); + ms.Dispose(); + if (!DeleteEnhMetaFile(enfMetafileHandle)) //free handle + throw new SystemException("Fail Free"); + } + + [DllImport("gdi32")] + public static extern int GetEnhMetaFileBits(int hemf, int cbBuffer, byte[] lpbBuffer); + + [DllImport("gdi32")] + public static extern bool DeleteEnhMetaFile(int hemfbitHandle); + } +} From 530e9a05f4caf2c3958634170b4ea80d0de05a47 Mon Sep 17 00:00:00 2001 From: Andrey Ushakov Date: Tue, 26 Apr 2016 13:57:23 +0300 Subject: [PATCH 14/54] Support base64 images in css content property --- Source/Demo/Common/HtmlRenderer.Demo.Common.csproj | 3 +++ .../Common/TestSamples/32.Image in css content.htm | 14 ++++++++++++++ Source/HtmlRenderer/Core/Dom/CssBoxImage.cs | 8 ++++++-- Source/HtmlRenderer/Core/Dom/CssBoxProperties.cs | 10 ++++++++-- Source/HtmlRenderer/Core/Parse/CssParser.cs | 14 ++++++++++++-- Source/HtmlRenderer/Core/Utils/CssUtils.cs | 5 +++++ Source/HtmlRenderer/Core/Utils/HtmlConstants.cs | 2 +- 7 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 Source/Demo/Common/TestSamples/32.Image in css content.htm diff --git a/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj b/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj index a8ffe8490..9e964a55e 100644 --- a/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj +++ b/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj @@ -155,6 +155,9 @@ + + + - foinobpjg + foinobpjg
- fcb: j onq'p eoapl jmin leo halnbcmam ei cfri... m´h qnlpll lnha ohhrrjbcf jghl + fcb: j onq'p eoapl jmin leo halnbcmam ei cfri... m´h qnlpll lnha ohhrrjbcf jghl bqcrgpk lb abp qkqo gralcp kfeildpd, dbjbj ril eppg n hfcbqd gqj fnjd &gpnp;egoppa&foaq; fn &ncon;ccrb hm rjelnn&jgkl; qhlj kpkfoe qead odr obepl ij gfk dekfm, gmo fifdf kle cnnj bpjon fgn frbcf'e haerd qfgimmkn le gfol nifmojh rrjghcqa dkac (koen hpccjmi, @@ -149,7 +149,7 @@

- qcpciiahbq + qcpciiahbq

- gmoorqgfcj + gmoorqgfcj
- lqafmgjder + lqafmgjder
- iefmkkidri + iefmkkidri
- mlkgdjqbrb + mlkgdjqbrb
- dafomhjllq + dafomhjllq
- lplfhiceem + lplfhiceem
- erkeokamgb + erkeokamgb
- lljaghklrq + lljaghklrq
- hgiircibcr + hgiircibcr
- jbcmbmblrd + jbcmbmblrd
- qicilgnpmc + qicilgnpmc
- idgpecqqbe + idgpecqqbe
- nalofqmbfj + nalofqmbfj
- pnkaqjoffq + pnkaqjoffq
- qrqrkgdcqr + qrqrkgdcqr
- gnlikhjdnp + gnlikhjdnp
- iabjqrghmc + iabjqrghmc
- krccimirgr + krccimirgr
- qdlabffkab + qdlabffkab
@@ -1854,7 +1854,7 @@

gekjn ofkcmr + href='https://www.google.com'>gekjn ofkcmr

- ermkrcjhph + ermkrcjhph
- pjlooeoecc + pjlooeoecc
- cbmqpeodaj + cbmqpeodaj
- kariaiqbfn + kariaiqbfn
- fffjecboen + fffjecboen
- ffpqbmpdrj + ffpqbmpdrj
- fchijmeomh + fchijmeomh
- qbaqglhbcp + qbaqglhbcp
- kkpoghnaeg + kkpoghnaeg
- effijocbfm + effijocbfm
- fiicehbcam + fiicehbcam
- adnkmldmig + adnkmldmig
- pngfmr o bba dahbkcro ql qaralkcqojci ch addkifq mie dcobgb 2.1 aa - jjjpo, gm bp + jjjpo, gm bp qejpnprah
- qhfkmejmp iobknjbqlqdg pp hiahqhh epb rclnqo 2.1 ff ciden gjaooda: pabjq - +
@@ -63,7 +63,6 @@

public DemoForm() { - SamplesLoader.Init(HtmlRenderingHelper.IsRunningOnMono() ? "Mono" : "WinForms", typeof(HtmlRender).Assembly.GetName().Version.ToString()); + SamplesLoader.Init("WinForms", typeof(HtmlRender).Assembly.GetName().Version.ToString()); InitializeComponent(); @@ -59,8 +59,8 @@ public DemoForm() LoadCustomFonts(); - _showIEViewTSSB.Enabled = !HtmlRenderingHelper.IsRunningOnMono(); - _generatePdfTSB.Enabled = !HtmlRenderingHelper.IsRunningOnMono(); + _showIEViewTSSB.Enabled = true; + _generatePdfTSB.Enabled = true; } /// @@ -145,10 +145,12 @@ private void OnGeneratePdf_Click(object sender, EventArgs e) config.SetMargins(20); var doc = PdfGenerator.GeneratePdf(_mainControl.GetHtml(), config, null, DemoUtils.OnStylesheetLoad, HtmlRenderingHelper.OnImageLoadPdfSharp); + var tmpFile = Path.GetTempFileName(); - tmpFile = Path.GetFileNameWithoutExtension(tmpFile) + ".pdf"; - doc.Save(tmpFile); - Process.Start(tmpFile); + var pdfFile = Path.ChangeExtension(tmpFile, ".pdf"); // Preserves the full path + doc.Save(pdfFile); + + Process.Start(new ProcessStartInfo(pdfFile) { UseShellExecute = true }); } /// diff --git a/Source/Demo/WinForms/GenerateImageForm.cs b/Source/Demo/WinForms/GenerateImageForm.cs index 5f966a8f2..f4e8a4577 100644 --- a/Source/Demo/WinForms/GenerateImageForm.cs +++ b/Source/Demo/WinForms/GenerateImageForm.cs @@ -51,8 +51,8 @@ public GenerateImageForm(string html) } _textRenderingHintTSCB.SelectedItem = TextRenderingHint.AntiAlias.ToString(); - _useGdiPlusTSB.Enabled = !HtmlRenderingHelper.IsRunningOnMono(); - _backgroundColorTSB.Enabled = !HtmlRenderingHelper.IsRunningOnMono(); + _useGdiPlusTSB.Enabled = true; + _backgroundColorTSB.Enabled = true; } private void OnSaveToFile_Click(object sender, EventArgs e) @@ -103,7 +103,7 @@ private void GenerateImage() TextRenderingHint textRenderingHint = (TextRenderingHint)Enum.Parse(typeof(TextRenderingHint), _textRenderingHintTSCB.SelectedItem.ToString()); Image img; - if (_useGdiPlusTSB.Checked || HtmlRenderingHelper.IsRunningOnMono()) + if (_useGdiPlusTSB.Checked) { img = HtmlRender.RenderToImageGdiPlus(_html, _pictureBox.ClientSize, textRenderingHint, null, DemoUtils.OnStylesheetLoad, HtmlRenderingHelper.OnImageLoad); } diff --git a/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj b/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj index 3485b7573..e6b47dcc7 100644 --- a/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj +++ b/Source/Demo/WinForms/HtmlRenderer.Demo.WinForms.csproj @@ -1,14 +1,12 @@  - net462 + net8.0-windows WinExe TheArtOfDev.HtmlRenderer.Demo.WinForms HtmlRendererWinFormsDemo - publish\ true - AllRules.ruleset - false - true + true + true html.ico diff --git a/Source/Demo/WinForms/HtmlRenderingHelper.cs b/Source/Demo/WinForms/HtmlRenderingHelper.cs index 6be842af6..33b6ae5e7 100644 --- a/Source/Demo/WinForms/HtmlRenderingHelper.cs +++ b/Source/Demo/WinForms/HtmlRenderingHelper.cs @@ -32,15 +32,6 @@ internal static class HtmlRenderingHelper #endregion - - /// - /// Check if currently running in mono. - /// - public static bool IsRunningOnMono() - { - return Type.GetType("Mono.Runtime") != null; - } - /// /// Create image to be used to fill background so it will be clear that what's on top is transparent. /// diff --git a/Source/Demo/WinForms/MainControl.cs b/Source/Demo/WinForms/MainControl.cs index 696fc032c..c683e99e2 100644 --- a/Source/Demo/WinForms/MainControl.cs +++ b/Source/Demo/WinForms/MainControl.cs @@ -11,6 +11,7 @@ // "The Art of War" using System; +using System.ComponentModel; using System.Drawing; using System.Drawing.Imaging; using System.IO; @@ -72,6 +73,8 @@ public MainControl() /// /// used ignore html editor updates when updating separately /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool UpdateLock { get { return _updateLock; } @@ -81,6 +84,8 @@ public bool UpdateLock /// /// In IE view if to show original html or the html generated from the html control /// + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public bool UseGeneratedHtml { get { return _useGeneratedHtml; } @@ -186,7 +191,7 @@ private void OnSamplesTreeViewAfterSelect(object sender, TreeViewEventArgs e) { _updateLock = true; - if (!HtmlRenderingHelper.IsRunningOnMono() && e.Node.Parent.Text != PerformanceSamplesTreeNodeName) + if (e.Node.Parent.Text != PerformanceSamplesTreeNodeName) SetColoredText(sample.Html); else _htmlEditor.Text = sample.Html; diff --git a/Source/Demo/WinForms/Program.cs b/Source/Demo/WinForms/Program.cs index f01eb6d0a..cba933ec4 100644 --- a/Source/Demo/WinForms/Program.cs +++ b/Source/Demo/WinForms/Program.cs @@ -14,6 +14,7 @@ using System.Globalization; using System.IO; using System.Reflection; +using System.Text; using System.Windows.Forms; namespace TheArtOfDev.HtmlRenderer.Demo.WinForms @@ -28,6 +29,8 @@ private static void Main() { AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly; + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new DemoForm()); @@ -52,7 +55,7 @@ private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args) if (stream != null) { byte[] assemblyRawBytes = new byte[stream.Length]; - stream.Read(assemblyRawBytes, 0, assemblyRawBytes.Length); + stream.ReadExactly(assemblyRawBytes); return Assembly.Load(assemblyRawBytes); } return null; 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/Directory.Build.props b/Source/Directory.Build.props index 9574b2471..dfc83f317 100644 --- a/Source/Directory.Build.props +++ b/Source/Directory.Build.props @@ -1,15 +1,19 @@ - + HTML Renderer Arthur Teplitzki Arthur Teplitzki + Open source hosted on GitHub + Copyright © 2008-2025 + 1.6.0-dev + 1.6.0.0 + 1.6.0.0 README.md BSD-3-Clause https://codeplexarchive.org/project/HtmlRenderer html.png false See https://github.com/ArthurHub/HTML-Renderer/releases. - 1.6.0-dev false diff --git a/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj b/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj index 524c96343..2ff483a96 100644 --- a/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj +++ b/Source/HtmlRenderer.PdfSharp/HtmlRenderer.PdfSharp.csproj @@ -1,10 +1,11 @@  - net462 + net8.0-windows Library TheArtOfDev.HtmlRenderer.PdfSharp - false - true + true + true + true @@ -25,9 +26,6 @@ Features and Benefits: PDF document generator from HTML snippet, 100% managed (C#), High performance library using PdfSharp. - - Properties\SharedAssemblyInfo.cs - @@ -35,5 +33,6 @@ Features and Benefits: + \ No newline at end of file diff --git a/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj b/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj index 3080e1406..65d9f483f 100644 --- a/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj +++ b/Source/HtmlRenderer.WPF/HtmlRenderer.WPF.csproj @@ -1,11 +1,11 @@  - net462 + net8.0-windows Library TheArtOfDev.HtmlRenderer.WPF true - false - true + true + true @@ -31,9 +31,6 @@ Features and Benefits: * Extendable and configurable. Multipurpose (UI Controls / Image generation), 100% managed (C#), High performance HTML Rendering library for WPF. - - bin\Release.WPF\ - @@ -41,9 +38,6 @@ Features and Benefits: - - Properties\SharedAssemblyInfo.cs - \ No newline at end of file diff --git a/Source/HtmlRenderer.WinForms/Adapters/GraphicsAdapter.cs b/Source/HtmlRenderer.WinForms/Adapters/GraphicsAdapter.cs index 523870c2b..6b55d50f2 100644 --- a/Source/HtmlRenderer.WinForms/Adapters/GraphicsAdapter.cs +++ b/Source/HtmlRenderer.WinForms/Adapters/GraphicsAdapter.cs @@ -62,12 +62,10 @@ internal sealed class GraphicsAdapter : RGraphics /// private readonly bool _useGdiPlusTextRendering; -#if !MONO /// /// the initialized HDC used /// private IntPtr _hdc; -#endif /// /// if to release the graphics object on dispose @@ -107,11 +105,7 @@ public GraphicsAdapter(Graphics g, bool useGdiPlusTextRendering, bool releaseGra _g = g; _releaseGraphics = releaseGraphics; -#if MONO - _useGdiPlusTextRendering = true; -#else _useGdiPlusTextRendering = useGdiPlusTextRendering; -#endif } public override void PopClip() @@ -167,19 +161,13 @@ public override RSize MeasureString(string str, RFont font) { var height = realFont.Height; var descent = realFont.Size * realFont.FontFamily.GetCellDescent(realFont.Style) / realFont.FontFamily.GetEmHeight(realFont.Style); -#if !MONO fontAdapter.SetMetrics(height, (int)Math.Round((height - descent + .5f))); -#else - fontAdapter.SetMetrics(height, (int)Math.Round((height - descent + 1f))); -#endif - } return Utils.Convert(size); } else { -#if !MONO SetFont(font); var size = new Size(); Win32Utils.GetTextExtentPoint32(_hdc, str, str.Length, ref size); @@ -192,9 +180,6 @@ public override RSize MeasureString(string str, RFont font) } return Utils.Convert(size); -#else - throw new InvalidProgramException("Invalid Mono code"); -#endif } } @@ -220,14 +205,12 @@ public override void MeasureString(string str, RFont font, double maxWidth, out } else { -#if !MONO SetFont(font); var size = new Size(); Win32Utils.GetTextExtentExPoint(_hdc, str, str.Length, (int)Math.Round(maxWidth), _charFit, _charFitWidth, ref size); charFit = _charFit[0]; charFitWidth = charFit > 0 ? _charFitWidth[charFit - 1] : 0; -#endif } } @@ -242,7 +225,6 @@ public override void DrawString(string str, RFont font, RColor color, RPoint poi } else { -#if !MONO var pointConv = Utils.ConvertRound(point); var colorConv = Utils.Convert(color); @@ -260,7 +242,6 @@ public override void DrawString(string str, RFont font, RColor color, RPoint poi SetRtlAlignGdi(rtl); DrawTransparentText(_hdc, str, font, pointConv, Utils.ConvertRound(size), colorConv); } -#endif } } @@ -349,17 +330,14 @@ public override void DrawPolygon(RBrush brush, RPoint[] points) /// private void ReleaseHdc() { -#if !MONO if (_hdc != IntPtr.Zero) { Win32Utils.SelectClipRgn(_hdc, IntPtr.Zero); _g.ReleaseHdc(_hdc); _hdc = IntPtr.Zero; } -#endif } -#if !MONO /// /// Init HDC for the current graphics object to be used to call GDI directly. /// @@ -448,7 +426,6 @@ private static void DrawTransparentText(IntPtr hdc, string str, RFont font, Poin Win32Utils.ReleaseMemoryHdc(memoryHdc, dib); } } -#endif /// /// Change text align to Left-to-Right or Right-to-Left if required. diff --git a/Source/HtmlRenderer.WinForms/HtmlLabel.cs b/Source/HtmlRenderer.WinForms/HtmlLabel.cs index 8853490d2..283ef7360 100644 --- a/Source/HtmlRenderer.WinForms/HtmlLabel.cs +++ b/Source/HtmlRenderer.WinForms/HtmlLabel.cs @@ -295,6 +295,7 @@ public virtual bool IsContextMenuEnabled [Browsable(true)] [Description("Set base stylesheet to be used by html rendered in the control.")] [Category("Appearance")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] [Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public virtual string BaseStylesheet { @@ -487,7 +488,7 @@ protected override void OnLayout(LayoutEventArgs levent) { if (_htmlContainer != null) { - Graphics g = Utils.CreateGraphics(this); + Graphics g = CreateGraphics(); if (g != null) { using (g) @@ -788,6 +789,7 @@ public override Cursor Cursor /// Not applicable. /// [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public new bool UseWaitCursor { get { return base.UseWaitCursor; } diff --git a/Source/HtmlRenderer.WinForms/HtmlPanel.cs b/Source/HtmlRenderer.WinForms/HtmlPanel.cs index ce94b0ea9..a2f061874 100644 --- a/Source/HtmlRenderer.WinForms/HtmlPanel.cs +++ b/Source/HtmlRenderer.WinForms/HtmlPanel.cs @@ -303,6 +303,7 @@ public virtual bool IsContextMenuEnabled [Browsable(true)] [Category("Appearance")] [Description("Set base stylesheet to be used by html rendered in the control.")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] [Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public virtual string BaseStylesheet { @@ -418,10 +419,8 @@ public void ClearSelection() _htmlContainer.ClearSelection(); } - #region Private methods -#if !MONO /// /// Override to support border for the control. /// @@ -445,7 +444,6 @@ protected override CreateParams CreateParams return createParams; } } -#endif /// /// Perform the layout of the html in the control. @@ -473,7 +471,7 @@ protected void PerformHtmlLayout() { _htmlContainer.MaxSize = new SizeF(ClientSize.Width - Padding.Horizontal, 0); - Graphics g = Utils.CreateGraphics(this); + Graphics g = CreateGraphics(); if (g != null) { using (g) @@ -482,7 +480,6 @@ protected void PerformHtmlLayout() } } - AutoScrollMinSize = Size.Round(new SizeF(_htmlContainer.ActualSize.Width + Padding.Horizontal, _htmlContainer.ActualSize.Height)); } } @@ -708,15 +705,12 @@ protected virtual void InvokeMouseMove() { try { - // mono has issue throwing exception for no reason var mp = PointToClient(MousePosition); _htmlContainer.HandleMouseMove(this, new MouseEventArgs(MouseButtons.None, 0, mp.X, mp.Y, 0)); } catch { -#if !MONO throw; -#endif } } @@ -741,7 +735,6 @@ protected override bool IsInputKey(Keys keyData) return base.IsInputKey(keyData); } -#if !MONO /// /// Override the proc processing method to set OS specific hand cursor. /// @@ -765,7 +758,6 @@ protected override void WndProc(ref Message m) } base.WndProc(ref m); } -#endif /// /// Release the html container resources. @@ -890,6 +882,7 @@ public override Cursor Cursor /// Not applicable. /// [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public new bool UseWaitCursor { get { return base.UseWaitCursor; } diff --git a/Source/HtmlRenderer.WinForms/HtmlRender.cs b/Source/HtmlRenderer.WinForms/HtmlRender.cs index b7e24d81e..ca0f44532 100644 --- a/Source/HtmlRenderer.WinForms/HtmlRender.cs +++ b/Source/HtmlRenderer.WinForms/HtmlRender.cs @@ -134,7 +134,6 @@ public static CssData ParseStyleSheet(string stylesheet, bool combineWithDefault return CssData.Parse(WinFormsAdapter.Instance, stylesheet, combineWithDefault); } -#if !MONO /// /// Measure the size (width and height) required to draw the given html under given max width restriction.
/// If no max width restriction is given the layout will use the maximum possible width required by the content, @@ -154,7 +153,6 @@ public static SizeF Measure(Graphics g, string html, float maxWidth = 0, CssData ArgChecker.AssertArgNotNull(g, "g"); return Measure(g, html, maxWidth, cssData, false, stylesheetLoad, imageLoad); } -#endif /// /// Measure the size (width and height) required to draw the given html under given max width restriction.
@@ -176,7 +174,6 @@ public static SizeF MeasureGdiPlus(Graphics g, string html, float maxWidth = 0, return Measure(g, html, maxWidth, cssData, true, stylesheetLoad, imageLoad); } -#if !MONO /// /// Renders the specified HTML source on the specified location and max width restriction.
/// Use GDI text rendering, note has no effect.
@@ -223,7 +220,6 @@ public static SizeF Render(Graphics g, string html, PointF location, SizeF maxSi ArgChecker.AssertArgNotNull(g, "g"); return RenderClip(g, html, location, maxSize, cssData, false, stylesheetLoad, imageLoad); } -#endif /// /// Renders the specified HTML source on the specified location and max size restriction.
@@ -272,8 +268,6 @@ public static SizeF RenderGdiPlus(Graphics g, string html, PointF location, Size return RenderClip(g, html, location, maxSize, cssData, true, stylesheetLoad, imageLoad); } -#if !MONO - public static Metafile RenderToMetafile(string html, float left = 0, float top = 0, float maxWidth = 0, CssData cssData = null, EventHandler stylesheetLoad = null, EventHandler imageLoad = null) { @@ -511,7 +505,6 @@ public static void RenderToImage(Image image, string html, PointF location, Size return image; } } -#endif /// /// Renders the specified HTML into a new image of the requested size.
@@ -764,7 +757,6 @@ private static SizeF RenderHtml(Graphics g, string html, PointF location, SizeF return actualSize; } -#if !MONO /// /// Copy all the bitmap bits from memory bitmap buffer to the given image. /// @@ -779,7 +771,6 @@ private static void CopyBufferToImage(IntPtr memoryHdc, Image image) imageGraphics.ReleaseHdc(imgHdc); } } -#endif #endregion } diff --git a/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj b/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj index 2e6c9dbf4..51aec7512 100644 --- a/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj +++ b/Source/HtmlRenderer.WinForms/HtmlRenderer.WinForms.csproj @@ -1,12 +1,11 @@  - net462 + net8.0-windows Library TheArtOfDev.HtmlRenderer.WinForms - publish\ true - false - true + true + true @@ -31,18 +30,7 @@ Features and Benefits: * Extendable and configurable. Multipurpose (UI Controls / Image generation), 100% managed (C#), High performance HTML Rendering library for WinForms. - - bin\Debug\ - AllRules.ruleset - - - bin\Release\ - AllRules.ruleset - - - Properties\SharedAssemblyInfo.cs - Component diff --git a/Source/HtmlRenderer.WinForms/HtmlToolTip.cs b/Source/HtmlRenderer.WinForms/HtmlToolTip.cs index 40d7ab6ca..2a82209bd 100644 --- a/Source/HtmlRenderer.WinForms/HtmlToolTip.cs +++ b/Source/HtmlRenderer.WinForms/HtmlToolTip.cs @@ -53,8 +53,6 @@ public class HtmlToolTip : ToolTip ///
private string _tooltipCssClass = "htmltooltip"; -#if !MONO - /// /// the control that the tooltip is currently showing on.
/// Used for link handling. @@ -79,7 +77,6 @@ public class HtmlToolTip : ToolTip /// if clicked the event will be raised although the tooltip will be closed. ///
private bool _allowLinksHandling = true; -#endif #endregion @@ -104,22 +101,18 @@ public HtmlToolTip() Draw += OnToolTipDraw; Disposed += OnToolTipDisposed; -#if !MONO _linkHandlingTimer = new Timer(); _linkHandlingTimer.Tick += OnLinkHandlingTimerTick; _linkHandlingTimer.Interval = 40; _htmlContainer.LinkClicked += OnLinkClicked; -#endif } -#if !MONO /// /// Raised when the user clicks on a link in the html.
/// Allows canceling the execution of the link. ///
public event EventHandler LinkClicked; -#endif /// /// Raised when an error occurred during html rendering.
@@ -181,6 +174,7 @@ public TextRenderingHint TextRenderingHint [Browsable(true)] [Description("Set base stylesheet to be used by html rendered in the tooltip.")] [Category("Appearance")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] [Editor("System.ComponentModel.Design.MultilineStringEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")] public virtual string BaseStylesheet { @@ -200,13 +194,13 @@ public virtual string BaseStylesheet [Browsable(true)] [Description("The CSS class used for tooltip html root div.")] [Category("Appearance")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public virtual string TooltipCssClass { get { return _tooltipCssClass; } set { _tooltipCssClass = value; } } -#if !MONO /// /// If to handle links in the tooltip (default: false).
/// When set to true the mouse pointer will change to hand when hovering over a tooltip and @@ -221,7 +215,6 @@ public virtual bool AllowLinksHandling get { return _allowLinksHandling; } set { _allowLinksHandling = value; } } -#endif /// /// Gets or sets the max size the tooltip. @@ -230,6 +223,7 @@ public virtual bool AllowLinksHandling [Browsable(true)] [Category("Layout")] [Description("Restrict the max size of the shown tooltip (0 is not restricted)")] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] public virtual Size MaximumSize { get { return Size.Round(_htmlContainer.MaxSize); } @@ -262,14 +256,12 @@ protected virtual void OnToolTipPopup(PopupEventArgs e) var desiredHeight = (int)Math.Ceiling(MaximumSize.Height > 0 ? Math.Min(_htmlContainer.ActualSize.Height, MaximumSize.Height) : _htmlContainer.ActualSize.Height); e.ToolTipSize = new Size(desiredWidth, desiredHeight); -#if !MONO // start mouse handle timer if (_allowLinksHandling) { _associatedControl = e.AssociatedControl; _linkHandlingTimer.Start(); } -#endif } /// @@ -277,7 +269,6 @@ protected virtual void OnToolTipPopup(PopupEventArgs e) /// protected virtual void OnToolTipDraw(DrawToolTipEventArgs e) { -#if !MONO if (_tooltipHandle == IntPtr.Zero) { // get the handle of the tooltip window using the graphics device context @@ -287,7 +278,6 @@ protected virtual void OnToolTipDraw(DrawToolTipEventArgs e) AdjustTooltipPosition(e.AssociatedControl, e.Bounds.Size); } -#endif e.Graphics.Clear(Color.White); e.Graphics.TextRenderingHint = _textRenderingHint; @@ -313,13 +303,10 @@ protected virtual void AdjustTooltipPosition(Control associatedControl, Size siz if (mousePos.Y + size.Height + yOffset > screenBounds.Bottom) mousePos.Y = Math.Max(screenBounds.Bottom - size.Height - yOffset - 3, screenBounds.Top + 2); -#if !MONO // move the tooltip window to new location Win32Utils.MoveWindow(_tooltipHandle, mousePos.X, mousePos.Y + yOffset, size.Width, size.Height, false); -#endif } -#if !MONO /// /// Propagate the LinkClicked event from root container. /// @@ -329,7 +316,6 @@ protected virtual void OnLinkClicked(HtmlLinkClickedEventArgs e) if (handler != null) handler(this, e); } -#endif /// /// Propagate the Render Error event from root container. @@ -361,7 +347,6 @@ protected virtual void OnImageLoad(HtmlImageLoadEventArgs e) handler(this, e); } -#if !MONO /// /// Raised on link handling timer tick, used for: /// 1. Know when the tooltip is hidden by checking the visibility of the tooltip window. @@ -407,7 +392,6 @@ protected virtual void OnLinkHandlingTimerTick(EventArgs e) OnRenderError(this, new HtmlRenderErrorEventArgs(HtmlRenderErrorType.General, "Error in link handling for tooltip", ex)); } } -#endif /// /// Unsubscribe from events and dispose of . @@ -427,7 +411,6 @@ protected virtual void OnToolTipDisposed(EventArgs e) _htmlContainer = null; } -#if !MONO if (_linkHandlingTimer != null) { _linkHandlingTimer.Dispose(); @@ -436,7 +419,6 @@ protected virtual void OnToolTipDisposed(EventArgs e) if (_htmlContainer != null) _htmlContainer.LinkClicked -= OnLinkClicked; } -#endif } @@ -466,7 +448,6 @@ private void OnImageLoad(object sender, HtmlImageLoadEventArgs e) OnImageLoad(e); } -#if !MONO private void OnLinkClicked(object sender, HtmlLinkClickedEventArgs e) { OnLinkClicked(e); @@ -475,7 +456,6 @@ private void OnLinkHandlingTimerTick(object sender, EventArgs e) { OnLinkHandlingTimerTick(e); } -#endif private void OnToolTipDisposed(object sender, EventArgs e) { diff --git a/Source/HtmlRenderer.WinForms/Utilities/Utils.cs b/Source/HtmlRenderer.WinForms/Utilities/Utils.cs index 9f25b6045..026102976 100644 --- a/Source/HtmlRenderer.WinForms/Utilities/Utils.cs +++ b/Source/HtmlRenderer.WinForms/Utilities/Utils.cs @@ -12,7 +12,6 @@ using System; using System.Drawing; -using System.Windows.Forms; using TheArtOfDev.HtmlRenderer.Adapters.Entities; namespace TheArtOfDev.HtmlRenderer.WinForms.Utilities @@ -120,26 +119,5 @@ public static Color Convert(RColor c) { return Color.FromArgb(c.A, c.R, c.G, c.B); } - - /// - /// mono has issue throwing exception for no reason. - /// - /// the control to create graphics object from - /// new graphics object or null in mono if failed - public static Graphics CreateGraphics(Control control) - { -#if MONO - try - { - return control.CreateGraphics(); - } - catch - { - return null; - } -#else - return control.CreateGraphics(); -#endif - } } } \ No newline at end of file diff --git a/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs b/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs index 33dddd53f..228e47658 100644 --- a/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs +++ b/Source/HtmlRenderer.WinForms/Utilities/Win32Utils.cs @@ -10,7 +10,6 @@ // - Sun Tsu, // "The Art of War" -#if !MONO using System; using System.Drawing; using System.Runtime.InteropServices; @@ -248,5 +247,4 @@ internal struct TextMetric public byte tmPitchAndFamily; public byte tmCharSet; } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/Source/HtmlRenderer.sln b/Source/HtmlRenderer.sln index 92aea3d46..c6594f4d7 100644 --- a/Source/HtmlRenderer.sln +++ b/Source/HtmlRenderer.sln @@ -1,23 +1,23 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 18 -VisualStudioVersion = 18.1.11312.151 d18.0 +VisualStudioVersion = 18.1.11312.151 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demo", "Demo", "{E263EA16-2E6A-4269-A319-AA2F97ADA8E1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.Demo.Common", "Demo\Common\HtmlRenderer.Demo.Common.csproj", "{2390B71F-9400-47F4-B23A-7F2649C87D35}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlRenderer.Demo.Common", "Demo\Common\HtmlRenderer.Demo.Common.csproj", "{2390B71F-9400-47F4-B23A-7F2649C87D35}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.Demo.WinForms", "Demo\WinForms\HtmlRenderer.Demo.WinForms.csproj", "{8AD34FE8-8382-4A8A-B3AA-A0392ED42423}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlRenderer.Demo.WinForms", "Demo\WinForms\HtmlRenderer.Demo.WinForms.csproj", "{8AD34FE8-8382-4A8A-B3AA-A0392ED42423}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.Demo.WPF", "Demo\WPF\HtmlRenderer.Demo.WPF.csproj", "{F02E0216-4AE3-474F-9381-FCB93411CDB0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlRenderer.Demo.WPF", "Demo\WPF\HtmlRenderer.Demo.WPF.csproj", "{F02E0216-4AE3-474F-9381-FCB93411CDB0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.WinForms", "HtmlRenderer.WinForms\HtmlRenderer.WinForms.csproj", "{1B058920-24B4-4140-8AE7-C8C6C38CA52D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlRenderer.WinForms", "HtmlRenderer.WinForms\HtmlRenderer.WinForms.csproj", "{1B058920-24B4-4140-8AE7-C8C6C38CA52D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.WPF", "HtmlRenderer.WPF\HtmlRenderer.WPF.csproj", "{7E4E8DB5-85AD-4388-BDCB-38C6F423B8B0}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlRenderer.WPF", "HtmlRenderer.WPF\HtmlRenderer.WPF.csproj", "{7E4E8DB5-85AD-4388-BDCB-38C6F423B8B0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer", "HtmlRenderer\HtmlRenderer.csproj", "{FE611685-391F-4E3E-B27E-D3150E51E49B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlRenderer", "HtmlRenderer\HtmlRenderer.csproj", "{FE611685-391F-4E3E-B27E-D3150E51E49B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlRenderer.PdfSharp", "HtmlRenderer.PdfSharp\HtmlRenderer.PdfSharp.csproj", "{CA249F5D-9285-40A6-B217-5889EF79FD7E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HtmlRenderer.PdfSharp", "HtmlRenderer.PdfSharp\HtmlRenderer.PdfSharp.csproj", "{CA249F5D-9285-40A6-B217-5889EF79FD7E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -108,4 +108,7 @@ Global {8AD34FE8-8382-4A8A-B3AA-A0392ED42423} = {E263EA16-2E6A-4269-A319-AA2F97ADA8E1} {F02E0216-4AE3-474F-9381-FCB93411CDB0} = {E263EA16-2E6A-4269-A319-AA2F97ADA8E1} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {902788D6-3165-491D-B860-DF2F74E66C1D} + EndGlobalSection EndGlobal diff --git a/Source/HtmlRenderer/HtmlRenderer.csproj b/Source/HtmlRenderer/HtmlRenderer.csproj index b8576e129..273dcccf8 100644 --- a/Source/HtmlRenderer/HtmlRenderer.csproj +++ b/Source/HtmlRenderer/HtmlRenderer.csproj @@ -1,34 +1,31 @@  - net462 + netstandard2.0;net8.0 Library TheArtOfDev.HtmlRenderer - false - true + true + true HtmlRenderer.Core HTML Renderer Core html render renderer draw core - Cross framework (WinForms/WPF/PDF/Metro/Mono/etc.), Multipurpose (UI Controls / Image generation / PDF generation / etc.), 100% managed (C#), High performance HTML Rendering library. + Cross framework (WinForms/WPF/PDF/Metro/etc.), Multipurpose (UI Controls / Image generation / PDF generation / etc.), 100% managed (C#), High performance HTML Rendering library. The Core assembly of HTML Renderer does not bound to any rendering framework (WinForms/WPF/PDF/etc.). Can be used to create framework specific renderer using adapter extensibility object model. For existing implementations see: HtmlRenderer.WinForms, HtmlRenderer.WPF and HtmlRenderer.PdfSharp. - Cross framework (WinForms/WPF/PDF/Metro/Mono/etc.), Multipurpose (UI Controls / Image generation / PDF generation / etc.), 100% managed (C#), High performance HTML Rendering library. + Cross framework (WinForms/WPF/PDF/Metro/etc.), Multipurpose (UI Controls / Image generation / PDF generation / etc.), 100% managed (C#), High performance HTML Rendering library. - - Properties\SharedAssemblyInfo.cs - - + \ No newline at end of file diff --git a/Source/SharedAssemblyInfo.cs b/Source/SharedAssemblyInfo.cs deleted file mode 100644 index 64944c19b..000000000 --- a/Source/SharedAssemblyInfo.cs +++ /dev/null @@ -1,29 +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")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Open source hosted on GitHub")] -[assembly: AssemblyProduct("HTML Renderer")] -[assembly: AssemblyCopyright("Copyright © 2008-2025")] -[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("ec8a9e7e-9a9d-43c3-aa97-f6f505b1d3ed")] - -// Version information for an assembly consists of the following four values: - -[assembly: AssemblyVersion("1.6.0.0")] \ No newline at end of file