473,549 Members | 2,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XslTransform in msword application with images

Hi,

I transform XML data in an OutputStream which is open as a word document.
All works fine excepted the images defined in the xsl file which are html
links (src="images/image1.jpg").
So, when I save the word document in a particular place, the image can't be
displayed cause the path is no good anymore.
I would like to merge the images in the word document without any external
html links.
Any idea?

aspx file :
XslTransform xslt = new XslTransform();
xslt.Load(cvXSL Chemin);
xslt.Transform( xPathXMLData,nu ll,Response.Out putStream,null) ;
Response.Conten tType = "Applicatio n/msword";
Response.Flush( );
Response.Close( );
......

XSL file :
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:styleshe et xmlns:xsl='http ://www.w3.org/1999/XSL/Transform'
version='1.0'>
<xsl:output method="html" media-type="applicati on/msword"/>
<xsl:template match="/">
<html><body>
<img width="126" height="91" src="images/image1.jpg"/></TD>
<xsl:value-of select="//Qualification"/>
.....
Regards.

Nov 12 '05 #1
2 3953
Hi Guillaume

Well the output of your XSL transformation will have to be well-formed XML
(or HTML or Text...) - so the only way that you could embed image data into
your document would be via base 64 or bin hex encoding...and then the
receiving application would need to support reading the image data from the
encoded data. AFAIK, Word won't do that. What about going for an absolute URL
in your output? Will that not work for you?

Nigel Armstrong

"Guillaume Durand" wrote:
Hi,

I transform XML data in an OutputStream which is open as a word document.
All works fine excepted the images defined in the xsl file which are html
links (src="images/image1.jpg").
So, when I save the word document in a particular place, the image can't be
displayed cause the path is no good anymore.
I would like to merge the images in the word document without any external
html links.
Any idea?

aspx file :
XslTransform xslt = new XslTransform();
xslt.Load(cvXSL Chemin);
xslt.Transform( xPathXMLData,nu ll,Response.Out putStream,null) ;
Response.Conten tType = "Applicatio n/msword";
Response.Flush( );
Response.Close( );
.....

XSL file :
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:styleshe et xmlns:xsl='http ://www.w3.org/1999/XSL/Transform'
version='1.0'>
<xsl:output method="html" media-type="applicati on/msword"/>
<xsl:template match="/">
<html><body>
<img width="126" height="91" src="images/image1.jpg"/></TD>
<xsl:value-of select="//Qualification"/>
....
Regards.

Nov 12 '05 #2
Hi Nigel
Thanks for yous fast reply !
What about going for an absolute URL in your output?

it's a tip which will works in most case but not all, nevertheless it will
certainly be my solution.

For the base 64 encoded data, i'm just trying this way, but i'm not sure to
succeed in :

XSL File :
<img width="126" height="91"
src="http://portail.cso-info.fr/_layouts/viveris.jpg">
<xsl:attribut e name="src">data :image/jpg,base64;<xsl :value-of
select="//Logo"/></xsl:attribute>
</img>

aspx file :
{
byte[] imageB = GetImage(Server .MapPath("../images/myImage.jpg"));
string stringDecode = Convert.ToBase6 4String(imageB, 0,2642);
....

writer.WriteEle mentString("Log o",stringDecode ); //Ajout de l'image encodee
....
}
............... .............
public byte[] GetImage(string monImage)
{
return getBinaryFile(m onImage);
}
public byte[] getBinaryFile(s tring filename)
{
FileStream s=File.OpenRead (filename);
return ConvertStreamTo ByteBuffer(s);
}

public byte[] ConvertStreamTo ByteBuffer(Syst em.IO.Stream theStream)
{
int b1;
System.IO.Memor yStream tempStream = new System.IO.Memor yStream();
while((b1=theSt ream.ReadByte() )!=-1)
{
tempStream.Writ eByte(((byte)b1 ));
}
return tempStream.ToAr ray();
}

Nov 12 '05 #3

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

Similar topics

1
1381
by: Animesh Sharma | last post by:
Hi, Following template matches correctly in MSXML4 but NOT with .Net XSL translator: <xsl:template match="//input]"> <--Do Some operation> </xsl:template>
0
1639
by: Tom Gao | last post by:
hi guys I'm trying to export an aspx page to msword. ############# I know you can do Response.Clear(); Response.ContentType="application/msword";
2
3614
by: John Meyer | last post by:
I have an application where I create an xml fragment using an XslTransform object. However, if I use the following output method, <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="no" omit-xml-declaration="yes" standalone="no" /> some of my transforms fail with the following exception: System.Xml.Xsl.XsltException: There...
0
1396
by: Matthew | last post by:
Hi all, I am attempting to cache a loaded XslTransform object using the cache application block. I get "System.Xsl.XslTransform.....is not marked as serializable" I guess the cache appl block uses serialization internally, but I am a little surprised that its impossible to cache these objects. Seems like the XmlDocument class would be the...
3
2260
by: Steve | last post by:
Is there any way of specifying the startMode when using the xslTransform class? We are updating code which used msxml to the system.xml classes but can find no way to specify the startMode. We use this so that we can specify different templates to be used by the same xml node. Know that we could use global params, but would rather not...
3
2690
by: Pat Buxton | last post by:
I am transforming xml using XSLTransform which works fine. The xsl file is stored on eg. C:\temp1 and the xml is loaded from c:\temp2. All image files referenced in the stylesheet file are stored on the same path as the stylesheet and are not used in the transform. How do I use an XMLResolver to transform using the images without having to...
6
1813
by: Peter | last post by:
I have to write a ASP.NET application that creates MSWord document from a template and populated with data from the webpage. (Templates can reside on the server or client's hard drive.) What is the best way to do this? Is it good idea to have MSWord installed on the server? If it's not a good idea or if MSWord is not installed on the server...
1
1500
by: rmgalante | last post by:
Hello, I have a VB.Net component that uses the XslTransform object. I am using the FXSL randomizeList function in my XSL template. When I transform the XML in the VB.Net component, my application hangs. When I load the XML in a browser with a reference to the XSL template, it works fine. Here is my XML:
0
1033
by: arkark | last post by:
Hi I Need Very Urgent In My Project I access the msword, in Msword header section just i insert the text only. I unable to insert the images.how can i insert the image in msword header using asp dotnet and vb code?
0
7518
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, 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...
1
7469
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...
0
6040
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5368
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5087
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...
0
3498
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...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1057
muto222
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.