NRichTextView not saving inserted hyperlinks to RTF string


https://www.nevron.com/Forum/Topic12823.aspx
Print Topic | Close Window

By Tom Galczynski - 2 Years Ago
Hello. I'm using the NRichTextView control and am trying to insert a hyperlink into my document and saved it to RTF.  The hyperlink is fine (shows up as a link) in my document, but when I save it to rtf string/file, the link is lost. I've attached the resulting rtf file which in the control was just two lines "test text" and "test link" which the latter was a hyperlink to www.asdsoftware.com.  After saving to RTF the hyperlink is gone.

Previously I posted about an issue with saving tables to RTF and you resolved that by having me add document.Evaluate() prior to my call to SaveToStream. Maybe there is something similar to fix this?

Thanks!


By Nevron Support - 2 Years Ago
Hi Tom,
This looks like a problem with the control which we'll be looking to address in the upcoming 2019 release we're about to launch next month. It currently works in HTML and DOCX export formats only. We also want to include PDF and RTF to that list.
By Tom Galczynski - 2 Years Ago
Hi.  Just checking if there has been any update on this issue?:

"...we'll be looking to address in the upcoming 2019 release we're about to launch next month..."

Has this been released yet?

Thanks!
Tom Galczynski
By Tom Galczynski - 2 Years Ago
Hello.  Has this been resolved in a new release?  If so can you provide a link?

Thanks very much.
By Nevron Support - 2 Years Ago
Hi Tom,
We've resolved the issue with the PDF export and will try to fix the RTF export as well for the upcoming release which should happen very soon. We've made many improvements in the text control especially in the way tables are edited.
By Nevron Support - 2 Years Ago
Hi Tom,

