I am looking to make changes to HTML text within a UITextView. The original text was created using an HTML editor in the web version of the app and needs to be edited with a default font on iOS.
Here is the simple HTML code for the text that needs editing:
<p><b>html</b> <u>html</u> <i>html</i></p>
After editing, when I retrieve the HTML text from UITextView, it comes back with additional CSS styles like this:
NSDictionary *exportParams = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType};
NSData *htmlData = [_txtDescricao.attributedText dataFromRange:NSMakeRange(0, _txtDescricao.attributedText.length) documentAttributes:exportParams error:nil];
NSString *descHtml = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];
The HTML text is returned with CSS styling as shown below:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 16.0px 'Helvetica Neue'; color: #000000; -webkit-text-stroke: #000000}
span.s1 {font-family: 'Helvetica Neue'; font-weight: bold; font-style: normal; font-size: 16.00pt; font-kerning: none}
span.s2 {font-family: 'Helvetica Neue'; font-weight: normal; font-style: normal; font-size: 16.00pt; font-kerning: none}
span.s3 {font-family: 'Helvetica Neue'; font-weight: normal; font-style: normal; font-size: 16.00pt; text-decoration: underline ; font-kerning: none}
span.s4 {font-family: 'Helvetica Neue'; font-weight: normal; font-style: italic; font-size: 16.00pt; font-kerning: none}
</style>
</head>
<body>
<p class="p1"><span class="s1">html</span><span class="s2"> </span><span class="s3">html</span><span class="s2"> </span><span class="s4">html</span></p>
</body>
</html>
I need help getting the HTML text from UITextView without any CSS formatting. I require the simplified HTML format so that I can also edit the same text in the Android version of the app, where EditText does not support CSS formatted HTML.
If anyone could assist me in obtaining the HTML text in UITextView without CSS, I would greatly appreciate it.
Thank you.