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, but you
can use not all of members, because all of them is already set by default to
make conversion more precise.
|
|
||||||||||||||||||||||||||||||
* - marked members are available
only in Pro version.
string RTF Convert( string
HTML, string PageHeader, string
PageFooter) - this method
takes HTML string and returns RTF string.
Example:
Dim
h As New HTML2RTF.Converter
strRet = h.Convert("<b>This test</b>", "", "")
! If you don't want that header/footer appears in produced RTF document, use empty strings "" as parameters in methods.
PageHeader
- put text in RTF page header (150 symbols max)
Possible values: any string, 150 symbols max
Default value: ""
Example: PageHeader
= "Page Header
Example"
Example: PageHeader
= "{\b Bold
Page Header Example}"
Example: PageHeader
= "{\b\i
Bold Italic Page Header Example}"
Example: PageHeader
= "{\qc Centered
Page Header Example}"
h.Convert("<b>This test</b>", PageHeader, PageFooter)
PageFooter
- put text in RTF page footer (150 symbols max)
Possible values: any string, 150 symbols max
Default value: ""
Example: PageFooter
= "Page Footer
Example"
h.Convert("<b>This test</b>", PageHeader,
PageFooter)
int
ConvertFile( string HTMLpath, string RTFpath,
string PageHeader, string
PageFooter ) -
this method converts HTML
file into RTF file. This method supports image conversion.
return values:
CONVERTING_SUCCESSFUL -
convert ok ( value
0 )
NOT_ENOUGH_MEMORY
- not enough
memory ( value 1 )
RTF_CREATE_ERROR -
can't create RTF file
( value 2 )
HTML_OPEN_ERROR -
can't open HTML file
( value 3 )
HTML_HAS_ZERO_LENGTH
-
the HTML file has zero length (
value 4)
UNKNOWN_ERROR
-
unknown error (
value 5)
Example:
Dim
h As New HTML2RTF.Converter
strRet = h.ConvertFile("D:\test.htm","d:\", "",
"")
'or
strRet
= h.ConvertFile("D:\test.htm","d:\file.rtf", "Sample
header", "Sample footer")
string
ConvertFileToString( string HTMLpath,
string PageHeader, string
PageFooter ) -
this method takes HTML
file and returns RTF string.
int
ConvertStringToFile( string HTML, string RTFpath,
string PageHeader, string
PageFooter ) -
this method takes HTML
string and creates RTF file.
return values:
CONVERTING_SUCCESSFUL
- convert
ok ( value 0 )
NOT_ENOUGH_MEMORY
- not enough memory
( value 1 )
RTF_CREATE_ERROR -
can't create RTF file
( value 2 )
HTML_OPEN_ERROR -
can't open HTML file
( value 3 )
HTML_HAS_ZERO_LENGTH
- the
HTML file has zero length (
value 4)
UNKNOWN_ERROR -
unknown error (
value 5)
You may adjust the component and output RTF file will look as
you wish. After creating object of HTML2RTF, you cant set the object properties:
BorderVisibility
- this property set table border's visibility;
or
Possible values: Hidden, SameAsOriginalHtml, Visible.
Integer values:
|
Default value:
Hidden
Example: Dim h
As New HTML2RTF.Converter
h.BorderVisibility = Visible
h.BorderVisibility = 1
|
OutputTextFormat
- type of output file (RTF or TXT)
Possible values: Rtf, Text.
Integer values:
|
Default value:
Rtf
Example: h.OutputTextFormat
= Text
Example:
h.OutputTextFormat = 1
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
= HTML2RTF.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
= HTML2RTF.AlignLeft
Example:
h.PageAlignment = 0
PreserveAlignment
- keep alignment as in HTML
or
Possible values: True or False
Default value: True
PreserveTables
- convert tables or transform to text
or
Possible values: True or False
Default value: True
PreserveNestedTables
- preserve nested tables as in HTML or transform it to plain tables
or
Possible values: True or False
Default value: False
PreserveImages
- convert images or skip them (this feature work only in method ConvertFile)
or
Possible values: True or False
Default value: False
PreserveFontFace
- keep font face as in HTML
or
Possible values: True or False
Default value: False
PreserveFontSize
- keep font size as in HTML
or
Possible values: True or False
Default value: False
PreserveFontColor
- keep font color as in HTML
or
Possible values: True or False
Default value: True
PreserveBackgroundColor - keep background color as in HTML (for table columns and text)
Possible values: True
or False
Default value: True
PreserveHyperlinks
- keep hyperlinks as in HTML
or
Possible values: True or False
Default value: False
PreserveTableWidth
- keep width of table columns as in HTML
or
Possible values: True or False
Default value: False
PageSize
- select page size for RTF
Possible values: A4, A3, A5, B5, Letter, Legal, Executive, Monarh
Default value: Letter
Integer values:
|
Example:
h.PageSize = HTML2RTF.Legal
Example: h.PageSize
= 5
PageOrientation
- select page orientation: Portrait or Landscape
Possible values: Portrait or Landscape
Default value: Portrait
Integer values:
|
Example:
h.PageOrientation = HTML2RTF.Landscape
Example: h.PageOrientation
= 1
PageMarginLeft,
PageMarginRight, PageMarginTop, PageMarginBottom -
set page margins
Possible values: margin_0mm, margin_5mm, margin_10mm, margin_15mm, margin_20mm,
margin_25mm, margin_30mm, margin_35mm, margin_40mm, margin_45mm, margin_50mm
Default values:
PageMarginLeft
= margin_25mm
PageMarginRight = margin_10mm
PageMarginTop = margin_10mm
PageMarginBottom = margin_10mm
|
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
= HTML2RTF.l_English
Example: h.RtfLanguage
= 1033
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
= HTML2RTF.image_WordPad
Example: h.PageOrientation
= 1
PreservePageBreaks
- preserve page breaks as in HTML
If 'True', then converter will create new page in RTF each time when it meet
'page-break-before:' or 'page-break-aftrer:'.
Possible values: True or False
Default value: False
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 = HTML2RTF.PageNumFirst
PageNumbersAlignH
- horizontal alignment of page numbers
Possible values: AlignLeft, AlignRight, AlignCenter.
Integer values:
|
Default value: AlignCenter
Example: h.PageNumbersAlignH
= HTML2RTF.AlignLeft
Example:
h.PageNumbersAlignH = 0
PageNumbersAlignV
- vertical alignment of page numbers
Possible values: AlignTop, AlignBottom
Integer values:
|
Default value: AlignBottom
Example: h.PageNumbersAlignV
= HTML2RTF.AlignLeft
Example:
h.PageNumbersAlignV = 0
PreserveHR
- keep horizontal rule <HR> as in HTML
Possible values: True or False
Default value: True