Discussion:
HtmlToRtf fails to convert
(too old to reply)
Nibu
2009-02-25 15:08:03 UTC
Permalink
Hi there,

I was trying to convert an html file to an rtf file using the HtmlToRtf
class provided in Microsoft.Exchange.Data.TextConverters
(Microsoft.Exchange.Data.Common.dll). But it fails with an exception given
below.

System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="Microsoft.Exchange.Data.Common"
StackTrace:
at
Microsoft.Exchange.Data.TextConverters.ConverterDecodingInput..ctor(Stream
source, Boolean push, Encoding encoding, Boolean
detectEncodingFromByteOrderMark, Int32 maxParseToken, Int32 restartMax, Int32
inputBufferSize, Boolean testBoundaryConditions, IResultsFeedback
resultFeedback, IProgressMonitor progressMonitor)
at
Microsoft.Exchange.Data.TextConverters.HtmlToRtf.CreatePullChain(Stream
input, ConverterStream converterStream)
at
Microsoft.Exchange.Data.TextConverters.ConverterStream..ctor(Stream stream,
TextConverter converter, ConverterStreamAccess access)
at
Microsoft.Exchange.Data.TextConverters.TextConverter.Convert(Stream
sourceStream, Stream destinationStream)
at WindowsFormsApplication1.Form1.button1_Click(Object sender,
EventArgs e) in
e:\Works\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs:line 61
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at WindowsFormsApplication1.Program.Main() in
e:\Works\WindowsFormsApplication1\WindowsFormsApplication1\Program.cs:line 18
InnerException:

The code used is as given here..

StreamReader reader2 = new StreamReader("d:\\rtftohtml.html");
Stream s2 = new
MemoryStream(System.Text.Encoding.Default.GetBytes(reader2.ReadToEnd()));
Stream newrtf = new MemoryStream();
htmlToRtf.Convert(s2, newrtf);

A similar code works fine for RtfToHtml convert.

Any help greatly appreciated..

Thanks..
Nibu.
Nibu
2009-02-25 16:40:01 UTC
Permalink
Adding a few more bits..
Object is created as show below with no other parameters being set..

HtmlToRtf htmlToRtf = new HtmlToRtf();

Thanks.

Loading...