Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Writing Your Own RTF Converter

, 1 Aug 2013
An article on how to write a custom RTF parser and converter.
rtfconverter_sourcecode.zip
RtfConverter_SourceCode
bin
Debug
Release
Itenso.Rtf.Converter.Html.dll
Itenso.Rtf.Converter.Xml.dll
Itenso.Rtf.Interpreter.dll
Itenso.Rtf.Parser.dll
Itenso.Sys.dll
log4net.dll
nunit-console-runner.dll
nunit.core.dll
nunit.framework.dll
nunit.util.dll
Rtf2Html.exe
Rtf2Raw.exe
Rtf2Xml.exe
RtfInterpreterTests.exe
RtfParserTests.exe
RtfWindows.exe
RtfWinForms.exe
Converter
Html
Properties
Xml
Properties
docu
Word2007RTFSpec9.pdf
ext
log4net.dll
nunit-console-runner.dll
nunit.core.dll
nunit.framework.dll
nunit.util.dll
Interpreter
Converter
Image
Text
Interpreter
Model
Properties
Support
InterpreterTests
Properties
RtfInterpreterTest
RtfInterpreterTest_0.rtf
RtfInterpreterTest_1.rtf
RtfInterpreterTest_10.rtf
RtfInterpreterTest_11.rtf
RtfInterpreterTest_12.rtf
RtfInterpreterTest_13.rtf
RtfInterpreterTest_14.rtf
RtfInterpreterTest_15.rtf
RtfInterpreterTest_16.rtf
RtfInterpreterTest_17.rtf
RtfInterpreterTest_18.rtf
RtfInterpreterTest_19.rtf
RtfInterpreterTest_2.rtf
RtfInterpreterTest_20.rtf
RtfInterpreterTest_21.rtf
RtfInterpreterTest_22.rtf
RtfInterpreterTest_23.rtf
RtfInterpreterTest_3.rtf
RtfInterpreterTest_4.rtf
RtfInterpreterTest_4.rtf.jpg
RtfInterpreterTest_4.rtf.jpg.hex
RtfInterpreterTest_5.rtf
RtfInterpreterTest_5.rtf.png
RtfInterpreterTest_5.rtf.png.hex
RtfInterpreterTest_6.rtf
RtfInterpreterTest_6.rtf.wmf
RtfInterpreterTest_6.rtf.wmf.hex
RtfInterpreterTest_7.rtf
RtfInterpreterTest_7.rtf.emf
RtfInterpreterTest_7.rtf.emf.hex
RtfInterpreterTest_8.rtf
RtfInterpreterTest_8.rtf.wmf
RtfInterpreterTest_8.rtf.wmf.hex
RtfInterpreterTest_9.rtf
RtfInterpreterTest_fail_0.rtf
RtfInterpreterTest_fail_1.rtf
RtfInterpreterTest_fail_2.rtf
RtfInterpreterTest_fail_3.rtf
RtfInterpreterTest_fail_4.rtf
keys
ItensoRtfConverter.snk
Parser
Model
Parser
Properties
Support
ParserTests
Properties
RtfParserTest
minimal.rtf
RtfParserTest_0.rtf
RtfParserTest_1.rtf
RtfParserTest_2.rtf
RtfParserTest_3.rtf
RtfParserTest_4.rtf
RtfParserTest_5.rtf
RtfParserTest_6.rtf
RtfParserTest_7.rtf
RtfParserTest_8.rtf
RtfParserTest_fail_0.rtf
RtfParserTest_fail_1.rtf
RtfParserTest_fail_2.rtf
RtfParserTest_fail_3.rtf
RtfParserTest_fail_4.rtf
RtfParserTest_fail_5.rtf
RtfParserTest_fail_6.rtf
Rtf2Html
Properties
Rtf2Raw
Properties
Rtf2Xml
Properties
RtfWindows
Properties
RtfWinForms
DefaultText.rtf
Properties
Sys
Application
Collection
Logging
Properties
Test
RtfConverter_v1.7.0.zip
Rtf2Xml
Properties
bin
Release
Itenso.Rtf.Converter.Html.dll
Itenso.Rtf.Converter.Xml.dll
Itenso.Rtf.Interpreter.dll
Itenso.Rtf.Parser.dll
Itenso.Sys.dll
log4net.dll
nunit-console-runner.dll
nunit.core.dll
nunit.framework.dll
nunit.util.dll
Rtf2Html.exe
Rtf2Raw.exe
Rtf2Xml.exe
RtfInterpreterTests.exe
RtfParserTests.exe
RtfWindows.exe
RtfWinForms.exe
Converter
Html
Properties
Xml
Properties
docu
Word2007RTFSpec9.pdf
ext
log4net.dll
nunit-console-runner.dll
nunit.core.dll
nunit.framework.dll
nunit.util.dll
Interpreter
Converter
Image
Text
Interpreter
Model
Properties
Support
InterpreterTests
Properties
RtfInterpreterTest
RtfInterpreterTest_0.rtf
RtfInterpreterTest_1.rtf
RtfInterpreterTest_10.rtf
RtfInterpreterTest_11.rtf
RtfInterpreterTest_12.rtf
RtfInterpreterTest_13.rtf
RtfInterpreterTest_14.rtf
RtfInterpreterTest_15.rtf
RtfInterpreterTest_16.rtf
RtfInterpreterTest_17.rtf
RtfInterpreterTest_18.rtf
RtfInterpreterTest_19.rtf
RtfInterpreterTest_2.rtf
RtfInterpreterTest_20.rtf
RtfInterpreterTest_21.rtf
RtfInterpreterTest_22.rtf
RtfInterpreterTest_23.rtf
RtfInterpreterTest_3.rtf
RtfInterpreterTest_4.rtf
RtfInterpreterTest_4.rtf.jpg
RtfInterpreterTest_4.rtf.jpg.hex
RtfInterpreterTest_5.rtf
RtfInterpreterTest_5.rtf.png
RtfInterpreterTest_5.rtf.png.hex
RtfInterpreterTest_6.rtf
RtfInterpreterTest_6.rtf.wmf
RtfInterpreterTest_6.rtf.wmf.hex
RtfInterpreterTest_7.rtf
RtfInterpreterTest_7.rtf.emf
RtfInterpreterTest_7.rtf.emf.hex
RtfInterpreterTest_8.rtf
RtfInterpreterTest_8.rtf.wmf
RtfInterpreterTest_8.rtf.wmf.hex
RtfInterpreterTest_9.rtf
RtfInterpreterTest_fail_0.rtf
RtfInterpreterTest_fail_1.rtf
RtfInterpreterTest_fail_2.rtf
RtfInterpreterTest_fail_3.rtf
RtfInterpreterTest_fail_4.rtf
keys
ItensoRtfConverter.snk
Parser
Model
Parser
Properties
Support
ParserTests
Properties
RtfParserTest
minimal.rtf
RtfParserTest_0.rtf
RtfParserTest_1.rtf
RtfParserTest_2.rtf
RtfParserTest_3.rtf
RtfParserTest_4.rtf
RtfParserTest_5.rtf
RtfParserTest_6.rtf
RtfParserTest_7.rtf
RtfParserTest_8.rtf
RtfParserTest_fail_0.rtf
RtfParserTest_fail_1.rtf
RtfParserTest_fail_2.rtf
RtfParserTest_fail_3.rtf
RtfParserTest_fail_4.rtf
RtfParserTest_fail_5.rtf
RtfParserTest_fail_6.rtf
Rtf2Html
Properties
Rtf2Raw
Properties
RtfWindows
Properties
RtfWinForms
DefaultText.rtf
Properties
Sys
Application
Collection
Logging
Properties
Test
// -- FILE ------------------------------------------------------------------
// name       : LoggerImplBase.cs
// project    : System Framelet
// created    : Leon Poyyayil - 2008.05.14
// language   : c#
// environment: .NET 2.0
// copyright  : (c) 2004-2010 by Itenso GmbH, Switzerland
// --------------------------------------------------------------------------
using System;