Just a short note the RTF Hyperlink export is implemented in the upcoming release...
By Tom Galczynski - 2 Years Ago
Thanks.  Do you have an ETA for the release that fixes the rtf/link issue?
Also, I am having a problem using html format to send an email message.  Using the control, I am adding a line of text with a hyperlink and saving it to the Body of a MailMessage object.  The html code generated by the control is this:
<!DOCTYPE html><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><br><html><br><head><br><br><style type="text/css"><br>.n1 {text-align:left;direction:ltr;vertical-align:top;border-collapse:separate;border-spacing:0 0;font:normal normal 10pt/1 'Arial',sans-serif;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;}<br>.n4 {color:#000000;text-decoration:none;}<br>.n5 {visibility:visible;border:none;}<br>.n11 {margin:0;}<br>.n19 {margin:8px 0;}<br>.n20 {font:normal normal 10pt/normal 'Arial',sans-serif;}<br>.n21 {color:#0000ff;text-decoration:underline;}<br><br></style><br></head><br><body class="n1 n4 n5 n11"><br><section class="n1 n4 n5 n11"><br><p class="n1 n4 n5 n19"><br><span class="n4 n5 n20">This message has a hyperlink </span><a href="http://www.asdsoftware.com" target="_self" class="n5 n20 n21">here</a><span class="n4 n5 n20">.</span><br></p><br></section><br></body><br></html><br>

When I receive the message in Outlook, it looks like this:
https://www.nevron.com/forum/uploads/images/1acbffaa-41b2-4a94-ad1c-172a.png
If I save the html source to a file and open in a browser it shows the text and hyperlink ok but with a number of blank lines beforehand.  Can you see anything in the html code that may be causing this? Maybe there is some control setting I need to use so that those formatting lines don't appear???  Thanks for all your help!

By Nevron Support - 2 Years Ago
Hello,

We would like to inform you that Nevron Open Vision 2019.1 is now live. For more information about the new features and improvements in this release, please visit:
https://www.nevron.com/company-news-and-events.aspx

Regarding the issue with the HTML in Outlook, maybe Outlook does not support CSS classes properly. Please instruct the NOV rich text control to inline the CSS styles into the HTML tags. For an example, check out the following documentation topic (see the last code example):
NOV Rich Text - HTML Import and Export
By Tom Galczynski - 2 Years Ago
Thanks for the inline CSS tip.  We are getting closer!  However there seems to be persistent blank lines at the top of the message and I am not sure what is causing it.  Here is a picture of what it looks like now followed by the html string:
https://www.nevron.com/forum/uploads/images/365b32d3-91ce-4bbf-9769-67ea.png
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;margin:0;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;">
<section style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;margin:0;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;">
<p style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;margin:8px 0;">
<span style="color:#000000;visibility:visible;border:none;text-decoration:none;font:normal normal 10pt/normal 'Arial',sans-serif;">This is a test of hyperlink </span><a href="http://www.asdsoftware.com" target="_self" style="visibility:visible;border:none;font:normal normal 10pt/normal 'Arial',sans-serif;color:#0000ff;text-decoration:underline;">here</a><span style="color:#000000;visibility:visible;border:none;text-decoration:none;font:normal normal 10pt/normal 'Arial',sans-serif;">.</span>
</p>
</section>
</body>
</html>

Is there some other save setting perhaps I can try to eliminate those blank lines?  The html code opened up in a browser and also in the Nevron control doesn't show those blank lines at all so I'm thinking it is due to some auto-formatting aspect perhaps???

Thanks so much for your help!
By Nevron Support - 2 Years Ago
Hello,

We created an HTML file with your HTML code and it works fine in all browsers, including Internet Explorer 11 as shown below:
https://www.nevron.com/forum/uploads/images/c4e8d12c-94ad-4675-98ef-8fb7.png
Maybe Outlook centers the content vertically and that is why it looks like on your screenshot. You can test this by adding a border to the paragraph element. You can do this either in the original document or in the style attribute of the p tag by replacing "border: none " with "border:2px solid red;".
By Tom Galczynski - 2 Years Ago
Hi.  I tried your suggestion and the email message displays the same way, with a border around the text.  And it's not just Outlook. Thunderbird also shows the text the same way, with several blank lines first.  Very strange.

Thanks for your help!
By Nevron Support - 2 Years Ago
Hello,

Maybe the email clients you are testing with just center the content of the message vertically. Can you please try to send the email to an email address in GMAIL and see how it looks there?
By Tom Galczynski - 2 Years Ago
Hi.  I sent the message to my gmail account, opened it on my phone, here is the screenshot:

https://www.nevron.com/forum/uploads/images/0e98e882-e795-417b-938b-58c7.png
By Nevron Support - 2 Years Ago
Hello,

Does it look like this (i.e. with a lot of empty lines) on your computer in a desktop browser? If yes, please save the text document to NTX and send it to us for evaluation. Please also send us the HTML that you send as an email.

Thank you!
By Tom Galczynski - 2 Years Ago
Hello, no when I save the html to a file it looks fine in any browser, just like it does in the control. I am guessing there is some aspect of the body, section or paragraph style that the email readers can't handle?
Thanks!
By Nevron Support - 2 Years Ago
Hello,

Maybe the email clients have some non-standard default CSS values and they change the way the generated HTML looks. Please try applying a CSS reset. A simple CSS reset file is attached to this message. You can include it in a "<style></style>" element in the "<head>" element of the generated HTML. Please try this and let us know if it fixes the issue.
By Tom Galczynski - 2 Years Ago
Hi.  I took the reset.css code and added it to my html before adding to the MailMessage body. The result is what you see in the file emailreset2output.txt.  Then I took a look at the source after the message was displayed in Outlook. The result is what you see in the file emailreset2source.txt.  As you can see, Outlook (and also Gmail, Thunderbird) adds several "<br>" commands throughout which probably is what accounts for the blank lines.  Not sure if there is anything we can do about that?
By Nevron Support - 2 Years Ago
Hello,

Thank you for the HTML files. You are correct. The <br> elements are causing the blank new lines. You don't need the CSS reset, so just add the following CSS in a <style> element in the <head> element:

br {
    display: none;
}

p br {
    display: inline;
}


This CSS will hide all <br> elements that are not in a paragraph.
By Tom Galczynski - 2 Years Ago
In both Gmail and Outlook the blanks persist.  In Thunderbird though, that took care of it.  I've attached the source from Outlook in emailblankssource.txt.  Thanks for your help.
By Nevron Support - Last Year
Hi Tom and Happy New Year 2020!

Outlook uses the Microsoft Word HTML engine. It's far from perfect and does not support all CSS properties, so maybe that's why you get an incorrect rendering in Outlook. Please try using only the first CSS declaration:

br {
  display: none;
}


By Tom Galczynski - Last Year
Hi there.  Tried your suggestion and the Outlook issue persists. :-(  Here is the output from the control:

<!DOCTYPE html> <html> <head><style> br { display: none; } </style> <meta charset="utf-8" /> </head> <body style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;margin:0;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;"> <section style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;margin:0;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;">  <p style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;margin:8px 0;">  <span style="color:#000000;visibility:visible;border:none;text-decoration:none;font:normal normal 10pt/normal 'Arial',sans-serif;">This is the body text.</span>  </p> </section> </body> </html> 

Here is the source from Outlook:
<!DOCTYPE html><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><br><html><br><head><style> br { display: none; } </style><br><br></head><br><body style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;margin:0;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;"><br><section style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;margin:0;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;"><br><p style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;margin:8px 0;"><br><span style="color:#000000;visibility:visible;border:none;text-decoration:none;font:normal normal 10pt/normal 'Arial',sans-serif;">This is the body text.</span><br></p><br></section><br></body><br></html><br>

Thanks for your help and Happy New Year :-)
By Nevron Support - Last Year
Hello,

We did some additional research and it appears that Outlook has only partial support for the CSS "display" property. Please try the following CSS and let us know if it fixes the Outlook issues:

br {
  display: none;
  font-size: 0;
  max-height: 0;
  line-height: 0;
  mso-hide: all;
}

By Tom Galczynski - Last Year
I really appreciate you guys looking into this.  Thanks!  Unfortunately this did not change the appearance.  Outlook (and Gmail) show blank lines before the body text.  Thunderbird does not.  Here is the output from the control:

<!DOCTYPE html> <html> <head><style> br { display: none; font-size: 0; max-height: 0; line-height: 0; mso-hide: all;} </style> <meta charset="utf-8" /> </head> <body style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;margin:0;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;"> <section style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;margin:0;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;">  <p style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;margin:8px 0;">  <span style="color:#000000;visibility:visible;border:none;text-decoration:none;font:normal normal 10pt/normal 'Arial',sans-serif;">This is the first line of the body of the email.</span>  </p> </section> </body> </html>

And here is the "view source" from Outlook:
<!DOCTYPE html><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"><br><html><br><head><style> br { display: none; font-size: 0; max-height: 0; line-height: 0; mso-hide: all;} </style><br><br></head><br><body style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;margin:0;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;"><br><section style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;margin:0;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;"><br><p style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;margin:8px 0;"><br><span style="color:#000000;visibility:visible;border:none;text-decoration:none;font:normal normal 10pt/normal 'Arial',sans-serif;">This is the first line of the body of the email.</span><br></p><br></section><br></body><br></html><br>


By Nevron Support - Last Year
Hi Tom. Here's one more idea for you to try: please remove all new lines from the HTML code generated by the NOV Rich Text View before sending the email. Thus the HTML will be on a single line and Outlook should not add all these <br> elements. You can use the following line of code to remove the new lines from the HTML string:

htmlCode = htmlCode.Replace(Environment.NewLine, String.Empty);


Please try this and let us know if it fixed the issue with Outlook.
By Tom Galczynski - Last Year
Bingo! That seems to have done it. Here is the html from the control:
<!DOCTYPE html><html> <head> <meta charset="utf-8" /> </head> <body style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;margin:0;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;"> <section style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;margin:0;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;"> <p style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;margin:8px 0;">  <span style="color:#000000;visibility:visible;border:none;text-decoration:none;font:normal normal 10pt/normal 'Arial',sans-serif;">First line.</span> </p> <p style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;margin:8px 0;">  <span style="color:#000000;visibility:visible;border:none;text-decoration:none;font:normal normal 10pt/normal 'Arial',sans-serif;">Second line.</span> </p> </section> </body></html>

And here is "view source" from Outlook:
<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;margin:0;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;"><section style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;margin:0;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;"><p style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;margin:8px 0;"><span style="color:#000000;visibility:visible;border:none;text-decoration:none;font:normal normal 10pt/normal 'Arial',sans-serif;">First line.</span></p><p style="text-align:left;direction:ltr;vertical-align:top;color:#000000;visibility:visible;border-collapse:separate;border-spacing:0 0;border:none;font:normal normal 10pt/1 'Arial',sans-serif;text-decoration:none;padding:0;clear:none;float:none;text-indent:0;page-break-before:auto;page-break-after:auto;position:static;margin:8px 0;"><span style="color:#000000;visibility:visible;border:none;text-decoration:none;font:normal normal 10pt/normal 'Arial',sans-serif;">Second line.</span></p></section></body></html>

Also looks fine in Gmail and Thunderbird.  Thanks very much! :-)
By Nevron Support - Last Year
That's great. You can also remove the <style> element from the <head> element of the document. It shouldn't be necessary anymore.