469,631 Members | 1,492 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

Converting an image for an RTF Document


I am creating an RTF document server side for a report.

However I am having problems converting images into the required RTF

I am converting the image into a string (binary) and including the
image syntax as per the RTF Specification, however the image is not
appearing when I view the document in Word or WordPad.

I would greatly appreciate any advice if anyone has done this before.

I have included some code:

Dim l_ConvertImage As New ImageConvert("images/decipher_logo.gif"))

l_RTFString.Append("{\sp{\sn fLayoutInCell}{\sv
1}}}\picscalex100\picscaley100\piccropl0\piccropr0 \piccropt0\piccropb0\picw"
& l_ConvertImage.l_ImageWidth & "\pich" & l_ConvertImage.l_ImageHeight
& " \picwgoal3615\pichgoal1200\jpegblip\bliptag-1988638119{\*\blipuid
8977ca59685e5fedce9ad02c42c5fff2\bin " & l_ConvertImage.l_ImageSize &
"}" & vbCrLf & vbCrLf)
l_RTFString.Append("}}" & vbCrLf)

Private Class ImageConvert
Private l_ImageFile As System.Drawing.Bitmap
Private l_MemStream As MemoryStream
Public l_ImageWidth As Integer
Public l_ImageHeight As Integer
Public l_ImageSize As Integer

Public Sub New(ByVal v_ImageLocation As String)
l_ImageFile = New System.Drawing.Bitmap(v_ImageLocation)
l_ImageWidth = l_ImageFile.Width
l_ImageHeight = l_ImageFile.Height

l_MemStream = New MemoryStream()
l_ImageSize = Convert.ToInt32(l_MemStream.Length)
End Sub

Public Function BinaryToString() As String
Dim l_ReturnString As New System.Text.StringBuilder()
Dim l_ImageBytes(l_ImageSize) As Byte

l_MemStream.Position = 0
l_MemStream.Read(l_ImageBytes, 0, l_ImageSize)

Dim l_Enum As System.Collections.IEnumerator =
While l_Enum.MoveNext
End While

Return l_ReturnString.ToString
End Function
End Class

Nov 17 '05 #1
0 1565

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Richard | last post: by
2 posts views Thread by Mekon | last post: by
2 posts views Thread by Tjerk | last post: by
7 posts views Thread by Andrew Poulos | last post: by
4 posts views Thread by mabosch | last post: by
9 posts views Thread by Tim | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.