p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 2.0 Professional (http://p2p.wrox.com/forumdisplay.php?f=215)
-   -   export asp.net page to ms word and embed images (http://p2p.wrox.com/showthread.php?t=65211)

Itech January 11th, 2008 05:59 PM

export asp.net page to ms word and embed images
 
Hello All,

I am using this code snippet to export the contents of my asp.net page to an ms word doc giving the user the option to "Open", "Save", "Cancel".

            Response.ClearHeaders();
            Response.Clear(); //this clears the Response of any headers or previous output
            Response.Buffer = true; //make sure that the entire output is rendered simultaneously
                    Response.ContentType = "application/msword";
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + _ProjDocEntity.DocTitle + ".doc");

anyhow, when i do a local save of the created word doc, the pictures within the word doc(outputted html) are simply image references to the location of it on the web server. well, i need to create this word doc and instead of having the images as references, i need them to be embedded into the word doc the same as if i were to issue a "Insert Picture" from within ms word.

Do any of you know how to export an asp.net page into ms word and have the images embedded into the file so that the contents of the ms word doc are completely disconnected from any references to any external resources i.e. <img refs etc.?

thanks in advance.


bhawesh.sengg June 9th, 2011 12:08 AM

export asp.net page to ms word and embed images
 
Does any one find solution for reported issue so far? How can I embed image in word document from ASP.NET. Any clue?
Note: I'm working with VS2010.

PerttiOO March 6th, 2014 03:39 AM

RE: export asp.net page to ms word and
 
Hi, try using this .NET Word component for your conversion. I tested it out and it does create images from the URI referenced images.
Also it has a simple API for exporting Word file in ASP.NET with this Save method:
Code:

// Empty document.
var document = new DocumentModel();

// ...

// Stream the document to a browser.
document.Save(this.Response, "Document.docx");



All times are GMT -4. The time now is 09:09 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.