namespace Itenso.Sys.Logging
{

	// ------------------------------------------------------------------------
	public abstract class LoggerImplBase : LoggerBase, ILogger
	{

		// ----------------------------------------------------------------------
		protected LoggerImplBase()
		{
			level = LoggerLevel.Warn;
		} // LoggerImplBase

		// ----------------------------------------------------------------------
		protected LoggerImplBase( LoggerLevel level )
		{
			this.level = level;
		} // LoggerImplBase

		// ----------------------------------------------------------------------
		public LoggerLevel Level
		{
			get { return level; }
			set { level = value; }
		} // Level

		// ----------------------------------------------------------------------
		public bool IsDebugEnabled
		{
			get { return LoggerLevel.Debug.CompareTo( level ) <= 0; }
		} // IsDebugEnabled

		// ----------------------------------------------------------------------
		public bool IsInfoEnabled
		{
			get { return LoggerLevel.Info.CompareTo( level ) <= 0; }
		} // IsInfoEnabled

		// ----------------------------------------------------------------------
		public bool IsWarnEnabled
		{
			get { return LoggerLevel.Warn.CompareTo( level ) <= 0; }
		} // IsWarnEnabled

		// ----------------------------------------------------------------------
		public bool IsErrorEnabled
		{
			get { return LoggerLevel.Error.CompareTo( level ) <= 0; }
		} // IsErrorEnabled

		// ----------------------------------------------------------------------
		public bool IsFatalEnabled
		{
			get { return LoggerLevel.Fatal.CompareTo( level ) <= 0; }
		} // IsFatalEnabled

		// ----------------------------------------------------------------------
		public bool IsEnabledFor( LoggerLevel loggerLevel )
		{
			return loggerLevel.CompareTo( level ) <= 0;
		} // IsEnabledFor

		// ----------------------------------------------------------------------
		public virtual void Debug( object message )
		{
			Log( LoggerLevel.Debug, message );
		} // Debug

		// ----------------------------------------------------------------------
		public virtual void Debug( object message, Exception exception )
		{
			Log( LoggerLevel.Debug, message, exception );
		} // Debug

