I think I would create a folder under /app_data/ called documents then for each file create a folder with a unique guid then build a custom controller that serves up word docs via some route - e.g. www.mydomain.com/document/docPath=[[guid/filename]]
Or attach it to an email?
Depends on how secure you need these files to be but the guid would ensure that paths aren't guessable.
Just so I understand the process... you have a webpage with an Umbraco form on it. You're creating a workflow that will take the form submission and then generates this word doc - is that right?
I guess you could redirect to the custom controller that will then serve up that form as a download???
public ActionResult Get()
{
MemoryStream ms;
using (ms = new MemoryStream())
{
using (var document = DocX.Create(ms, DocumentTypes.Document))
{
// Add a title
document.InsertParagraph("Adding Custom Properties to a document").FontSize(15d).SpacingAfter(50d).Alignment = Alignment.center;
//Add custom properties to document.
document.AddCustomProperty(new CustomProperty("CompanyName", "Xceed Software inc."));
document.AddCustomProperty(new CustomProperty("Product", "Xceed Words for .NET"));
document.AddCustomProperty(new CustomProperty("Address", "3141 Taschereau, Greenfield Park"));
document.AddCustomProperty(new CustomProperty("Date", DateTime.Now));
// Add a paragraph displaying the number of custom properties.
var p = document.InsertParagraph("This document contains ").Append(document.CustomProperties.Count.ToString()).Append(" Custom Properties :");
p.SpacingAfter(30);
document.Save();
}
}
return File(ms.ToArray(), "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Test.docx");
}
WorkflowType: Output Word Document to client
I have my class file that deals with building my word document from umbraco form values, it uses DocX by Xceed.
Calling it from a WorkflowType class, I cannot get my head around how I can supply this newly created word document to the client.
Hoping someone can point me in the right direction?!
Code in WorkflowType below;
public class UmbracoFormSaveAsWord : WorkflowType {
Hi,
I think I would create a folder under /app_data/ called documents then for each file create a folder with a unique guid then build a custom controller that serves up word docs via some route - e.g. www.mydomain.com/document/docPath=[[guid/filename]]
Or attach it to an email?
Depends on how secure you need these files to be but the guid would ensure that paths aren't guessable.
Steve
Hi Steve,
Thanks for getting back to me so quick!
Would I call this custom controller to serve up the new file from WorkflowType?
Sorry if it sounds like a dumb question.
Hi,
Just so I understand the process... you have a webpage with an Umbraco form on it. You're creating a workflow that will take the form submission and then generates this word doc - is that right?
I guess you could redirect to the custom controller that will then serve up that form as a download???
Hi,
Yes that is indeed a correct assumption. I shall try that.
Thanks
Okay I am still having issues with this... As an example I have a word docx stored in a temp folder to see if it serves, but unfortunately doesn't.
My Workflow calls an ActionResult and it and it does step through find but never serves up the document to the client.
Have to admit that I am now stuck.
Hopefully someone can help...
Even something as simple as this doesn't work;
Building a simple MVC project and running this works, so why does an umbraco project differ?
I have tried both SurfaceController and Controller inheritance..
is working on a reply...