Word Templates - Can I Stream It To the User Workstation?

I store a library of Microsoft Word templates on my server. From a web page, the user selects a template and it is then downloaded to the workstation using a Response.Writefile command.
However, before downloading, I want to use Aspose Words to fill in bookmarked items using some data entered into a web form and submittted by the user. Question: Do I need to save the modified template to disk before I download the template (Word document) or can I simply stream it to the user’s workstation?
Thank you

Hi
Thank you for your interest in Aspose.Words. No, you can send file directly to a client browser. For example see the following code.

Document doc = new Document(Server.MapPath("template.doc"));
//here is code thatyou use to fill you template
doc.Save("outputfile.doc", SaveFormat.Doc, SaveType.OpenInWord, Response);

Also, see the following link.
https://docs.aspose.com/words/net/save-a-document/
I hope that this will help you.
Best regards.

I tried this code and it sends it directly to my browser, which is what I want. Is it also saving it somewhere? I couldn’t find it.

Hi
Thanks for your inquiry. This function doesn’t save document anywhere on your machine. This save method works like the following code.

MemoryStream stream = new MemoryStream();
doc.Save(stream, SaveFormat.Doc);
byte[] bytes = stream.GetBuffer();
Response.Clear();
//Specify the document type.
Response.ContentType = "application/msword";
//Other options:
//Response.ContentType = "text/plain"
//Response.ContentType = "text/html"
//Specify how the document is sent to the browser.
Response.AddHeader("content-disposition", "attachment; filename=test.doc");
//Another option could be:
//Response.AddHeader "content-disposition","inline; filename=MyDocument.doc"; 
//Get data bytes from the stream and send it to the response.
Response.BinaryWrite(bytes);
Response.End();

Best regards.

Perfect! Thank you!
Is there anyway to specify a path in addition to the filename? When the file is opened by the user, I would like to have it preset to save to an existing folder. I didn’t see anything in BuiltInDocProperties for the filepath.

Hi
Thanks for your inquiry. Unfortunately, this is impossible.
Best regards.