		// ----------------------------------------------------------------------
		public virtual void DebugFormat( string format, params object[] args )
		{
			LogFormat( LoggerLevel.Debug, format, args );
		} // DebugFormat

		// ----------------------------------------------------------------------
		public virtual void DebugFormat( IFormatProvider provider, string format, params object[] args )
		{
			LogFormat( LoggerLevel.Debug, provider, format, args );
		} // DebugFormat

		// ----------------------------------------------------------------------
		public virtual void Info( object message )
		{
			Log( LoggerLevel.Info, message );
		} // Info

		// ----------------------------------------------------------------------
		public virtual void Info( object message, Exception exception )
		{
			Log( LoggerLevel.Info, message, exception );
		} // Info

		// ----------------------------------------------------------------------
		public virtual void InfoFormat( string format, params object[] args )
		{
			LogFormat( LoggerLevel.Info, format, args );
		} // InfoFormat

		// ----------------------------------------------------------------------
		public virtual void InfoFormat( IFormatProvider provider, string format, params object[] args )
		{
			LogFormat( LoggerLevel.Info, provider, format, args );
		} // InfoFormat

		// ----------------------------------------------------------------------
		public virtual void Warn( object message )
		{
			Log( LoggerLevel.Warn, message );
		} // Warn

		// ----------------------------------------------------------------------
		public virtual void Warn( object message, Exception exception )
		{
			Log( LoggerLevel.Warn, message, exception );
		} // Warn

		// ----------------------------------------------------------------------
		public virtual void WarnFormat( string format, params object[] args )
		{
			LogFormat( LoggerLevel.Warn, format, args );
		} // WarnFormat

		// ----------------------------------------------------------------------
		public virtual void WarnFormat( IFormatProvider provider, string format, params object[] args )
		{
			LogFormat( LoggerLevel.Warn, provider, format, args );
		} // WarnFormat

		// ----------------------------------------------------------------------
		public virtual void Error( object message )
		{
			Log( LoggerLevel.Error, message );
		} // Error

		// ----------------------------------------------------------------------
		public virtual void Error( object message, Exception exception )
		{
			Log( LoggerLevel.Error, message, exception );
		} // Error

		// ----------------------------------------------------------------------
		public virtual void ErrorFormat( string format, params object[] args )
		{
			LogFormat( LoggerLevel.Error, format, args );
		} // ErrorFormat

		// ----------------------------------------------------------------------
		public virtual void ErrorFormat( IFormatProvider provider, string format, params object[] args )
		{
			LogFormat( LoggerLevel.Error, provider, format, args );
		} // ErrorFormat

		// ----------------------------------------------------------------------
		public virtual void Fatal( object message )
		{
			Log( LoggerLevel.Fatal, message );
		} // Fatal

		// ----------------------------------------------------------------------
		public virtual void Fatal( object message, Exception exception )
		{
			Log( LoggerLevel.Fatal, message, exception );
		} // Fatal

		// ----------------------------------------------------------------------
		public virtual void FatalFormat( string format, params object[] args )
		{
			LogFormat( LoggerLevel.Fatal, format, args );
		} // FatalFormat

		// ----------------------------------------------------------------------
		public virtual void FatalFormat( IFormatProvider provider, string format, params object[] args )
		{
			LogFormat( LoggerLevel.Fatal, provider, format, args );
		} // FatalFormat

		// ----------------------------------------------------------------------
		public virtual void Log( LoggerLevel loggerLevel, object message )
		{
			Log( loggerLevel, message, null );
		} // Log

		// ----------------------------------------------------------------------
		public virtual void Log( LoggerLevel loggerLevel, object message, Exception exception )
		{
			if ( IsEnabledFor( loggerLevel ) )
			{
				Output( loggerLevel, message, exception );
			}
		} // Log

		// ----------------------------------------------------------------------
		public virtual void LogFormat( LoggerLevel loggerLevel, string format, params object[] args )
		{
			Log( loggerLevel, string.Format( format, args ) );
		} // LogFormat

		// ----------------------------------------------------------------------
		public virtual void LogFormat( LoggerLevel loggerLevel, IFormatProvider provider, string format, params object[] args )
		{
			Log( loggerLevel, string.Format( provider, format, args ) );
		} // LogFormat

		// ----------------------------------------------------------------------
		protected abstract void Output( LoggerLevel level, object message, Exception exception );

		// ----------------------------------------------------------------------
		protected sealed override ILogger Logger
		{
			get { return this; }
		} // Logger

		// ----------------------------------------------------------------------
		// members
		private LoggerLevel level;

	} // class LoggerNone

} // namespace Itenso.Sys.Logging
// -- EOF -------------------------------------------------------------------

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Jani Giannoudis
Software Developer (Senior)
Switzerland Switzerland
Jani is Co-founder of Meerazo.com, a free service which allows to share resources like locations, things, persons and their services in a cooperating group of people.

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 1 Aug 2013
Article Copyright 2008 by Jani Giannoudis
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid