Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

[180] Convert RTF to HTML

Last post 08-05-2005 8:43 PM by shovmyfist. 37 replies.
Page 1 of 3 (38 items) 1 2 3 Next >
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [180] Convert RTF to HTML

    This thread is for discussions of Convert RTF to HTML.

    • Post Points: 0
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 10-30-2001 5:47 PM In reply to

    • sparkz
    • Not Ranked
    • Joined on 10-30-2001
    • New Member
    • Points 15

    Thanks for RTF2HTML

    Perfect - thanks for saving me from learning RTF.

    An inspired piece of code!
    • Post Points: 0
  • 02-22-2002 3:09 PM In reply to

    • ulisse
    • Not Ranked
    • Joined on 02-22-2002
    • New Member
    • Points 5

    rtf2html

    I have download the rtf2html.bas project.
    and implemented in the my simple project.
    probably in my project there is an error because
    the software run incorrectly.

    Please help me.

    Thank You very for your kindness.

    Ulisse Quadri

    email: ulisse.quadri@libero.it
    • Post Points: 0
  • 02-22-2002 3:54 PM In reply to

    • James Crowley
    • Top 10 Contributor
    • Joined on 12-07-2000
    • United Kingdom
    • Guru
    • Points 15,030
    • SystemAdministrator
    • Post Points: 0
  • 02-23-2002 4:00 PM In reply to

    • James Crowley
    • Top 10 Contributor
    • Joined on 12-07-2000
    • United Kingdom
    • Guru
    • Points 15,030
    • SystemAdministrator
    The code has now been updated to Version 3.... which should solve your problem.
    • Post Points: 0
  • 04-03-2002 3:01 AM In reply to

    • pranay
    • Not Ranked
    • Joined on 03-25-2002
    • New Member
    • Points 10

    querry!


    what is the meaning of RTF?
    what is the need to convert it into HTML codes?
    thankx in advance.
    • Post Points: 0
  • 04-03-2002 5:31 AM In reply to

    • James Crowley
    • Top 10 Contributor
    • Joined on 12-07-2000
    • United Kingdom
    • Guru
    • Points 15,030
    • SystemAdministrator
    RTF =RichTextFormat ... it is used in the RichTextBox (which allows you to add bold/italic text effects etc). This code lets you convert the bold/italic text in a richtextbox into a HTML page.

    Take a look at some of the items in the "related" panel on the right-hand side of the code for some links to related articles.
    • Post Points: 0
  • 06-01-2002 6:34 AM In reply to

    RTF to HTML

    Hi there,

    The code displayed here is really commandable. but i couldnt understand which all funtions to be used to execute to convert RTFtext to HTML.

    It states to copy the code and paste in a module (.bas) but which all functions need to be executed to convert the code it hasn't mention that.

    Please direct me for the same.

    Thanks.

    Butterfly.
    • Post Points: 0
  • 06-01-2002 8:38 AM In reply to

    • James Crowley
    • Top 10 Contributor
    • Joined on 12-07-2000
    • United Kingdom
    • Guru
    • Points 15,030
    • SystemAdministrator
    You need to call the rtf2html function.
    Code:
    Function rtf2html(strRTF As String, Optional strOptions As String) As String
    • Post Points: 0
  • 06-03-2002 8:33 AM In reply to

    Richtext to html

    Thanks!!

    I tried to execute the code as per ur direction... but it gave the following result:
    -------------------------------------------------------
    \rtf1
    \ansi
    \deff0
    \viewkind4
    \uc1
    \pard
    \lang1033
    \f0
    \fs17
    Test
    \par
    This is a test.....
    \par
    Doono what kind of output it will be!!
    \par
    Test <br>This is a test.....<br>Doono what kind of output it will be!!

    -------------------------------------------------------------------

    The generated code was not at all displaying the input text as html.

    I used to following code for this:
    ------------------------------------
    Private Sub Command1_Click()
    Debug.Print rtf2html(RichTextBox1.TextRTF, "+H")
    End Sub

    Private Sub Form_Load()
    RichTextBox1.BackColor = &H80000004
    RichTextBox1.Font = Verdana
    RichTextBox1.TextRTF = "Test"
    End Sub
    ------------------

    Kindly direct me more to achive the desired result.

    In appriciation

    Butterfly
    • Post Points: 0
  • 07-09-2002 6:58 PM In reply to

    • pleitch
    • Not Ranked
    • Joined on 07-09-2002
    • Junior Member
    • Points 60

    Good start

    Good - but what about the text Font type, background colours and image support?
    • Post Points: 0
  • 07-09-2002 8:20 PM In reply to

    good to see more aussies around!
    Digitally Yours,

    Thushan Fernando
    • Post Points: 0
  • 07-09-2002 9:33 PM In reply to

    • pleitch
    • Not Ranked
    • Joined on 07-09-2002
    • Junior Member
    • Points 60

    Code is incomplete

    Upon further review.... the code is simply incomplete.
     There are numerous (15-20) variables that are declared but not used.
     The code loaded a "Font" table, but then just ignored it
     The code indicated multiple arguments, of which only two were used.

     I added Font handling by adding this code:
    In the General section:
    Dim strFontFace as string
    Function ParseFont(strColor As String, strSize As String, strFont As String) As String
       Dim strTmpFont As String

       strTmpFont = "<font"
       If strColor <> "" Then
          strTmpFont = strTmpFont & " color=""" & strColor & """"
       End If
       If strSize <> "" And strSize <> "2" Then
           strTmpFont = strTmpFont & " size=" & strSize
       End If
       If strFontFace <> "" Then
           strTmpFont = strTmpFont & " face=" & strFont
       End If
       strTmpFont = strTmpFont & ">"
       ParseFont = strTmpFont
    End Function

    **ALSO** in the ProcessWord function alterations need to be made
    in the Case "\f" section, remove the main "End IF" (the endif for the first if) and replace it with
               ElseIf IsNumeric(Mid(strWord, 3)) Then 'Font Type
                   strFontFace = strFontTable(Mid(strWord, 3))
               End If

    **ALSO** in the ProcessWord function change every call to ParseFont to:
    ParseFont(strFontColor, strFontSize, strFontFace)

     To include a basic HTML headder (+H option) just add this at the very last line of the  RFT2HTML function:
       If InStr(strOptions, "+H") Then
           RTF2HTML = "<html><body>" & RTF2HTML & "</body></html>"
       End If

    Crude, but effective.


     Finally, you might want to comment out ALL local and module scoped variables and then de-comment the ones the compiler says are needed..... cuts right down on the number of variables....
    • Post Points: 0
  • 07-09-2002 9:35 PM In reply to

    • pleitch
    • Not Ranked
    • Joined on 07-09-2002
    • Junior Member
    • Points 60
    No problem.  I found this sight through Google.... what is it all about?  Is it like PlanetSourceCode?
    • Post Points: 0
  • 07-09-2002 10:30 PM In reply to

    • pleitch
    • Not Ranked
    • Joined on 07-09-2002
    • Junior Member
    • Points 60

    More changes


    ummm.... don't mean to grumble but the way the Font type was being constructed appeared buggy.  I have rewritten it below (feel free to tell me if I am doing it wrong).  Much much smaller and I think it might even be faster.

    Function GetFontTable(strSecTmp As String, strFontTable() As String)
    Dim i As Integer
       'get font table data and fill in strFontTable array
       
       'We already know that this is multiple {} seperated values, and we should be looking
       'at font definitions ONLY....
       Dim strFonts As String
       'Strip off the begining of the section (and the first curly brace and last brace and semi-colon)
       strFonts = Mid(strSecTmp, 11, Len(strSecTmp) - 13)
       ReDim strFontTable(CInt(UBound(Split(strFonts, ";}{")))) As String
       For i = 0 To UBound(Split(strFonts, ";}{"))
           'We only want the section from the first space to the end....using ";}{" as an array splitter
           strFontTable(i) = Right(Split(strFonts, ";}{")(i), Len(Split(strFonts, ";}{")(i)) - InStr(1, Split(strFonts, ";}{")(i), " "))
       Next i
    end Function
    • Post Points: 0
Page 1 of 3 (38 items) 1 2 3 Next >