1
votes

We are importing a source database X to our target database Y.

X has blobs of text in RTF format which are somehow displayed in its application.

Our web app can't display RTF, so we were instructed to convert those blobs of RTF into files in our database Y.

We simply copy the RTF blob from X, where it is nvarchar, into a column in Y which we already use for storing attachments, which is of type varbinary. Then we write it out as a file foo.rtf when the user wants to view it - so they can download and open the RTF in Word.

Unfortunately the foo.rtf file, when opened in Word, just looks like raw RTF, Something like

{\rtf1\ansi\ansicpg1252\deff0\deftab1134{\fonttbl{....

What do we need to do in order to correctly convert this RTF "blob of text" into an actual RTF file? It looks like just saving the bytes doesn't work.

Thank you.

2

2 Answers

1
votes

Did you save the file using the extension .rtf -- I know Word opens RTF files just fine that way (assuming the rtf is valid of course)?

ADDED

Something else is wrong then, I did a web site where I generated .RTF file with a few thousand users, with a low level of sophistication -- not a single complaint about problems opening them in word

ADDED MORE

Be sure that you check that the web server is serving up the correct MIME doc type for your files (if rendered in the browser). IIS, APache, etc. do this in different ways

0
votes

It turns out the source and target encodings were different. We used Cast(Cast(Value as Varchar(max)) as Varbinary) and that made everything work.