berndgabriel / htmlviewer Goto Github PK
View Code? Open in Web Editor NEWThe well-known Delphi/Lazarus HtmlViewer/FrameViewer
License: Other
The well-known Delphi/Lazarus HtmlViewer/FrameViewer
License: Other
-------------------------------------------------------------------------------- Welcome to GitHub! -------------------------------------------------------------------------------- Developers might want to use Tortoise-GIT or "Git Gui" to keep their sources up-to-date. Or even become a member of GitHub, clone the repository and push their changes to their clone. If they are of public interest you can request me to pull it into my branch where it will become part of the "official" HtmlViewer. -------------------------------------------------------------------------------- HtmlViewer 11 -------------------------------------------------------------------------------- The current version is HtmlViewer 11.10 in the default branch "HtmlViewer-11.10". The next version is growing up in branch "master". The HtmlViewer component set consists of the THtmlViewer, TFrameViewer, and TFrameBrowser components. All three are HTML document display components: THtmlViewer - The basic component. - THtmlViewer displays single (non-frame) documents from file systems and resources. - It also forms the basis for the other two components. TFrameViewer - Displays both frame and single HTML documents. - TFrameViewer is oriented more for local file system use. TFrameBrowser - Also displays frame and single HTML documents. - TFrameBrower is oriented for use with local file systems and toward Internet style protocols and URL usage. - Additional code and/or components are generally required to get data from other sources than the local file system. We recommend using Indy or ICS components. These components support most of the HTML 4.01 specifications with many additional popular HTML 5 enhancements. Many Cascading Style Sheet properties are also supported. Some features: - Cascading Stylesheets - Large HTML files - HTML Frames - HTML Forms - HTML Tables - Bitmap, GIF, JPEG, and PNG Images - Transparent images - Image caching - Left and right floating images - Image sizing attributes - Client side image maps - Background colors and images - Font sizes, styles, and colors with HTML tags or default settings - Formatted printing of the HTML document - Can print multiple pages horizontally - Print preview - Text search - Copy to clipboard - Subscripts and superscripts - Unicode, UTF-8 and many single and multi byte character codes supported - DPI scaling - works with Delphi 2009 or newer, 32 and 64 Bit - works with Lazarus 1.2.x or newer, 32 and 64 Bit, for Windows and Linux While HTML documents are normally associated with the Internet, they are also very useful for displaying all kinds of textual material such as documentation, helpfiles, etc. Graphics are easily incorporated in these documents. For a detailed list and demonstration of features start FrameDem.exe and try some other demo programs. For a detailed list of changes and bugfixes per version start FrameDem.exe and click "What's new" or see "./Demos/Compiled Framedemo/whatsnew.htm". -------------------------------------------------------------------------------- HtmlViewer 11.x is available at: https://sourceforge.net/projects/htmlviewer/ HtmlViewer development is hosted at: https://github.com/BerndGabriel/HtmlViewer -------------------------------------------------------------------------------- If you try to use HtmlViewer 11 with no longer supported Delphi 6..2007 you will need the TntUnicodeControls 2.3.0 or 2.2.1, which are available at: http://www.yunqa.de/delphi/doku.php/products/tntunicodecontrols/index Please install them into your IDE. -------------------------------------------------------- Copyright (c) 1995 - 2008 by L. David Baldwin Copyright (c) 1995 - 2023 by Anders Melander (DitherUnit.pas) Copyright (c) 1995 - 2023 by Ron Collins (HtmlGif1.pas) Copyright (c) 2008 - 2009 by Sebastian Zierer (Delphi 2009 Port) Copyright (c) 2008 - 2010 by Arvid Winkelsdorf (Fixes) Copyright (c) 2009 - 2023 by HtmlViewer Team See included License.txt --------------------------------------------------------------------------------
Hi, the following are not display correctly:
ā ṭ “ ” ñ
shown as respectively below:
Ä á¹ â€œ â€� ñ
would be great if these problem are solved.
Thanks.
Brad.
THTMLViewer trying to install a component for Delphi 7
TntUnicodeControls 2.3.0 component installed successfully.
If you are installing THTViewer get an exception
"[Error] TntWideStrings.pas (353): Undeclared identifier: 'WideLoadResString'"
procedure TWideStrings.Error(Msg: PResStringRec; Data: Integer);
begin
Error(WideLoadResString(Msg), Data); --> here to crashes
end;
Regards
I've made changes to support Delphi 10 Seattle and created the packages.
Also made several improvements to the FrameBrowserUsingICSv7 demo to properly support http/1.1, better authentication and form posting. Sorry, another ICS contributor reformatted some units with the XE2 style formatter which makes merging almost impossible.
I've used Hithub in the past and found in tedious to submit changes and don't have the time to do so again, so all the changed files are at:
http://www.magsys.co.uk/download/software/htmlview-11.6-7-magsys.zip
Angus
I noticed that in earlier versions of the component images are displayed. I can not say what version since they are no longer displayed.
On the old site of the project was the ability to attach files, but not here. Therefore, the example file here: http://rghost.ru/private/8PWw7BRVt/78db4e13c1d0a3447c236873ede467dd
Hi there,
your htmlviewer is the perfect backoffice counterpart for webfrontends using ckeditor.
It renders all embedded images
img alt="" src="data:image/jpeg;base64,"...."
img alt="" src="data:image/png;base64,"...."
img src="data:image/bmp;base64,"...." alt=""
img src="data:image/gif;base64,"...." alt=""
But it fails on icons
img alt="" src="data:image/x-icon;base64,"...."
Would it be much work to implement them ?
rgds
Ralph
Lots of calculations done in DrawLogic methods are repeated in the Draw methods.
DrawLogic ought to be the method, that precalculates the entire layout and Draw should not re-evaluate a single coordinate, but draw, what DrawLogic has calculated. Only viewport calculations might be done in Draw.
Blocks should remember inner and outer rectangles relative to parent.
Texts should remember the lists of their LineRecs.
Hello,
I'm a new git on the block. ;-)
I'd like to know if you're working on a version of HtmlViewer for XE2?
I've managed to install the components in 32-bit mode, but the 64-bit compiler is complaining about a couple of asm-procedures.
In "DitherUnit.pas": ByteSwapColors
In "HtmlUn2.pas": StrLenW, StrPosW, StrRScanW and StrScanW
I don't know any assembler, or I would have translated them into pascal code myself. Do you know any Delphi procedures that can be used instead? Otherwise, when you have time I'd appreciate pascal versions of them, at least the ones in "HtmlUn2.pas" cause ByteSwapColors can be avoided by not defining PIXELFORMAT_TOO_SLOW.
Have a lovely day!
Thanks for reading. :-)
In letters sent to the tablet on Android with mail GMail application has the ability to send smoylikov as symbols. In your browser, the characters are displayed correctly in HtmlViewer displayed as squares. It is possible to do something will support these characters?
Test file: http://rghost.ru/private/6wTXFSgYD/f3b855929f7916d2de7bf727e7805508
HTMLViewer 11.5
The html code from the "attached" emails does not display correctly.
BoS - the images are loaded by my app but do not display
Becky - the disclaimer in light text should be at the bottom
Office - screwed - layout and images
Sorry about pasting the html into the text but its the only way I can find to get it to you. Attachments don't seem to work.
BECKY
<title>FW: Compare keyman cover</title><style type="text/css">body, #bodyTable { height:100% !important; width:100% !important; margin:0; padding:0; }table, td {border-collapse:collapse; }table, td {mso-table-lspace:0pt; mso-table-rspace:0pt;}img{-ms-interpolation-mode: bicubic; text-decoration:none; border:0 none; line-height:100%;}body, table, td, p, a, li, blockquote{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;}td img { display: block; }a.disable-link { pointer-events: none; cursor: default;}a.nav{color:#ffffff;}a.nav:hover {color:#7ac142;} .table {width:600px !important;max-width:600px !important;margin-left:auto !important;margin-right:auto !important;}@media only screen and (min-device-width : 768px) and (max-device-width : 1024px) {body[yahoo] .click {display: none !important; max-height: 0 !important;}body[yahoo] .tap:after {content:"tap";}@media screen and (max-device-width: 480px), screen and (max-width: 480px) {body[yahoo] body, body[yahoo] td, body[yahoo] p, body[yahoo] a, body[yahoo] li, body[yahoo] blockquote{-ms-text-size-adjust:110% !important; -webkit-text-size-adjust:110% !important;}body[yahoo] .click {display: none; display: none !important; max-height: 0 !important;}body[yahoo] .tap:after {content:"tap";}body[yahoo] .table {width:100% !important;max-width:100% !important;max-device-width:100% !important;}body[yahoo] td {width:100% !important;float:left !important;margin-left: 0px !important;margin-right: 0px !important;max-device-width:100% !important;max-width:100% !important;}body[yahoo] img {width:100% !important;height:auto !important;max-width:100% !important;max-device-width:100% !important;margin-bottom:0px !important;display:block !important;}body[yahoo] a[class="disable-link"] { pointer-events: auto !important; cursor: auto !important;}body[yahoo] .hideelement {display:none !important;}}</style>
|
BOS
<title>Bank of Scotland</title><style type="text/css"> table { border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; } body { margin:0 !important; padding:0 !important; }@media screen and (max-width: 720px) { /\* mobile-specific CSS styles go here _/img[class="logo"] { padding-left:20px !important; }.mobilehide {display:none !important; } table[class="contenttable"] { width:325px !important; }td[class="leftmargin"] { width:15px !Important; }td[class="rightmargin"] { width:10px !Important; }.mainwidth { width:300px !important; }.mainwidthcentre { width:300px !important; text-align:center !important; }.socialwidth { width:200px !important; margin-top:5px; margin-bottom:5px; margin-left:5px;}.socialwidth2 { width:90px !important; padding:3px;}.introwidth { width:275px !important; }.introwidthandmargin { width:275px !important; margin-bottom:20px;}.marginbottom {margin-bottom:10px;}td[class="anchorwidth"] { width:323px !Important;}.anchors {width:270px !important; padding-left:0px !important; font-size:15px !important; line-height:23px;}.anchorsbgcolor {background-color:##007f7b !important;}.anchorlineheight {line-height:17px !important;}.cta {width:250px !important;}.ctaandheight {width:275px !important; height:25px !important;}.buttonsize {width:125px !important; height:30px !important; font-size:14px !important;}.centre {text-align:center !important }.heightnone {height:1px !important; line-height:1px !important; font-size:1px !important;}.buttonsize {width:125px !important; height:30px !important; font-size:14px !important;}.buttonsize {width:125px !important; height:30px !important; font-size:14px !important;}</style>BUSINESS BANKING - Practical tools from the Business Bank of the Year. | Web version | Text Version |
|
OFFICE
<title>Acan Business Park</title><style type="text/css" media="screen">\* {line-height: inherit;}.ExternalClass \* { line-height: 100%; }body, p{margin:0; padding:0; margin-bottom:0; -webkit-text-size-adjust:none; -ms-text-size-adjust:none;} img{line-height:100%; outline:none; text-decoration:none; -ms-interpolation-mode: bicubic;} a img{border: none;} #backgroundTable {margin:0; padding:0; width:100% !important; } a, a:link, .no-detect-local a, .appleLinks a{color:#5555ff !important; text-decoration: underline;} .ExternalClass {display: block !important; width:100%;} .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div { line-height: inherit; } table td {border-collapse:collapse;mso-table-lspace: 0pt; mso-table-rspace: 0pt;} sup{position: relative; top: 4px; line-height:7px !important;font-size:11px !important;} .mobile_link a[href^="tel"], .mobile_link a[href^="sms"] {text-decoration: default; color: #5555ff !important; pointer-events: auto; cursor: default;} .no-detect a{text-decoration: none; color: #5555ff; pointer-events: auto; cursor: default;} {color: #5555ff;} span {color: inherit; border-bottom: none;} span:hover { background-color: transparent; }.nounderline {text-decoration: none !important;}h1, h2, h3 { margin:0; padding:0; }p {Margin: 0px !important; }table[class="email-root-wrapper"] { width: 600px !important; }body {}body { min-width: 280px; width: 100%;}td[class="pattern"] .c412p71r { width: 71.1864406779661%;}td[class="pattern"] .c167p28r { width: 28.813559322033896%;}</style><style>@media only screen and (min-width: 600px) { td[class="pattern"] .c412p71r { width: 412px !important;}td[class="pattern"] .c167p28r { width: 167px !important;}}@media only screen and (max-width: 599px),only screen and (max-device-width: 599px),only screen and (max-width: 400px),only screen and (max-device-width: 400px) { .email-root-wrapper { width: 100% !important; } table[class="email-root-wrapper"] { width: 100% !important; } td[class="wrap"] .full-width { width: 100% !important; height: auto !important;} td[class="wrap"] .fullwidthhalfleft {width:100% !important;} td[class="wrap"] .fullwidthhalfright {width:100% !important;} td[class="wrap"] .fullwidthhalfinner {width:100% !important; margin: 0 auto !important; float: none !important; margin-left: auto !important; margin-right: auto !important; clear:both !important; } td[class="wrap"] .hide { display:none !important; width:0px;height:0px; overflow:hidden; } td[class="pattern"] .c412p71r { width: 100% !important; }td[class="pattern"] .c167p28r { width: 100% !important; }}@media yahoo{table {table-layout:fixed;float: none !important;height:auto; }table[align="left"] {float:left !important; }td[align="left"] {float:left !important;height:auto; }table[align="center"] {margin:0 auto; }td[align="center"] {margin:0 auto;height:auto; }table[align="right"] {float:right !important; }td[align="right"] {float:right !important;height:auto; }}@media only screen and (max-width: 599px),only screen and (max-device-width: 599px),only screen and (max-width: 400px),only screen and (max-device-width: 400px){table[class=desktop-hide] { display: table !important; height: auto !important; max-height: 100% !important; width: 100% !important; line-height: auto !important;}}@media only screen and (min-width: 600px){\* [lang~='dHide']{ display:NONE!important; height:0; max-height:0; width:0; max-height:0; overflow:hidden; }}@media yahoo {table.desktop-hide { display: none !important; width: 0px !important; height:0px !important; }}</style><STYLE type="text/css" media="(pointer) and (min-color-index:0)">html, body {background-image: none !important; background-color: transparent !important; margin:0 !important; padding:0 !important;}</STYLE> Can't see this email..? Click here to view in your browser.
If you wish to unsubscribe, please click on the link below. Please note this is an automated operation. Click here to unsubscribe |
If you open this file www.Frigate3.com/download/html3.Zip in FrameDem.exe, it looks all right. However, if you view it in Print Preview, all images are lost except the first one.
The text files are not displayed correctly table elements. Sometimes the text is not completely visible. All files in the archive table is not displayed correctly.
Test files: http://rghost.ru/private/6gCzjZPjb/984e3ead39bd477d24069020a348f309
after this call
mfp := TMetaFilePrinter.Create(self);
html.PrintPreview(mfp);
the application crash.
i located the problem at
procedure ThtDocument.Clear;
... inherited Clear; //(self.Count = 1)
and
procedure TFreeList.Notify(Ptr: Pointer; Action: TListNotification);
as a workarround, this helps:
procedure TFreeList.Notify(Ptr: Pointer; Action: TListNotification);
begin
if (Action = lnDeleted) and FOwnsObjects then
if TObject(Ptr).ClassName <> 'TFreedObject' then
TObject(Ptr).Free;
end;
Reported by [email protected], Mar 13, 2015
Which steps will reproduce the problem?
What is the expected output? What do you see instead?
The printout should arrive, "Invalid Pointer Operation" Error
Which version of the product are you using? Which compiler version are you
using? On which operating system?
w8.1 - xe3 - THtmlViewer-115-r472
Please attach test html files and screenshots, if appropriate.
Please provide any additional information:
excuse me, i have bad english ...
The function "LoadFromString" is called with a string and the following access violation was reported:
exception class : EAccessViolation
exception message : Access violation at address 00408F08 in module 'Program.exe'. Read of address FFFFFFFD.
00408f08 +008 Program.exe System 15513 +1 TObject.Free
007fd493 +01f Program.exe StyleUn 3014 +2 TStyleList.Clear
008330ff +0eb Program.exe HTMLSubs 7104 +24 ThtDocument.Clear
00863cd9 +05d Program.exe HtmlView 4402 +8 THtmlViewer.InitLoad
0085cba9 +1e1 Program.exe HtmlView 1229 +56 THtmlViewer.LoadDocument
0085cf82 +036 Program.exe HtmlView 1297 +3 THtmlViewer.LoadString
0085c9b5 +009 Program.exe HtmlView 1156 +1 THtmlViewer.LoadFromString
When clicking a link, ParentForm.ActiveControl is changed to a some TabControl (currently I can't understand what it is). If URLAction is handled, the contents of HTMLViewer is changed (except for cases when the link is an anchor to the same page) and TabControl goes away, therefore ActiveControl becomes NIL what is unlikely a good thing.
Besides bad look it also leads to inconvenience when user cannot use mouse wheel immediately - he has to click a html view explicitly.
EDIT: the quick fix suggested was bad
Transparent GIF images are displayed with inverted colors and cause a memory leak.
The problem was introduced by check-in bc29d97 on 17.06.2015 21:59:15.
To reproduce, open the HTML below with in HtmlDemo.exe so it loads transparent.gif:
<html>
<head>
</head>
<body>
<img src=transparent.gif>
</body>
</html>
To solve, I propose the following patch below against 00056eb. It works well for me and HtmlViewer\Demos\Compiled Framedemo\sample3.htm shows no obvious side effects.
--- a/source/HtmlImages.pas
+++ b/source/HtmlImages.pas
@@ -633,7 +633,7 @@ begin
if Bitmap <> nil then
begin
//if Transparent = LLCorner then
- Mask := GetImageMask(Bitmap, False, 0);
+ // Yunqa.de removed: Mask := GetImageMask(Bitmap, False, 0);
Bitmap := ConvertImage(Bitmap);
Result := ThtBitmapImage.Create(Bitmap, Mask, Transparent);
end;
--- a/source/HTMLSubs.pas
+++ b/source/HTMLSubs.pas
@@ -2866,7 +2866,7 @@ begin
H := ObjHeight;
end;
try
- ddImage.Transp := Transparent;
+ // Yunqa removed: ddImage.Transp := Transparent;
if IsCopy then
ddImage.Print(Canvas, XX, Y, W, H, clWhite)
else
Ralf
THtmlViewer distorts the link containing the lang attribute:
The link:
it will be transformed in (the lang attribute disappears):
How to check:
1 . Create a HTML document with the contents:
<html> <body> <a href="http://egov.kz/wps/portal/Content?contentPath=%2Fegovcontent%2Femployment%2Femployment_relations%2Farticle%2Fholidays_calend&lang=ru ">Holidays 2013</a> </body> </html>
2 . Open this document through FrameDem.exe (Demos\Compiled Framedemo).
3 . Follow the link.
Reimplementation of the style cascading is required.
Especially the handling of properties "display", "float" and "position" needs some enhancements. Currently there are the specified values only.
In unicode version of Delphi to change the character case need to use functions AnsiLowerCase, AnsiUpperCase instead of LowerCase, UpperCase.
http://docwiki.embarcadero.com/Libraries/XE2/en/System.AnsiStrings.LowerCase
function htLowerCase(Str: ThtString): ThtString; begin {$ifdef UNICODE} // Result := LowerCase(Str); Result := AnsiLowerCase(Str); {$else} Result := Str; if Length(Result) > 0 then CharLowerBuffW(@Result[1], Length(Result)); {$endif} end;
function htUpperCase(Str: ThtString): ThtString; begin {$ifdef UNICODE} // Result := UpperCase(Str); Result := AnsiUpperCase(Str); {$else} Result := Str; if Length(Result) > 0 then CharUpperBuffW(@Result[1], Length(Result)); {$endif} end;
Copied from https://code.google.com/p/thtmlviewer/issues/detail?id=206 as the issue still exists
Which steps will reproduce the problem?
What is the expected output?
What do you see instead?
This problem does NOT appear when
Which version of the product are you using?
Which compiler version are you using?
On which operating system?
Declaration of type TPropDisplay is missing so it should either have UseOldStyleTypes defined or use ThtDisplayStyle and StyleTypes unit.
I have an HTML string, I load it in an THtmlViewer component, and then I click on the viewer with the mouse and I want to find the corresponding position in the HTML source. The code to find the source position should go something like this
// X and Y are the mouse coordinates:
DP := HtmlViewer1.XYToDisplayPos(X, Y);
// DP is an integer:
SP := HtmlViewer1.FindSourcePos(DP);
...and now SP should contain the index of the position in the source code.
However, when I look for the text in HtmlViewer1.DocumentSource near position SP, it's clearly the wrong place.
Then, after a lot of head scratching, I found that the correct position is SP div 2. If I divide the result of FindSourcePos by two, that is the correct result.
If this is a bug, it guess that it has something to do with the AnsiString vs. WideString format of the HTML source.
Hopefully this will be helpful to someone... cheers :)
In the letters came to me display elements which should not be visible. So file 1.htm display text that does not show any one browser. So the same text is displayed above and below the picture that should not be visible.
Test files: http://rghost.ru/private/7ldXMpQPc/0c30e175fe1807255ffe140b882531ad
Hello, the current html viewer displays tag <style> inside wrong. Here is an example:
www.Frigate3.com/download/html/ReWFP_Account.html
Is there any source of them ?? like BegaComboBox.pas
Whats with the DCC Fatal Error when installing on Delphi XE throung (FrameViewerXE.dpk)
[DCC Fatal Error] GDIPL2A.pas(124): F1026 File not found: 'GDIPUTIL.dcu'
A have problem with CSS styles . I don't know how to :hover TR in TABLE , parsing is ok but it dosent work .
As property "display" can switch an inline element to a block element and vice versa, the HtmlViewer's object structure, which divides the elements into TSection a block of text incl. inlined images and other TBlocks is obsolete.
In a revised object structure there should be no hard coded "display" property in the element objects. All objects should be able to be rendered with "display=inline", "display=block", ...
It is theoretically possible to embedd VCL-forms or -frames in HTML-code?
my idea is, to implement a tag like , which fire a event OnLoadEmbeddedForm. This Event returns the form-handle. The html-component show the form.
If NoGDIPlus is $defined, ac0777a makes JPG images transparent as if the TRANSP attribute was present.
In trying to fix this, I discovered a number of improvement possibilities in function LoadImageFromStream(). I have hence refactored the function slightly to
For testing, I have developed a collection of image files with HTML. Unfortunately GitHub does not allow attachments to issues. Please e-mail me so I can send you a copy.
Here is the code. Feel free to substitute:
function LoadImageFromStream(Stream: TStream; Transparent: TTransparency{; var AMask: TBitmap}): ThtImage;
// extracted from ThtDocument.GetTheBitmap(), ThtDocument.InsertImage(), and ThtDocument.ReplaceImage()
{$ifndef NoMetafile}
function LoadMetafileImage: ThtImage;
var
Meta: ThtMetaFile;
begin
Meta := ThtMetafile.Create;
try
Meta.LoadFromStream(Stream);
except
Meta.Free;
raise;
end;
Result := ThtMetafileImage.Create(Meta);
end;
{$endif NoMetafile}
{$ifndef NoGDIPlus}
function LoadGpImage: ThtImage;
var
Image: ThtGpImage;
begin
Result := nil;
if GDIPlusActive then
begin
Image := ThtGpImage.Create(Stream);
try
Result := ThtGdipImage.Create(Image);
except
Image.Free;
raise;
end;
end;
end;
{$endif !NoGDIPlus}
var
Bitmap, Mask: TBitmap;
function LoadGif: ThtImage;
var
Gif: TGifImage;
NonAnimated: Boolean;
begin
Gif := LoadGifFromStream(NonAnimated, Stream);
if NonAnimated then
begin {else already have animated GIF}
try
Bitmap := TBitmap.Create;
Bitmap.Assign(Gif.MaskedBitmap);
if Gif.IsTransparent then
begin
Mask := TBitmap.Create;
Mask.Assign(Gif.Mask);
Transparent := TrGif;
end;
finally
Gif.Free;
end;
Result := nil;
end
else
Result := ThtGifImage.Create(Gif);
end;
procedure LoadPng;
{$ifdef LCL}
var
pngImage: TPortableNetworkGraphic;
begin
pngImage := TPortableNetworkGraphic.Create;
try
pngImage.LoadFromStream(Stream);
if ColorBits <= 8 then
pngImage.PixelFormat := pf8bit
else
pngImage.PixelFormat := pf24bit;
Bitmap := TBitmap.Create;
Bitmap.Assign(pngImage);
pngImage.Mask(clDefault);
if pngImage.MaskHandleAllocated then
begin
Mask := TBitmap.Create;
Mask.LoadFromBitmapHandles(pngImage.MaskHandle, 0);
Transparent := TrPng;
end;
finally
pngImage.Free;
end;
{$else}
begin
{$endif}
end;
procedure LoadJpeg;
var
jpImage: TJpegImage;
begin
jpImage := TJpegImage.Create;
try
jpImage.LoadFromStream(Stream);
if ColorBits <= 8 then
begin
jpImage.PixelFormat := {$ifdef LCL} pf8bit {$else} jf8bit {$endif};
if not jpImage.GrayScale and (ColorBits = 8) then
jpImage.Palette := CopyPalette(ThePalette);
end
else
jpImage.PixelFormat := {$ifdef LCL} pf24bit {$else} jf24bit {$endif};
Bitmap := TBitmap.Create;
Bitmap.Assign(jpImage);
Transparent := NotTransp;
finally
jpImage.Free;
end;
end;
procedure LoadIco;
var
Icon: TIcon;
begin
Icon := TIcon.Create;
try
Icon.LoadFromStream(Stream);
Bitmap := TBitmap.Create;
Bitmap.Assign(Icon);
Transparent := LLCorner;
finally
Icon.Free;
end;
end;
procedure LoadBmp;
begin
Bitmap := TBitmap.Create;
Bitmap.LoadFromStream(Stream);
end;
var
ImageFormat: ThtImageFormat;
begin
Result := nil;
Stream.Position := 0;
ImageFormat := KindOfImage(Stream);
if ImageFormat = itNone then
Exit;
Mask := nil;
Bitmap := nil;
try
{$ifndef NoGDIPlus}
if not (ImageFormat in [itBmp, itIco, itGif]) then
try
Result := LoadGpImage;
except
// just continue without image...
end;
{$endif !NoGDIPlus}
if Result = nil then
case ImageFormat of
itIco,
itCur: LoadIco;
itGif: Result := LoadGif;
itPng: LoadPng;
itJpg: LoadJpeg;
itBmp: LoadBmp;
end;
if (Result = nil) and (Bitmap <> nil) then
begin
if Transparent = LLCorner then
Mask := GetImageMask(Bitmap, False, 0);
Bitmap := ConvertImage(Bitmap);
Result := ThtBitmapImage.Create(Bitmap, Mask, Transparent);
end;
except
Bitmap.Free;
Mask.Free;
FreeAndNil(Result);
end;
{$IFNDEF NoMetafile}
if Result = nil then
try
Result := LoadMetafileImage;
except
// just continue without image...
end;
{$ENDIF}
end;
I was testing THTMLViewer 11 with links and I found some incorrect behavior. If a color is not specified by a pseudo-class CSS element, the color reverts back to the THTMLViewer default color. This is incorrect if there is more than one pseudo-class involved with the element.
In the following HTML, I would expect the font-color for either the ":link" or ":visited" to appear instead of the default active link color. The only difference that should appear is that if you move the cursor over the link, the underline disappears and a 2-pixel dotted border should appear. A number of websites do this with CSS, mine included.
<title></title> <style type="text/css"> a:link { color: #800000; } a:visited { color: #4C0000; } a:active { color: #990000; } a:hover { border: 2px dotted; text-decoration: none; } </style>Click the link to go to http://www.jpetermugaas.com/.
#When will there be a delphi Xe8 package ?
Is this project for Windows only?
My compilation is stopping on InitFlatSB which makes a call to handle:=GetModuleHandle('comctrl32.dll');
?
There's memory leak caused by StyleUn.PropertyStrings object never gets destroyed.
Implement IFRAME support.
Hello,
I need some attributes from a form control and there was in version 9.41 the property AttributeValue in TFormControlObj, like this :
TFormControlObj(FormControlList[i]).AttributeValue['style']
Is there a way to access it ?
Thank you
Frederic
I am unable to fully install Htmlviewer version 11 on my Windows 10 64-bit machine. I am able to compile the DPK file after correcting syntax errors on the content of the DPK file. Errors are
Contains 'C'
There are duplicate-named classes in the sources:
THtmlParser --> in HtmlParser.pas and ReadHTML.pas
THtmlStyleParser --> StyleParser.pas and StylePars.pas
These classes, even though they share names, are distinct classes.
Is this an oversight, or are they artifacts of ongoing refactoring?
If a webpage has a graphic or line or table that extends to the right beyond the viewport/window boundary then all the following text also uses that new extended boundary. IE doesn't do this. In IE even if a graphic or line or table extends beyond the right margin the text above and below is wrapped to the window dimensions.
This is critical for viewing and printing emails. It is a little thing if a graphic is mis-sized beyond the margin and prints on two pages. Same with tables, not a big deal if it prints on a second page. However with HTMLViewer all following text then will wrap across two pages also. IE is more pragmatic and wraps the text to window dimensions and wraps to paper dimensions. I hacked htmlviewer and just ignored the width specification on h elements and now it automatically adjusts to window width. I am researching if I can do the same thing with graphics with a width gt 500px.
Unicode Character ⁴, ⁵, ⁶, ⁷. ⁸ ⁹ appear as square boxes. There may be others as well. I am loading from a string and the other Unicode characters from the string appear correctly.
Hi,
First, of all, a big thnk you for this component, as I was looking for an HTML parser and now I found one. I just thought you might be interested in knowing how developers will use it and receive some feedback/suggestions on it.
I'm just interested in a component that can take some HTML text and render it on a canvas. Therefore, your component is much more powerful than my needs and I'm in the process of removing all the unecessary code (e.g. I need to be able to draw text with formatting, have images embedded but I don't need sounds, scripts, form controls, events). While doing this, I got to learn about the structure of your objects and would like to suggest the following:
I understand that in version 12, you are planning some in depth internal changes so this might be what you are planning already. This is my humble suggestion:
You could have 4 main core objects (and my suggestion mainly focuses here on number 2 and 3):
1- The parser: the one that takes an HTML file and fragments it into HTML tokens.
2- The renderer on a canvas: I would see this one as being the object that only handles graphical tokens (e.g. text formatting, lines, images, etc.) and it is a descendant of TObject and simply drawns on a provided canvas within a provided Rect (e.g. Procedure DrawHTML(aCanvas : TCanvas; aRect : TRect)). This can thus be used in places where a software only needs powerful drawing of formatted texts but no need for all the overheads associated with the more powerful HTML features (my case to be honest).
3- The renderer of full HTML features on a control: This is a descendant of the canvas renderer in point 2. It also handles creation of all form controls, sounds, events, etc. hance needs to render on a control (i.e. is kind of THTMLViewer but with a large part of the processing done by point number 2 moved to that component)
4- The HTMLViewer control: a control that can be placed on a form to display an HTML text.
I think this architecture would allow you to see your components used in many more applications, you might for example be aware of TMS Software for example where they have many numerous HTML renderers (ridiculous number actually). Using their components + yours could add 1 MB of exe size for codes aiming at doing the same thing. If you implemented my suggestion and manage to impose yourself as the HTML renderer standard in Delphi (as you could easily, your component is so nice), your code could be used by them and others, helping maintenance and code size.
Various other suggestions:
TMyClass = Class(TMyAncestor)
Public
XXX : TXXXType;
...
End
to be replaced by:
TMyClass = Class(TMyAncestor)
Private
FXXX : TXXXType;
Public
...
Property XXX : TMyXXXType Read FXXX Write FXXX;
End
Also, it is common practice to call all private variables with an "F" prefix.
All of these contribute to users being able to concentration on code meaning rather than syntax. As you clearly are focused on open source for other to use, that would bring a big benefit to the community.
Hello,
In my program I build a html-page in a string variable and then use LoadFromString() to load it in a THtmlViewer object. Previously I've been able to use the property DocumentSource to save the created page as a textfile for debug purposes. But now I get an empty file, or perhaps two random characters.
This is the code I use to save the page:
SourceList := TStringList.Create;
try
SourceList.Text := html.DocumentSource;
SourceList.SaveToFile(ChangeFileExt(Application.ExeName, '.log'));
finally
SourceList.Free;
end;
I've been using the master branch of HtmlViewer with XE2 and XE3. Today I also tried the latest HtmlViewer 11 with same result. The latest downloaded source code I have that work is from July 21th 2012.
Do you have any idea what can be wrong ? Is there perhaps a better way to save the html source of a page ?
Best Regards
Is the branch called HtmlViewer2 meant to be 12 instead of 2 ?
Previously I've been using the master branch for my projects and I assume it will be updated with stable changes. Or is it better to use one of the other branches ?
Best Regards
I suggest to add flexibility to the history system. Now it deals with local files only what seems very strange to me. I suppose it should be customizable via events to allow loading urls or even any custom stuff (currently I use THV for my help system with pseudo-urls looking like "help:Topic_Name").
I'll create pull request with quick workaround a little later.
My error message in http://code.google.com/p/thtmlviewer/issues/detail?id=63 and http://code.google.com/p/thtmlviewer/issues/detail?id=77 corrected, and here the error is not corrected.
Currently the combinator characters '+' (CSS2.1) and '*', '~' (CSS3) stop parsing the selector and assign the style to the style read up to now skipping the rest of the selectors before next '{'.
In case of "body ul+li {...}" the style is assigned to "body ul", which is definitely wrong.
Now these styles are skipped until they are processed correctly, which is subject of this issue.
The enumerated type named 'THtmlElementSymbol' (in 'HtmlSymbols.pas') and 'Symb' (in HTMLUn2.pas) are (or should have been) the same --i.e. one or the other is redundant.
But, when compared to 'Symb', 'THtmlElementSymbol' is missing these words.
ABBR
ACRONYM
APPLET
BDO
DEL
DFN
EMBED
H1
H2
H3
H4
H5
H6
INS
NOEMBED
NOSCRIPT
OPTGROUP
Q
And, when compared to 'THtmlElementSymbol', 'Symb' is missing these words.
ARTICLE
ASIDE
FOOTER
H
HEADER
HGROUP
MARK
NAV
SECTION
IOW, both are incomplete.
[When I say "incomplete", I don't mean to imply that I have checked them against any given HTML version. They are incomplete when compared with another --i.e. some words are missing in one, while others are missing from the other one.]
And.. did I mention that 'Symb' was a lousy choice for enumerated type :)
Currently drawing background images is implemented for table cells only.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.