472,348 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,348 software developers and data experts.

Converting an image for an RTF Document

Hello,

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

However I am having problems converting images into the required RTF
format.

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(l_ConvertImage.BinaryToString)
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_ImageFile.Save(l_MemStream,
System.Drawing.Imaging.ImageFormat.Jpeg)
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)
l_MemStream.Close()

Dim l_Enum As System.Collections.IEnumerator =
l_ImageBytes.GetEnumerator
While l_Enum.MoveNext
l_ReturnString.Append(l_Enum.Current)
End While

Return l_ReturnString.ToString
End Function
End Class

Thanks,
Mark
Nov 17 '05 #1
0 1668

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Richard | last post by:
Considering the elemtary image swap routine in javascript: document.name.src="filename.gif" How would this be translated into PHP? So that if...
2
by: Mekon | last post by:
I have never written a line of script in my life but I need some help with it now. I have this auto generated code which I want to modify if...
2
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does...
7
by: Andrew Poulos | last post by:
I'm using the following code to create a small table with one column and two rows. An image goes into the first cell. //create table var t =...
4
by: mabosch | last post by:
I'm trying to convert a DOC to JPG it works in Windows Forms, but I run under asp.net the clipboard its empty, I'm doing Dim objWord As New...
9
by: Tim | last post by:
Since rtf files cause so many troubles, i.e., allow the users to download the files, slow loading, incompatible with other browser, and so on. Do...
2
by: s.danyal.k | last post by:
Hi All, I have created an application in C# that converts HTML file to MS word documents. The HTML file may also have images , for e.g "<img...
1
by: ajaxnewbie | last post by:
Can someone help me convert the PHP lines below from PHP to Coldfusion? <?php $ftmp = $_FILES; $oname = $_FILES; $fname = 'upload/'.$_FILES;...
6
by: Rob | last post by:
Hello, I'm sure this has come up before. I have need for a collection of all elements/objects in an HTML document that have any kind of an...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.