©
Copyright SautinSoft 2002 - 2008 (2.3.0 - July 16th, 2008) Manual for RTF-to-HTML DLL - .Net component to convert Text, RTF strings (files) to HTML, XHTML strings (files). |
||
about | methods and properties | code samples | rtf samples | faq | order and pricing | license | support and contacts |
|
|
|
|||||||||||||||||||||||||||
Methods
int ConvertFile(string RtfPath, string HtmlPath) - this method takes RTF (or Text) file and converts it into HTML file.
Return values:
0 - converting successful
1 - can't open input RTF
2 - can't create output HTML
3 - converting error
string ConvertString(string Rtf) - this method takes RTF (or Text) string and returns HTML string.
string
ConvertString(string Rtf, ArrayList ImageList) -
this method takes RTF (or Text) string and array list for storing images.
Returns HTML string and array list filled by images.
This method is very useful to work together with HTML-to-RTF
Pro DLL .Net. When you need to convert HTML -> RTF ->
HTML or RTF -> HTML ->RTF in memory with
images (without any HDD savings), use the methods ConvertString(string,
ArrayList) from both components.
This is description of class ImagesList:
public class SautinImage
{
private string cid = string.Empty;
private System.Drawing.Image img =
null;
private MemoryStream MS;
public
string Cid
{
get
{ return this.cid; }
}
public
System.Drawing.Image Img
{
get
{ return this.img; }
}
public
SautinImage(string Cid_, System.Drawing.Image Img_)
{
MemoryStream
MS = new MemoryStream();
Img_.Save(MS,System.Drawing.Imaging.ImageFormat.Png);
this.img
= System.Drawing.Image.FromStream(MS,true);
this.cid
= Cid_;
}
public
void ClearImage()
{
MS.Close();
}
}
This is a sample of using these special methods in C#: (rtf ->
html -> rtf)
SautinSoft.HtmlToRtf.Converter
h = new SautinSoft.HtmlToRtf.Converter();
SautinSoft.RtfToHtml.Converter
r = new SautinSoft.RtfToHtml.Converter();
string
rtfString = "...... already filled from RTF file or database";
string
htmlString = "";
//convert
rtf to html
ArrayList
myImages = new ArrayList ();
myImages.Add(new
SautinImage("image1",null));
htmlString
= r.ConvertString(rtfString,myImages)
//convert
html to rtf back
rtfString
= h.ConvertString(htmlString,myImages);
string ConvertFileToString(string RtfPath) - this method takes RTF (or Text) file and returns HTML string
int ConvertStringToFile(string Rtf, string HtmlPath) - this method takes RTF (or Text) file and converts it to HTML file.
Return values:
0 - converting successful
1 - can't open input RTF
2 - can't create output HTML
3 - converting error
Encoding
- specify encoding for output HTML/XHTML
Possible values: any value from enumerator
SautinSoft.RtfToHtml.eEncoding
Default value: Windows-1250
|
Example: r.Encoding = SautinSoft.RtfToHtml.eEncoding.ISO_8859_1;
HtmlParts
- specify component to produce only some parts of HTML document
Possible values: Html_completely, Html_body
from enumerator SautinSoft.RtfToHtml.eHtmlParts.
Default value: Html_completely
|
Example: r.HtmlParts = SautinSoft.RtfToHtml.eHtmlParts.Html_body;
OutputFormat
- type of ouput HTML document.
Possible values: XHTML_10, HTML_401,
HTML_32 from enumerator SautinSoft.RtfToHtml.eOutputFormat.
Default value: HTML_401
|
Example: r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.XHTML_10;
Title
- HTML page title, which appears between tags <title>...</title>
Possible values: Any string.
Default value: "Untitled Document"
Example: r.Title = "My first page";
<html>
<head>...
<title>My first page</title>
</head>
Text Parameters
TextStyle.FontFace
- specify single font face for all document, otherwise font faces will
be as in RTF
Possible values: any font name,
Default value: as in RTF document
Example: r.TextStyle.FontFace = "Verdana";
or
TextStyle.FontSize
- specify single font
size for all document, otherwise font sizes will be as in RTF
Possible values: from 0 to 100
Default value: as in RTF document
Example: r.TextStyle.FontSize
= 12
or
TextStyle.FontColor.SetRGB
- specify single font
color for all document, otherwise font colors will be as in RTF
Possible values: any RGB color
Default value: as in RTF document
Example: r.TextStyle.FontColor.SetRGB(100,100,100);
or
TextStyle.StyleName
- specify name template for CSS styles
Possible values: any string
Default value: "st"
Example: r.TextStyle.StyleName = "my_style";
<style type="text/css">
<!--
span.my_style1
{
font-family: Times New Roman;
font-size: 9pt;
color: #000000;
}
span.my_style2
{
font-family: Times New Roman;
.....
TextStyle.StartCSSNumber
- specify start number for CSS style name
Possible values: any integer value >0
Default value: 1
Example: r.TextStyle.StartCSSNumber = 100;
<style type="text/css">
<!--
span.my_style100
{
font-family: Times New Roman;
font-size: 9pt;
color: #000000;
}
span.my_style101
{
font-family: Times New Roman;
.....
Table Parameters
TableStyle.BorderType
- specify table border
type (visible, hidden or as in original RTF)
Possible values: Visible, Hidden or SameAsInRtf
from enumerator SautinSoft.RtfToHtml.eTableBorderType
Default value: SameAsInRtf
Example: r.TableStyle.BorderType = SautinSoft.RtfToHtml.eTableBorderType.Visible;
or
TableStyle.WidthType
- specify the type of table's and column's width (percents or pixels)
Possible values: Percents or Pixels from
enumerator SautinSoft.RtfToHtml.eWidthType
Default value: Pixels
Example: r.TableStyle.WidthType = SautinSoft.RtfToHtml.eWidthType.Percents;
<table width="100%">
<tr>
<td width="30%".......
or
<table width="750">
<tr>
<td width="240".......
Image Parameters
ImageStyle.PreserveImages
- if this parameter set to true
then images will be preserved.
Possible values:
true, false.
Default value:
true
Example: r.ImageStyle.PreserveImages = false;
or
ImageStyle.ImageFolder
- path where images will be stored, this folder must already exist.
Path must be absolute, it must begin from "C:\.." or "D:\"
etc.
Possible values: real path
Default value: "c:\"
Example: r.ImageStyle.ImageFolder = @"d:\webs\";
ImageStyle.ImageSubFolder
- folder which will created for storing images.
Folder will be created by component.
Must be without any "C:\.." or "D:\" etc, only folder
as "my folder".
Possible values: "string",
etc.
Default value: "images"
Example: r.ImageStyle.ImageSubFolder = "pictures";
ImageStyle.ImagesFormat
- specify format for output images (Jpeg, Gif or Png)
Possible values: gif, jpg or png from
enumerator SautinSoft.RtfToHtml.eImageFormat
Default value: jpg
Example: r.ImageStyle.ImagesFormat = SautinSoft.RtfToHtml.eImageFormat.gif;
ImageStyle.ImageFileName
- specify template name for images
Possible values: any string
Default value: "image"
Example: r.ImageStyle.ImageFileName
= "pict";
<img src="pict1.jpg" ...>
<img src="pict2.jpg" ...>
<img src="pict3.jpg" ...>
ImageStyle.ImageNumStart
- specify start number for image's name
Possible values: any integer
>0
Default value: 1
Example: r.ImageStyle.ImageNumStart
= 100;
<img src="pict100.jpg" ...>
<img src="pict101.jpg" ...>
<img src="pict102.jpg" ...>
DestFile
- specify path where HTML file will be stored. This is necessary to make
a relative path inside tag <img src="..\..\image1.jpg" ...>.
Possible values: any path
Default value: the same as in ImageFolder
Example: r.DestFile = @"d:\webs\1.htm";
<img src="pict100.jpg" ...>
<img src="pict101.jpg" ...>
<img src="pict102.jpg" ...>
License activation
Serial
- set activation key
After purchasing component you will get own serial number, it's necessary
to activate your copy
Possible values: unknown
Default value: unknown :)
Example: r.Serial = "XXXXXXXX";
Copyright © 2002-2008, SautinSoft. All rights reserved.