RTF-to-HTML-Converter-Class-Library-DLL icon indicating copy to clipboard operation
RTF-to-HTML-Converter-Class-Library-DLL copied to clipboard

How to Work (RTF to XML) ??

Open pc8181 opened this issue 7 years ago • 4 comments

how to work with this library for RTF to XML ?

my rtbx has different style font with content i want to extract the text with it's font, is't possible ?

Thanks

pc8181 avatar Feb 24 '18 16:02 pc8181

I don't know what is rtbx, but please let me know if you got an error you need help with ᐧ

Sincerely yours,

Shereef Marzouk http://shereef.net/ Software Engineer @ DaySmart http://DaySmart.com/ +1 (707) 8671712 / +1 (437) 8663883

http://shereef.net/sig/qr.png

[image: Shereef Marzouk » About.me] http://about.me/Shereef [image: Shereef Marzouk » Blog] http://shereef.net/blog [image: Shereef Marzouk » Twitter] http://twitter.com/Shereefz [image: Shereef Marzouk » Facebook] http://bit.ly/Shereef [image: Shereef Marzouk » Google Plus] http://google.com/+ShereefMarzouk [image: Shereef Marzouk » Linkedin] http://ca.linkedin.com/in/Shereef [image: Shereef Marzouk » Github] http://github.com/Shereef [image: Shereef Marzouk » Ohloh] http://ohloh.net/accounts/Shereefz [image: Shereef Marzouk » Stackoverflow] http://stackoverflow.com/users/435706/shereef [image: Shereef Marzouk » Reddit] http://reddit.com/user/Shereefz [image: Shereef Marzouk » StumbleUpon] http://stumbleupon.com/stumbler/Shereefz [image: Shereef Marzouk » Goodreads] http://goodreads.com/profile/Shereef [image: Shereef Marzouk » Youtube] http://youtube.com/user/Shereefz "The road to success is always under construction!"

On Sat, Feb 24, 2018 at 11:20 AM, pc8181 [email protected] wrote:

how to work with this library for RTF to XML ?

my rtbx has different style font with content i want to extract the text with it's font, is't possible ?

Thanks

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Shereef/RTF-to-HTML-Converter-Class-Library-DLL/issues/2, or mute the thread https://github.com/notifications/unsubscribe-auth/AAVxmy1wcz5HHq1iKypeZ-wabR6J-KxMks5tYDa8gaJpZM4SR8gu .

Shereef avatar Feb 26 '18 12:02 Shereef

Thanks for your reply sir ...

RTBX = Rich Text Box I am using Rich Text Box for different type of font styles

Thanks

pc8181 avatar Feb 26 '18 19:02 pc8181

Sorry for the late reply, if you find this file after cloning and then navigate in the solution to this file i think you'll get the gist of it

Shereef avatar Feb 27 '18 12:02 Shereef

i need XML .... k sir thnks for your reply i managed it ....

my stackoverflow is about RTF to XML https://stackoverflow.com/questions/49005971/vb-net-rtf-to-required-xml-format

i tried like this


        _lamParseRTF = Function()
                               Dim rtfStructure As IRtfGroup
                               Dim parserLogger As RtfParserListenerFileLogger = Nothing
                               Try
                                   Using stream As FileStream = File.Open(_tmpRTFFile$, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
                                       ' parse the rtf structure
                                       Dim structureBuilder As New RtfParserListenerStructureBuilder()
                                       Dim parser As New RtfParser(structureBuilder)
                                       parser.IgnoreContentAfterRootGroup = True ' support WordPad documents
                                       If parserLogger IsNot Nothing Then
                                           parser.AddParserListener(parserLogger)
                                       End If
                                       parser.Parse(New RtfSource(stream))
                                       rtfStructure = structureBuilder.StructureRoot
                                   End Using
                               Catch ef As Exception
                                   If parserLogger IsNot Nothing Then
                                       parserLogger.Dispose()
                                   End If
                                   Trace.WriteLine("error while parsing rtf: " & ef.Message)
                                   Return Nothing
                               End Try
                               Return rtfStructure
                           End Function
                _lamInterPreterRTF = Function(rtfStructure As IRtfGroup) As IRtfDocument
                                     Dim rtfDocument As IRtfDocument
                                     Dim interpreterLogger As RtfInterpreterListenerFileLogger = Nothing
                                     Try
                                      Dim interpreterSettings As New Itenso.Rtf.Interpreter.RtfInterpreterSettings()
                                         interpreterSettings.IgnoreDuplicatedFonts = False
                                         interpreterSettings.IgnoreUnknownFonts = False

                                      
                                         rtfDocument = RtfInterpreterTool.BuildDoc(rtfStructure, interpreterLogger)
                                     Catch edf As Exception
                                         If interpreterLogger IsNot Nothing Then
                                             interpreterLogger.Dispose()
                                         End If

                                         Trace.WriteLine("error while interpreting rtf: " & edf.Message)
                                         Return Nothing
                                     End Try
                                     Return rtfDocument
                                 End Function ' InterpretRtf
            _lamConvertXML = Function(rtfDocumentHere As IRtfDocument)
                                 Try
                                     Dim xmlWriterSettings As New XmlWriterSettings()
                                     xmlWriterSettings.Indent = True
                                     xmlWriterSettings.IndentChars = ("  ")
                                     xmlWriterSettings.Encoding = Encoding.Unicode

                                     Using writer As XmlWriter = XmlWriter.Create(_tmpXMLFile$, xmlWriterSettings)
                                         Dim xmlConvertSettings As New RtfXmlConvertSettings()
                                         '  xmlConvertSettings.Prefix = ""
                                         '  xmlConvertSettings.Ns = ""
                                         '   xmlConvertSettings.IsShowHiddenText = False
                                         Dim xmlConverter As New RtfXmlConverter(rtfDocumentHere, writer, xmlConvertSettings)
                                         xmlConverter.Convert()
                                         writer.Flush()
                                     End Using
                                 Catch eff As Exception
                                     Trace.WriteLine("error while converting to xml: " & eff.Message)
                                 End Try
                                 Return True
                             End Function ' ConvertXml


pc8181 avatar Feb 27 '18 13:02 pc8181