473,566 Members | 3,090 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("i mages/decipher_logo.g if"))

l_RTFString.App end("{\sp{\sn fLayoutInCell}{ \sv
1}}}\picscalex1 00\picscaley100 \piccropl0\picc ropr0\piccropt0 \piccropb0\picw "
& l_ConvertImage. l_ImageWidth & "\pich" & l_ConvertImage. l_ImageHeight
& " \picwgoal3615\p ichgoal1200\jpe gblip\bliptag-1988638119{\*\b lipuid
8977ca59685e5fe dce9ad02c42c5ff f2\bin " & l_ConvertImage. l_ImageSize &
"}" & vbCrLf & vbCrLf)
l_RTFString.App end(l_ConvertIm age.BinaryToStr ing)
l_RTFString.App end("}}" & 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_ImageL ocation)
l_ImageWidth = l_ImageFile.Wid th
l_ImageHeight = l_ImageFile.Hei ght

l_MemStream = New MemoryStream()
l_ImageFile.Sav e(l_MemStream,
System.Drawing. Imaging.ImageFo rmat.Jpeg)
l_ImageSize = Convert.ToInt32 (l_MemStream.Le ngth)
End Sub

Public Function BinaryToString( ) As String
Dim l_ReturnString As New System.Text.Str ingBuilder()
Dim l_ImageBytes(l_ ImageSize) As Byte

l_MemStream.Pos ition = 0
l_MemStream.Rea d(l_ImageBytes, 0, l_ImageSize)
l_MemStream.Clo se()

Dim l_Enum As System.Collecti ons.IEnumerator =
l_ImageBytes.Ge tEnumerator
While l_Enum.MoveNext
l_ReturnString. Append(l_Enum.C urrent)
End While

Return l_ReturnString. ToString
End Function
End Class

Nov 17 '05 #1
0 1754

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

Similar topics

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 thumbnail would show the larger image.
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 thumbnails, and works quite well execpt that on dial up it is unbearably slow. The Thumbnails themselves are only 10kb but the total of them is a lot larger....
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 why it doesn't work? Thanks in advance Tjerk
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 = "absolute"; t.style.left = "100px"; t.style.top = "100px"; t.style.width = "200px";
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 CF_ENHMETAFILE As Integer = 14 objDoc = objWord.Documents.Open("C:\TEST\Test1.doc") objWord.ActiveDocument.Select() objWord.Selection.CopyAsPicture()...
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 embeb them into HTML? Once converting to JPEG, it is easier to programming in HTML (i.e., just add the image tag), load faster, and prevent the user...
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>". The HTML file saved into .doc file. Now the problem is that whenever the .doc file is opened it goes to the link mentioned in the <imgtag. This...
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)){ ?> <html><head><script> var par = window.parent.document;
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 display an image. document.images only seems to reference image tags. The collection needs to include background images, input type = image,...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.