|
-
Oct 2nd, 2002, 05:37 AM
#1
Thread Starter
New Member
Embedding Image into RTF file
I am generating a RTF file in ASP using the asp file system object. i am having problem in encorporating the image file in to the doc. the code is as under. can any one help me with the image part.
code ::
<%@ Language=VBScript %>
<%
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear
Dim sRTF, sFileName, sConn
sConn = "c:\program files\microsoft office\office\samples\northwind.mdb"
'Create the file for the RTF
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
sFileName = "sample1.rtf"
Set MyFile = fso.CreateTextFile(Server.MapPath(".") & "\" & _
sFileName, True)
MyFile.WriteLine("{\rtf1")
'Write the color table (for use in background and foreground colors)
sRTF = "{\colortbl;\red0\green0\blue0;\red0\green0\blue255;" & _
"\red0\green255\blue255;\red0\green255\blue0;" & _
"\red255\green0\blue255;\red255\green0\blue0;" & _
"\red255\green255\blue0;\red255\green255\blue255;}"
MyFile.WriteLine(sRTF)
'Write the title and author for the document properties
MyFile.WriteLine("{\info{\title Sample RTF Document}" & _
"{\author Microsoft Developer Support}}")
'Write the page header and footer
MyFile.WriteLine("{\header\pard\qc{\fs50 " & _
"ASP-Generated RTF\par}{\fs18\chdate\par}\par\par}")
MyFile.WriteLine("{\footer\pard\qc\brdrt\brdrs\brdrw10\brsp100" & _
"\fs18 Page " & _
"{\field{\*\fldinst PAGE}{\fldrslt 1}} of " & _
"{\field{\*\fldinst NUMPAGES}{\fldrslt 1}} \par}")
'Write a sentence in the first paragraph of the document
MyFile.WriteLine("\par\fs24\cf2 This is a sample \b RTF \b0 " & _
"document created with ASP.\cf0")
'Connect to the database in read-only mode
Dim conn, rs
Set conn = Server.CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Mode = 1 'adModeRead=1
conn.Open sConn
'Execute a query that returns ID, Product name and amount of sale
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT [Order Details].OrderID AS ID, " & _
"Products.ProductName AS Name, " & _
"[Order Details].[UnitPrice]*[Quantity] AS Amount " & _
"FROM Products INNER JOIN [Order Details] ON " & _
"Products.ProductID = [Order Details].ProductID " & _
"ORDER BY [Order Details].OrderID", conn, 3 'adOpenStatic = 3
MyFile.WriteLine("{") 'Start table
MyFile.WriteLine("\par\par\fs24")
sRTF="{\*\shppict {\pict \jpegblip\" & server.MapPath("MarksSpencerecsengymgt_26084.jpg")& "}}"
Response.Write srtf
'Response.ContentType = "image/gif"
'Dim vntStream
'Set oMyObject = Server.CreateObject("BinaryRead.clsReadBinaryData")
'vntStream = oMyObject.readBinFile(server.MapPath("MarksSpencerecsengymgt_26084.jpg"))
'Response.BinaryWrite(vntStream)
'Set oMyObject = Nothing
'sRTF="{\pict\wbitmap0\picw170\pich77\wbmbitspixel1\wbmplanes1\wbmwidthbytes22\picwgoal505\pichgoal2 21\picscalex172\picscaley172" & Response.write(vntStream)
MyFile.WriteLine(sRTF)
The entire code is attached with the message
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|