delphi - MSHTML PasteHTML() produces   -


we use in delphi standard twebbrowser component, uses mshtml.dll internally. additionaly use registry ensure pages renders new rendering engine (web-browser-control-specifying-the-ie-version, msdn: feature_browser_emulation). use rendering of ie 10 have same results ie 8 ie 11.

using standard rendering machine of mshtml (ie7) works right, due new rendering options need new rendering of mshtml.

we use design mode of control enabled user make changes in documents:

var   mdocument: ihtmldocument2; begin   mdocument := ((asender twebbrowser).document ihtmldocument2);   mdocument.designmode := 'on'; 

now have following problem: when use ihtmltxtrange.pastehtml(...) insert html code, of spaces replaced  

procedure tform1.bt_pastehtmlclick(sender: tobject); var   mdoc2: ihtmldocument2;   movsel:ihtmlselectionobject;   mrange: ihtmltxtrange;   mhtml: string; begin   /// reproduzierbarer fehler bei pastehtml   ///  leere zellen und falsche umbrüche.   mdoc2 := wb_test.document ihtmldocument2;    movsel := mdoc2.selection ihtmlselectionobject;   mrange := movsel.createrange() ihtmltxtrange;    mhtml := '<table width="100%" border="1" cellspacing="0" cellpadding="0">  <tbody>  <tr>    <td>falsche zellen werden erstellt, wo nur diese eine sein sollte!</td></tr></tbody></table>' + slinebreak +            '<p>falsche umbrueche '  + slinebreak +             'wo keine sein sollten  durch crlf im html-code!</p>' + slinebreak;   mrange.pastehtml(mhtml); end; 

looking @ inserted code, spaces between table, tbody, tr , td tags have been converted &nbsp;. wrongly inserted html code is:

<table width="100%" border="1" cellspacing="0" cellpadding="0">&nbsp;    <tbody>&nbsp;    <tr>&nbsp;&nbsp;&nbsp;      <td>falsche zellen werden erstellt, wo nur diese eine sein    sollte!</td></tr></tbody></table><br> <p>falsche umbrueche <br>wo keine sein sollten&nbsp; durch crlf im  html-code!</p> 

edit: start following html:

<html>   <body>   </body> </html> 

and after inserting:

<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html><head> <meta http-equiv="content-type" content="text/html; charset=windows-1252"> <meta name="generator" content="mshtml 10.00.9200.16540"></head> <body>  <table border="1" cellspacing="0" cellpadding="0">   <tbody>   <tr>     <td>tabelle mit<br>einem text!</td></tr></tbody></table><br> <p>falsche umbrüche durch zu viele&nbsp; leerzeichen</p></body></html> 

this may design. conform html specifications, whitespace in html code should treated single instance of whitespace (except inside <pre> tags). provide word separation when type 2 or more spaces in design mode, ie inserts &nbsp; html entities instead.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -