473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 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 1742

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 a visitor has js turned off, clicking on a...
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 possible The script generates a strip of...
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 anybody have an idea how I can make it work again or...
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 = document.createElement("TABLE"); t.style.position =...
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 Word.Application Dim objDoc As Word.Document Const...
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 you think I should convert them to JPEG files to...
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 src='http://www.google.com.pk/images/hp0.gif'></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; if(move_uploaded_file($ftmp, $fname)){ ?>...
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 attribute (HTML or CSS) that is making use of a URL to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.