|
©
Copyright SautinSoft 2002 - 2007 (build 2.0.0 - June 5th, 2007) Manual for HTML-to-RTF Pro DLL - .Net component to convert HTML strings (files) to RTF, Text strings (files). |
||
| about | methods and properties | code samples | html samples | faq | order and pricing | support and contacts | ||
The component can convert HTML files(strings) into RTF or TXT
files (strings) with images, tables, CSS etc.
This scheme shows all methods and properties of DLL component,
but you can use not all of members, because all of them are already set by default
to make conversion more precision.
|
|
|||||||||||||||||||||||||||||||
string ConvertString(string htmlString) - this method takes HTML string and returns RTF string.The parameter HtmlPath helps to converter find a full path to image, because HTML string doesn't have full path. For example, if converter meets <img src="images/img1.png"> and HtmlPath = "d:\" so component will try to open image from:
If want to convert HTML string with images, be sure that you have set the member HtmlPath
string htmlString = "<b>Hello world</b>";
string rtfString = "";
//create object (instance) of html2rtf converter
SautinSoft.HtmlToRtf.Converter h = new SautinSoft.HtmlToRtf.Converter();
if (h!=null)
{
//set converter options
h.OutputTextFormat = SautinSoft.HtmlToRtf.eOutputTextFormat.Rtf;
h.HtmlPath = @"D:\";
//convert strings
rtfString = h.ConvertString(htmlString);
System.Console.WriteLine(rtfString);
}
int
ConvertFile(string htmlFile, string outFolder)
- this method converts HTML
file into RTF file.
return values:
0 - converting
OK
1 - can't open HTML file
2 - can't create RTF file
3 - memory error
4 - an input HTML has zero length
5 -
unknown error
Example:
// create
object (instance) of html2rtf converter
SautinSoft.HtmlToRtf.Converter h = new SautinSoft.HtmlToRtf.Converter();
h.ConvertFile("D:\test.htm", "d:\");
The method also supports internet paths, so
you can use it to download HTML file from internet and next convert it to RTF.
For example:
h.ConvertFile("http://www.yahoo.com/", @"d:\test.rtf");
h.OutputTextFormat = SautinSoft.HtmlToRtf.eOutputTextFormat.Html;
h.ConvertFile("http://www.htmltortf.com/index.php", @"d:\test.html");
string ConvertFileToString(string htmlFile) - this method takes path to HTML file and returns RTF string.
int ConvertStringToFile(string htmlString, string rtfFile) - this method takes HTML string and path to output RTF file.
You may adjust the component
and output RTF file will look as you wish.
PageHeader
- put text in RTF page header (unlimited symbols max)

Possible values: any string
Default value: ""
Example: h.pageHeader
= "page Header
Example";
Example: h.pageHeader
= "{\b Bold
page Header Example}";
Example: h.pageHeader
= "{\b\i
Bold Italic page Header Example}";
Example: h.pageHeader
= "{\qc Centered
page Header Example}";
How to insert images in header or footer?
You can insert even complete HTML file with images and tables inside header
and footer. But at first you have to convert it to RTF.
This a C# sample:
// create object of SautinSoft.HtmlToRtf
SautinSoft.HtmlToRtf.Converter h = new SautinSoft.HtmlToRtf.Converter();
//prepare header and footer with company logo
h.RtfParts = SautinSoft.HtmlToRtf.eRtfParts.RtfBody;
string header = h.ConvertString("<table width=\"100%\" border=\"0\">"+
"<tr>" +
"<td width=\"200\"><img src=\"d:\\logo.gif\"
width=\"200\" height=\"100\"></td>"+
"<td><div align=\"center\"><font color=\"#0099FF\"
size=\"4\">Some</font><em> text</em> in <strong>header</strong></div></td>"+
"</tr>"+
"</table>");
string footer = h.ConvertString("<table width=\"100%\" border=\"0\">"+
"<tr>" +
"<td width=\"200\"><img src=\"d:\\logo.gif\"
width=\"100\" height=\"50\"></td>"+
"<td><div align=\"center\"><font color=\"#0099FF\"
size=\"4\">Some</font><em> text</em> in <strong>footer</strong></div></td>"+
"</tr>"+
"</table>");
//convert general html to rtf
h.RtfParts = SautinSoft.HtmlToRtf.eRtfParts.RtfCompletely;
h.PageHeader = @"[header]";
h.PageFooter = @"[footer]";
string rtfString = h.ConvertFileToString(@"d:\test.htm");
//put new header and footer
rtfString = rtfString.Replace("[header]",header);
rtfString = rtfString.Replace("[footer]",footer);
//save rtf file
StreamWriter sw = new StreamWriter(@"d:\test.rtf",false);
sw.Write(rtfString);
sw.Close();
pageFooter
- put text in RTF page footer (unlimited symbols max)
Possible values: any string
Default value: ""
Example: h.pageFooter
= "page Footer
Example";
!
If you don't want that header/footer appears
in produced RTF document, use empty strings "".
borderVisibility
- this property set table border's visibility;
or 
Possible values: Hidden, SameAsOriginalHtml, Visible.
Integer values:
|
Default value:
Hidden
Example: SautinSoft.HtmlToRtf.Converter h = new SautinSoft.HtmlToRtf.Converter();
h.borderVisibility = Visible;
h.borderVisibility = 1;
|
OutputTextFormat
- type of output file (Rtf, Doc, Text or Html)
Possible values: Rtf, Doc, Text, Html.
Integer values:
|
Default value: Rtf
Example: h.OutputTextFormat
= SautinSoft.HtmlToRtf.eOutputTextFormat.Text;
FontFace
- default font face
Possible values:
f_Arial, f_Times_New_Roman, f_Verdana, f_Helvetica, f_Courier, f_Courier_New,
f_Times, f_Georgia, f_MS_Sans_Serif, f_Futura, f_Arial_Narrow, f_Garamond, f_Impact,
f_Lucida_Console, f_Tahoma, f_Inform, f_Symbol, f_WingDings, f_Traditional_Arabic
Integer values:
|
Default value:
f_Arial
Example: h.FontFace
= SautinSoft.HtmlToRtf.eFontFace.f_Verdana;
Example: h.FontFace
= 2;
FontSize
- default font size
Possible values: Any size
Default value: 10
Example: h.FontSize
= 12;
PageAlignment
- default page alignment
Possible values: AlignLeft, AlignRight, AlignCenter, AlignJustify.
Integer values:
|
Default value: AlignLeft
Example: h.PageAlignment
= AlignLeft;
Example:
h.PageAlignment = 0;
preserveAlignment
- keep alignment as in HTML
or 
Possible values: 1 or 0
Default value: 1
preserveTables
- convert tables or transform to text
or 
Possible values: 1 or 0
Default value: 1
preserveNestedTables
- preserve nested tables as in HTML or transform it to plain tables
or 
Possible values: 1 or 0
Default value: 1
PreserveImages
- convert images or skip them (this feature works in all methods)
or 
Possible values: 1 or 0
Default value: 1
PreserveHttpImages
- download images which have remote path such as "<img src="http://...">
or <img src="www.google.com...> or skip them
or 
Possible values: 1 or 0
Default value: 0
PreserveFontFace
- keep font face as in HTML
or 
Possible values: 1 or 0
Default value: 0
PreserveFontSize
- keep font size as in HTML
or 
Possible values: 1 or 0
Default value: 1
PreserveFontColor
- keep font color as in HTML
or 
Possible values: 1 or 0
Default value: 1
PreserveBackgroundColor - keep background color as in HTML (for table columns and text)
Possible values: 1
or 0
Default value: 1
PreserveHyperlinks
- keep hyperlinks as in HTML
or 
Possible values: 1 or 0
Default value: 1
PreserveTableWidth
- keep width of table columns as in HTML
or 
Possible values: 1 or 0
Default value: 1
PageSize
- select page size for RTF

