wpcubed.com Forum Index wpcubed.com
WPCubed GmbH Support Forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Outputting RTF image data stream as ASCII

 
Post new topic   Reply to topic    wpcubed.com Forum Index -> TextDynamic .NET and OCX
View previous topic :: View next topic  
Author Message
Tim



Joined: 10 Mar 2010
Posts: 1

PostPosted: Wed Mar 10, 2010 2:06 pm    Post subject: Outputting RTF image data stream as ASCII Reply with quote

Hi,

I've been working with your TextDynamic control and all seems to be well for text based documents. However, I am unable to store the RTF data in a C# string. Is there a way to do this?

When I save the file using SaveToFile() the file saves correctly. MS Word will open this file but Wordpad and other RTF tools will not. I believe this is because the output from TextDynamic writes the binary data out as 8-bit data bytes. MS word and Wordpad write their binary data out as ASCII encoded data. e.g.:

A byte with all bits set would be written out as the two ASCII characters 'FF'. In this way, the RTF is a pure ASCII document that can contain binary data.

There is also a _huge_ discrepency in the size of your file and the same file generated by other tools. Your file is 62k and MS Word / Wordpad generates a 4.5 meg file (it's a reasonably large image).

Because of the above, when I take your Stream2WPStream to store the data in a MemoryStream everything is fine. When I come to convert that to a C# string it quite naturally terminates on the first null (0) character it finds, and all the binary data is discarded.

Is there an interface method I can call to do this conversion. I really need the file written out in the more normal way as other components expect an ASCII data stream, and not all our customers use MS Word.

Also, I'm sending the RTF data to a third party control and the header and footer information is not appearing. Is this not part of the RTF data? I can see the header and footer text in the actual data, but it doesn't appear to get to the other side.

Any help pointing me in the right direction would be greatly appreciated.

Cheers,

Tim.
Back to top
View user's profile Send private message
wpsupport
Site Admin


Joined: 24 Oct 2003
Posts: 5658

PostPosted: Thu Mar 18, 2010 6:02 am    Post subject: Reply with quote

Hi,

C# strings are always two-byte which makes them a suboptimal choice to store RTF code (which is always ANSI code). You can use SaveToVar to save to a byte[] array.

When you want to avoid binary data in the RTF use

SaveToFile( ..., 'RTF-nobinary')

This works likewise for SaveToString and SaveToVar.

Julian
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    wpcubed.com Forum Index -> TextDynamic .NET and OCX All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group