After converting my RTF to HTML by using Aspose it give me like this.
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http-equiv="Content-Style-Type" content="text/css" /><meta name="generator" content="Aspose.Words for .NET 20.3" /><title></title></head><body><div><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">INDICATIONS:</span><span style="width:21.67pt; display:inline-block; -aw-tabstop-align:left; -aw-tabstop-pos:90pt"></span><span style="font-family:Arial; color:#ffffff">\</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">INDICATIONS:</span><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:spaces"> </span><span style="font-family:Arial; font-weight:bold; color:#ffffff">\</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">INDICATIONS:</span><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:spaces"> </span><span style="font-family:Arial; font-weight:bold; color:#ffffff">\</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">CLINICAL HISTORY:</span><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:spaces"> </span><span style="font-family:Arial; font-weight:bold; color:#ffffff">\</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">RAD 0002 - BARIUM ENEMA - SINGLE</span><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:spaces"> </span><span style="font-family:Arial; font-weight:bold; color:#ffffff">- Jan 21 2011</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">INDICATIONS:</span><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:spaces"> </span><span style="font-family:Arial; font-weight:bold; color:#ffffff">\</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">RESULT:</span><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:spaces"> </span><span style="font-family:Arial; font-weight:bold; color:#ffffff">This was REMERGED in TRD after Al Tiemann's fix.</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">Patient Name is Jan21e</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">DOB - April 5, 1945</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">Acc 184808</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">Proc Date - Jan 21, 2011 at 3:58pm</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">Proc is Barium Enema -Single</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">\</span><span style="width:87.22pt; display:inline-block; -aw-tabstop-align:left; -aw-tabstop-pos:90pt"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">IMPRESSION:</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">This is Jan21E's first procedure</span><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:spaces"> </span><span style="font-family:Arial; font-weight:bold; color:#ffffff">orig with bad result shell.</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">Jan21b is being added to SR while this is being edited in this is dictated on January 22.</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">This is going to be sedated and signed off while a procedure and tear and he is sent</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">\</span><span style="width:87.22pt; display:inline-block; -aw-tabstop-align:left; -aw-tabstop-pos:90pt"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:11pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:11pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:11pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:11pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p></div></body></html>
BUT i need like this HTML.
<html>
<head>
<title></title>
<meta name="GENERATOR" content="Siemens syngoWorkflow">
</head>
<BODY BGCOLOR="#FFFFFF"><font FACE="Arial" SIZE="2" ><font COLOR="#ffffff"><br> </font><font FACE="Arial" SIZE="2" COLOR="#ffffff" ><b> INDICATIONS:</b> \<br> </font><font FACE="Arial" SIZE="2" COLOR="#ffffff" ><br> </font><b><font FACE="Arial" SIZE="2" COLOR="#ffffff" >INDICATIONS: \<br> <br> INDICATIONS: \<br> <br> CLINICAL HISTORY: \<br> <br> RAD 0002 - BARIUM ENEMA - SINGLE - Jan 21 2011<br> INDICATIONS: \<br> <br> RESULT: This was REMERGED in TRD after Al Tiemann's fix.<br> Patient Name is Jan21e<br> DOB - April 5, 1945<br> Acc 184808<br> Proc Date - Jan 21, 2011 at 3:58pm<br> Proc is Barium Enema -Single<br> \<br> <br> <b>IMPRESSION:<br> This is Jan21E's first procedure orig with bad result shell.<br> Jan21b is being added to SR while this is being edited in this is dictated on January 22.<br> This is going to be sedated and signed off while a procedure and tear and he is sent<br> </b><br> <font SIZE="3"><br> </font></b></b><font FACE="Arial" SIZE="3" COLOR="#ffffff" ><br> <br> <font SIZE="2"><br> <br> </font><font SIZE="3" FACE="Arial" COLOR="#ffffff" >
<br>
</font>
</font></font></font>
</body>
</html>
Unfortunately, your question isn’t clear enough; therefore we request you to please elaborate your inquiry further by providing complete details about the problem (with the help of screenshots). This will help us to understand your problem, and we will be in a better position to address your concerns accordingly.
Do you want Aspose.Words to generate a well formatted (human readable) HTML markup? If yes, then please try the following code:
Document document = new Document("C:\\Temp\\input.rtf");
Aspose.Words.Saving.HtmlSaveOptions htmlSaveOptions = new Aspose.Words.Saving.HtmlSaveOptions(SaveFormat.Html);
htmlSaveOptions.PrettyFormat = true;
document.Save("C:\\Temp\\21.1.html", htmlSaveOptions);
There are many properties in HtmlSaveOptions Class (e.g. CssStyleSheetType property) that will help you to generate a neat HTML.
I am coverting RTF to HTML using ASPOSE.After conversion Aspose ive me like this.
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http-equiv="Content-Style-Type" content="text/css" /><meta name="generator" content="Aspose.Words for .NET 20.3" /><title></title></head><body><div><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">INDICATIONS:</span><span style="width:21.67pt; display:inline-block; -aw-tabstop-align:left; -aw-tabstop-pos:90pt"></span><span style="font-family:Arial; color:#ffffff">\</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">INDICATIONS:</span><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:spaces"> </span><span style="font-family:Arial; font-weight:bold; color:#ffffff">\</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">INDICATIONS:</span><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:spaces"> </span><span style="font-family:Arial; font-weight:bold; color:#ffffff">\</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">CLINICAL HISTORY:</span><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:spaces"> </span><span style="font-family:Arial; font-weight:bold; color:#ffffff">\</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">RAD 0002 - BARIUM ENEMA - SINGLE</span><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:spaces"> </span><span style="font-family:Arial; font-weight:bold; color:#ffffff">- Jan 21 2011</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">INDICATIONS:</span><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:spaces"> </span><span style="font-family:Arial; font-weight:bold; color:#ffffff">\</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">RESULT:</span><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:spaces"> </span><span style="font-family:Arial; font-weight:bold; color:#ffffff">This was REMERGED in TRD after Al Tiemann's fix.</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">Patient Name is Jan21e</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">DOB - April 5, 1945</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">Acc 184808</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">Proc Date - Jan 21, 2011 at 3:58pm</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">Proc is Barium Enema -Single</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">\</span><span style="width:87.22pt; display:inline-block; -aw-tabstop-align:left; -aw-tabstop-pos:90pt"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">IMPRESSION:</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">This is Jan21E's first procedure</span><span style="font-family:Arial; font-weight:bold; color:#ffffff; -aw-import:spaces"> </span><span style="font-family:Arial; font-weight:bold; color:#ffffff">orig with bad result shell.</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">Jan21b is being added to SR while this is being edited in this is dictated on January 22.</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">This is going to be sedated and signed off while a procedure and tear and he is sent</span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; font-weight:bold; color:#ffffff">\</span><span style="width:87.22pt; display:inline-block; -aw-tabstop-align:left; -aw-tabstop-pos:90pt"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:11pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:11pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:11pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:10pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p><p style="margin-top:0pt; margin-bottom:0pt; widows:0; orphans:0; font-size:11pt"><span style="font-family:Arial; color:#ffffff; -aw-import:ignore"></span></p></div></body></html>
But I need to like this.
<html>
<head>
<title></title>
<meta name="GENERATOR" content="Siemens syngoWorkflow">
</head>
<BODY BGCOLOR="#FFFFFF"><font FACE="Arial" SIZE="2" ><font COLOR="#ffffff"><br> </font><font FACE="Arial" SIZE="2" COLOR="#ffffff" ><b> INDICATIONS:</b> \<br> </font><font FACE="Arial" SIZE="2" COLOR="#ffffff" ><br> </font><b><font FACE="Arial" SIZE="2" COLOR="#ffffff" >INDICATIONS: \<br> <br> INDICATIONS: \<br> <br> CLINICAL HISTORY: \<br> <br> RAD 0002 - BARIUM ENEMA - SINGLE - Jan 21 2011<br> INDICATIONS: \<br> <br> RESULT: This was REMERGED in TRD after Al Tiemann's fix.<br> Patient Name is Jan21e<br> DOB - April 5, 1945<br> Acc 184808<br> Proc Date - Jan 21, 2011 at 3:58pm<br> Proc is Barium Enema -Single<br> \<br> <br> <b>IMPRESSION:<br> This is Jan21E's first procedure orig with bad result shell.<br> Jan21b is being added to SR while this is being edited in this is dictated on January 22.<br> This is going to be sedated and signed off while a procedure and tear and he is sent<br> </b><br> <font SIZE="3"><br> </font></b></b><font FACE="Arial" SIZE="3" COLOR="#ffffff" ><br> <br> <font SIZE="2"><br> <br> </font><font SIZE="3" FACE="Arial" COLOR="#ffffff" >
<br>
</font>
</font></font></font>
</body>
</html>
And after converting to HTML,I am not getting line spacing between the lines and font also not looking good.
Can you tell what are the property i can use to make more line space and font also.
see the below code i am using.
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.SaveFormat = SaveFormat.Html;
// saveOptions.Encoding = Encoding.UTF8;
saveOptions.ExportImagesAsBase64 = true;
saveOptions.ExportRelativeFontSize = true;
// Save the document to stream in HTML format.
using (MemoryStream htmlStream = new MemoryStream())
{
doc.Save(htmlStream, saveOptions);
// Read the HTML from the stream as plain text.
StringBuilder myHtml = new StringBuilder();
myHtml.Append(Encoding.UTF8.GetString(htmlStream.ToArray()));
myHtml.Replace(" ", "");
return myHtml.ToString();
}
Please ZIP and upload your simplified input RTF Word document and Aspose.Words generated HTML file showing the undesired behavior here for testing. We will then investigate the issue on our end and provide you more information.
You can also post-process Aspose.Words generated HTML and remove following tags:
This is not file conversion ,I am converting RTF content to HTML content. Below is my RTF content.
{\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang1033\deflangfe1033{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}}
{\colortbl ;\red255\green255\blue255;}
\viewkind4\uc1\pard\ltrpar\cf1\f0\fs20\par
\pard\ltrpar\tx360\tx1080\tx1800\tx2520\tx3240\tx3960\tx4680\tx5400\tx6120\tx6840\tx7560\tx8280\tx9000\tx9720\tx10440\tx11160\b\par
INDICATIONS:\b0\tab\\\par
\pard\ltrpar\tx1800\par
\pard\ltrpar\tx1800\tx2520\tx3240\tx3960\tx4680\b INDICATIONS: \\\par
\par
INDICATIONS: \\\par
\par
CLINICAL HISTORY: \\\par
\par
RAD 0002 - BARIUM ENEMA - SINGLE - Jan 21 2011\par
INDICATIONS: \\\par
\par
RESULT: This was REMERGED in TRD after Al Tiemann's fix.\par
Patient Name is Jan21e\par
DOB - April 5, 1945\par
Acc 184808\par
Proc Date - Jan 21, 2011 at 3:58pm\par
Proc is Barium Enema -Single\par
\\\b0\tab\par
\par
\b IMPRESSION:\par
This is Jan21E's first procedure orig with bad result shell.\par
Jan21b is being added to SR while this is being edited in this is dictated on January 22.\par
This is going to be sedated and signed off while a procedure and tear and he is sent\par
\\\tab\b0\par
\fs22\par
\pard\ltrpar\tx720\tx1080\tx1800\tx2520\tx3240\tx3960\tx4680\par
\par
\fs20\par
\par
\pard\ltrpar\fs22\par
}
If yes, then please list the complete steps that we can follow on our end to reproduce this expected HTML output from input RTF by using MS Word. We will then provide you code to perform the same steps by using Aspose.Words.
Yes I need this output.
Please help me to get it done.
Please check the below code i am using.
public static string RtfToHtml(string rtf, string strImageType)
{
Document doc;
using (Stream s = GenerateStreamFromString(rtf))
{
doc = new Aspose.Words.Document(s);
}
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.SaveFormat = SaveFormat.Html;
saveOptions.Encoding = Encoding.UTF8;
saveOptions.ExportImagesAsBase64 = true;
// Save the document to stream in HTML format.
using (MemoryStream htmlStream = new MemoryStream())
{
doc.Save(htmlStream, saveOptions);
// Read the HTML from the stream as plain text.
String myHtml = Encoding.UTF8.GetString(htmlStream.ToArray());
return myHtml.Replace(" ", "").Replace("0pt", "2pt");
}
}
public static Stream GenerateStreamFromString(string s)
{
var stream = new MemoryStream();
var writer = new StreamWriter(stream);
writer.Write(s);
writer.Flush();
stream.Position = 0;
return stream;
}
Please share above information for further proceedings. Since you have not shared the steps, I am going to tell you how you can use Aspose.Words to adjust the ‘Space After’ and ‘Space Before’ attributes of Paragraphs. Please check:
The following code also demonstrates how you can insert a Line Break at the end of Paragraphs.
public static string RtfToHtml(string rtf, string strImageType)
{
Document doc;
using (Stream s = GenerateStreamFromString(rtf))
{
doc = new Aspose.Words.Document(s);
}
DocumentBuilder builder = new DocumentBuilder(doc);
// just to make content visisble
foreach (Run run in doc.GetChildNodes(NodeType.Run, true))
run.Font.Color = System.Drawing.Color.Black;
// To adjust space after and space before attributes
foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
{
para.ParagraphFormat.SpaceAfter = 0;
para.ParagraphFormat.SpaceBefore = 12;
// and to add aditional line break after all Paragraphs
builder.MoveTo(para);
builder.Font.Color = System.Drawing.Color.Black;
builder.Write(ControlChar.LineBreak);
}
Aspose.Words.Saving.HtmlSaveOptions saveOptions = new Aspose.Words.Saving.HtmlSaveOptions();
saveOptions.SaveFormat = SaveFormat.Html;
saveOptions.Encoding = Encoding.UTF8;
saveOptions.ExportImagesAsBase64 = true;
// Save the document to stream in HTML format.
using (MemoryStream htmlStream = new MemoryStream())
{
doc.Save(htmlStream, saveOptions);
// Read the HTML from the stream as plain text.
String myHtml = Encoding.UTF8.GetString(htmlStream.ToArray());
return myHtml.Replace(" ", "").Replace("0pt", "2pt");
}
}
public static Stream GenerateStreamFromString(string s)
{
var stream = new MemoryStream();
var writer = new StreamWriter(stream);
writer.Write(s);
writer.Flush();
stream.Position = 0;
return stream;
}
Does Aspose.Words throw any exception on your end? Have you tried the latest (21.1) version of Aspose.Words for .NET on your end? We are unable to observe any issue during processing this RTF file (New RTF Document.zip (2.6 KB)) on our end. It would be great if you please provide a standalone simple Console application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words DLL files in it to reduce the file size.