Possible values: A4, A3, A5, B5, Letter, Legal, Executive, Monarh
Default value: Letter
Integer values:
|
Example: h.PageSize = SautinSoft.HtmlToRtf.ePageSize.Legal;
PageOrientation
- select page orientation: Portrait or Landscape
Possible values: Portrait or Landscape
Default value: Portrait
Integer values:
|
Example: h.PageOrientation = SautinSoft.HtmlToRtf.ePageOrientation.Landscape
pageMarginLeft,
pageMarginRight, pageMarginTop, pageMarginBottom -
set page margins
Possible values: any value in millimeters
Default values:
pageMarginLeft = 25
pageMarginRight = 20
pageMarginTop = 20
pageMarginBottom = 20
RtfLanguage
- language which will be used for spelling in Microsoft Word
Possible values: l_Albanian, l_English, l_Belgian, l_Bulgarian, l_Hungarian,
l_Danish, l_Spanish,
l_Italian, l_Latvian, l_Lithuanian, l_German, l_Netherlands, l_Norwegian, l_Portuguese,
l_Romanian, l_Russian,
l_Ukrainian, l_Finnish, l_French, l_Czech, l_Swedish, l_Turkish, l_Arabic.
Integer values:
|
Default value: l_English
Example: h.RtfLanguage
= SautinSoft.HtmlToRtf.eRtfLanguage.l_English
ImageCompatible
- select image compatible: image_Word or image_WordPad
Possible values: image_Word or image_WordPad
Default value: image_Word
Integer values:
|
When you selected image_Word
the images will be strored in JPG, PNG and WMF formats:
{\pict...\pngblip....89504e470d0a1a0a000......}
{\pict...\jpegblip....ffd8ffe070d0a1a0a000......}
{\pict...\wmetafile8....010009000003de000......}
When you selected image_WordPad the images will be
strored in BMP format:
{\pict...\dibitmap0....28000000690100......}
Example: h.PageOrientation
= SautinSoft.HtmlToRtf.ePageOrientation.image_WordPad
PreservepageBreaks
- preserve page breaks as in HTML
If '1', then converter will create new page in RTF each time when it meet
'page-break-before:' or 'page-break-aftrer:'.
Possible values: 1 or 0
Default value: 0
This is example for page-breaks:
<HTML>
<HEAD>
<TITLE>page-break-after</TITLE>
<STYLE>
P.after {page-break-after: always}
P.before {page-break-before: always}
</STYLE>
</HEAD>
<BODY>
<p class="before">Some text</p>
<p class="after">Some text</p>
<p>Some text</p>
</BODY>
</HTML>
PageNumbers
- put page numbers
Possible values: pageNumDisable, pageNumFirst and pageNumSecond
Default value: pageNumDisable
Integer values:
|
Example: h.PageNumbers = SautinSoft.HtmlToRtf.ePageNumbers.pageNumFirst
PageNumbersAlignH
- horizontal alignment of page numbers
Possible values: AlignLeft, AlignRight, AlignCenter.
Integer values:
|
Default value: AlignCenter
Example: h.PageNumbersAlignH
= SautinSoft.HtmlToRtf.ePageAlignment.AlignLeft
PageNumbersAlignV
- vertical alignment of page numbers
Possible values: AlignTop, AlignBottom
Integer values:
|
Default value: AlignBottom
Example: h.PageNumbersAlignV
= SautinSoft.HtmlToRtf.ePageAlignment.AlignLeft
PreserveHR
- keep horizontal rule <HR> as in HTML
Possible values: 1 or 0
Default value: 1
RtfParts
- allows to create completely RTF or only RTF body which you can insert inside
another RTF file
Possible values: RtfCompletely, RtfBody
Default value: RtfCompletely
|
Example: h.RtfParts
= SautinSoft.HtmlToRtf.eRtfParts.RtfBody
CreateTraceFile
- forces DLL to create tracing text file, this file shows you debug info and
helps find some errors
Possible values: 0 or 1
Default value: 0
Example: h.CreateTraceFile
= 1
By default tracing file will be created
on C:\htmltortf-trace.txt, you can also specify path for this file using this
parameter:
TraceFilePath
- path for tracing file
Possible values: any string
Default value: "C:\htmltortf-trace.txt"
Example: h.TraceFilePath
= @"D:\report.txt";
HtmlPath
- path of HTML file, needs to convert HTML string with images and CSS
This parameter helps to component find a full path to images and CSS external
file when you are using method ConvertString() or ConvertStringToFile()
Possible values: any string
Default value: ""
Example: h.HtmlPath
= @"D:\my
webs\";
TableCellPadding
- set default cell padding in pix for all tables inside converting file
Possible values: 0 to 10
Default value: 2
Example: h.TableCellPadding
= 10;
Serial
- your individual serial number to activate your product copy
After purchasing you will get the full version of product and your serial number.
This parameter doesn't have any effect in trial version. This parameter is necessary
in full version, please don't forget to spcify it by your serial number.
Possible values: any string
Default value: ""
Example: h.Serial
= "XXXXXXXXX";
DeleteImages
- specify that component removes images from input HTML
For example if you are converting from HTML to HTML converter will remove all
tags <img ...>. If you are converting from HTML to RTF you will also not
see images if this parameter is specified to 1.
Possible values: 0 or 1
Default value: 0
Example: h.DeleteImages
= 1;
DeleteTables
- specify that component removes all tables from input HTML
For example if you are converting from HTML to HTML converter will remove all
table's tags like a <table>, <tr>, <td>. If you are converting
from HTML to RTF you will also not see tables if this parameter is specified
to 1.
Possible values: 0 or 1
Default value: 0
Example: h.DeleteTables
= 1;
BaseURL
- specify base URL for HTML
For example if you are converting remote HTML and it has only relative path
to images, for example <img src="images\logo.jpg">, specify
domain name as this parameter.
Possible values: any string
Default value: ""
Example:
h.BaseURL = "http://www.sautinsoft.com/";
h.PreserveHttpImages = 1;
h.ConvertFile(@"http://www.sautinsoft.com",@"d:\test.rtf");