PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | French EN
  • Conversion rules
  • Supported tags
  • Managing the character set
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Converts an HTML string or an HTML buffer to an RTF string. The following operations are performed during the conversion:
  • Deletion of HTML tags
  • Conversion of HTML special characters
  • Conversion of CR characters (Carriage Return) to spaces
  • Conversion of multiple spaces to single spaces
The formatting is kept "as best as possible".
Versions 19 and later
WINDEVLinux This function is now available for WINDEV applications in Linux.
WEBDEV - Server codeLinux This function is now available for WEBDEV sites in Linux.
New in version 19
WINDEVLinux This function is now available for WINDEV applications in Linux.
WEBDEV - Server codeLinux This function is now available for WEBDEV sites in Linux.
WINDEVLinux This function is now available for WINDEV applications in Linux.
WEBDEV - Server codeLinux This function is now available for WEBDEV sites in Linux.
Versions 21 and later
iPhone/iPad This function is now available for iPhone/iPad applications.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
iPhone/iPad This function is now available for iPhone/iPad applications.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
iPhone/iPad This function is now available for iPhone/iPad applications.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Example
MyHTMLText is string = "<!--test-->'''''&quote;Hello!&quote;''"
Text is string = HTMLToRTF(MyHTMLText)
// Text is set to: "Hello"!
WINDEVWEBDEV - Server codeReports and QueriesUser code (UMC)
// If the HTML document is set to:
//<HTML>
// <HEAD>
//  <TITLE>This is a test for a Web page</TITLE>
//  <META http-equiv="content-type" content="text/html; charset=UTF-8">
// </HEAD>
//<BODY>
// <H2>This is      an HTML page   in English</H2>
//  <A href="http://www.windev.com">This is a link</A>
// </BODY>
//</HTML>
 
Text = HTMLToRTF(MyHTMLText)
// Text will contain the RTF code corresponding to the following text:
// This is     an HTML page   in English.
//
// This is a link
Syntax
<Result> = HTMLToRTF(<Text in HTML format> [, <Charset used>])
<Result>: Character string
RTF text corresponding to the result of the HTML conversion. The encoding used is the one of the current character set of WINDEV or WEBDEV.
<Text in HTML format>: Character string or buffer (with quotes)
Text to convert.
<Charset used>: Optional Integer constant
Constant identifying the character set used to write the <Text in HTML format>. The current character set of WINDEV or WEBDEV is used by default (charsetCurrent constant). If any information about the character set used is found in the <Text in HTML format>, this information has priority over this parameter.
For more details on these constants, see Correspondence between languages, sub-languages, character sets and nations.
Remarks

Conversion rules

  • The HTML tags are analyzed to keep the best possible formatting in the output text (CR characters, spaces, tabs, etc.). The formatting is kept as best as possible: bold, italic, colors, etc.
  • The following elements do not appear in the RTF output:
    • HTML tags
    • content of the "header" (information in the <HEAD> tag)
    • comments
    • control texts
    • scripts
    • SSL definitions
    • CSS styles (except "color" attributes)
  • Management of CR characters
    • 2 Carriage Returns are inserted to replace the following tags: <P>, <H1> to <H6>, <TABLE>, <UL> or <OL>
    • 1 Carriage Return is inserted to replace the following tags: <BR>, <TR>, <LI>, <DD> or <DIV>
    • 1 single Carriage Return is inserted if several identical tags (<TR>, <LI>, <DD> or <DIV>) follow one another (except for <BR> tags)
  • Management of arrays
    • A CR character is inserted for each array row (<TR> tag).
    • A tab is inserted for each array column (<TD> tag).
  • Management of special characters
    A special character is a character defined in the HTML standard. For example, a space can be written as " ". This standard is automatically used.

Supported tags

The unsupported tags are ignored: their content is taken into account as text.
The supported tags are as follows:
  • <PRE>
  • <UL>: Line break + tab
  • <OL>: Line break + tab
  • <LI>: Tab
  • <H1>: Line break above and below, bold and size
  • <H2>: Line break above and below, bold and size
  • <H3>: Line break above and below, bold and size
  • <H4>: Line break above and below, bold and size
  • <H5>: Line break above and below, bold and size
  • <H6>: Line break above and below, bold and size
  • <P>: Line break above and below
  • <BR>: Line break
  • <B>: Bold
  • <STRONG>: Bold
  • <I>: Italics
  • <EM>: Italics
  • <FONT>: Size and color
  • <A HREF>: Hyperlink
  • <SPAN>: Style: Color
  • <DL>: Line break
  • <DT>: Line break
  • <DD>: Tab and line break
  • <TABLE>: Line break
  • <TR>: Line break
  • <TD>: Elements separated by a tab
  • <HEAD>: Content ignored, except for the parameters of the character set
  • <STYLE>: Content ignored
  • &lt;SCRIPT&gt: Content ignored
  • <!-- -->: Comments ignored

Managing the character set

To find out the character set used in the HTML text, HTMLToRTF is using the information found in the CONTENT attribute of a <META> tag.
If this tag is not found, the character set used to write the HTML text must be specified in <Charset used>.
If the HTML content uses an Arabic character set and WINDEV/WEBDEV uses a French character set by default, the output text will have invalid characters.
Remarks:
  • If the output text contains several question marks ("?"), it means that the characters of the character set used in the HTML document cannot be expressed with the characters of the current language.
  • The UTF-8 character set is commonly used to encode Web pages.
Related Examples:
The HTMLTo functions Unit examples (WEBDEV): The HTMLTo functions
[ + ] This example explains how to use the HTMLToRTF and HTMLToText functions of WLanguage.
Component : wd260rtf.dll
Minimum version required
  • Version 12
This page is also available for…
Comments
Click [Add] to post a comment