We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Re: Create new document from template

Hi Anders,

Thanks for your inquiry. Aspose.Words for .NET is a class library that enables your applications to perform a great range of document processing tasks. Aspose.Words supports DOC, DOCX, RTF, HTML, OpenDocument, PDF, XPS, EPUB and other formats. With Aspose.Words you can generate, modify, convert, render and print documents without utilizing Microsoft Word®.

You can create a blank document using following code snippet. Note the blank document contains one section and one paragraph. You can set author name, creation date etc after creating blank document. Once you have created the document, you can save it to Dotx/Docx.

Hope this answers your query. Please let us know if you have any more queries.

Document doc = new Document();
doc.BuiltInDocumentProperties.Author = "AsposeWords";
doc.BuiltInDocumentProperties.CreatedTime = DateTime.Now.AddDays(-1);
doc.Save(MyDir + "Out.dotx", SaveFormat.Dotx);

Hi Anders,

Thanks for your inquiry. Aspose.Words for .NET is a class library that enables your applications to perform a great range of document processing tasks. Aspose.Words supports DOC, DOCX, RTF, HTML, OpenDocument, PDF, XPS, EPUB and other formats. With Aspose.Words you can generate, modify, convert, render and print documents without utilizing Microsoft Word®.

You can create a blank document using following code snippet. Note the blank document contains one section and one paragraph. You can set author name, creation date etc after creating blank document. Once you have created the document, you can save it to Dotx/Docx.

Hope this answers your query. Please let us know if you have any more queries.

Document doc = new Document();
doc.BuiltInDocumentProperties.Author = "AsposeWords";
doc.BuiltInDocumentProperties.CreatedTime = DateTime.Now.AddDays(-1);
doc.Save(MyDir + "Out.dotx", SaveFormat.Dotx);

Hi Tahir,

I think that you didn’t answer the question, do you Anders? I have the same question. How do I create a new document from a template?

Your sample just creates a new empty document (from the standard template I suppose) and saves the result as a new template. That wasn’t was Anders asked about.

Can you please read the question again and see if you have another answer? Please let us know if you need any clearifications of the question.

Best regards,
Örjan

Hi Örjan,

Thanks for your inquiry. Yes, you can create new document from a template by using following code example. You need to load your template document into Aspose.Words DOM and save it to your required save file format.

var doc = new Document(MyDir + "in.dotx");
// Your code....
// Your code....
doc.Save(MyDir + "Out.docx");

Yes, the empty document is created from a standard template. You may also attach Template(Dotx) to a Word document by
using Document.AttachedTemplate property. Please see the following code
snippet.

Document doc = new Document();
doc.AttachedTemplate = MyDir + "template.dotx";
// Your code...
doc.Save(MyDir + "Out.docx");

Hope this answers your query. Please
let us know if you have any more queries.