Problem with DOTX file


Hi, creating a document based on a dotx file is loaded and saved empty.

The libraries tell me that the file is corrupted.

When I convert the file to a dot type it works.

I attached both files.

Working with words 17.8 (114.4 KB)



Thanks for your inquiry. We will appreciate it if you please share your sample code here. It will help us to investigate and address your issue exactly.



The Document (commented) piece of code works.
The Template piece of code does not work.
Which makes me wonder if this is even correct or that I should create a doc using the path no matter if it is an actual document or a template?

public class Test {
	public static void main(String [] args) {
		Test test = new Test();

	public Test() {
		Document doc = null;
		FileOutputStream outputStream = null;
		String templatePath = "/Users/marceltrapman/Desktop/Bewilligung.dotx";
		String documentPath = "/Users/marceltrapman/Desktop/Test.docx";

		try {
			// Template
			doc = new Document();

			doc.setAttachedTemplate( templatePath );

			// Document
//			doc = new Document( templatePath );

			// Save
			outputStream = new FileOutputStream( documentPath ); outputStream, SaveFormat.DOCX );
		catch ( Exception e ) {



Thanks for your inquiry. Please note that Document.AttachedTemplate property gets or sets the full path of the template attached to the document. You are facing the expected behavior of Aspose.Words. You can import DOT or DOTX into Aspose.Words DOM and save it to DOCX. Importing the document (DOT or DOTX) into Aspose.Words DOM is different from attaching the template document to a document (DOCX or DOC).

Pleas let us know if you have any more queries.

String templatePath = MyDir + "/Users/marceltrapman/Desktop/Bewilligung.dotx";
String documentPath = MyDir + "/Users/marceltrapman/Desktop/Test.docx";

// Template
Document doc = new Document(templatePath);

// Save
FileOutputStream outputStream = new FileOutputStream( documentPath ); outputStream, SaveFormat.DOCX );


Hi Tahir,
This is on a Mac so it is the full path.
But whatever I do it seems to work with a doc and a dot format file.
When it is a docx or a dotx file it does not work anymore.

Having said that I must add the following:

It works when I run the code from within IntelliJ.
When running the code in my application it does not.
I run de code with a JWS client (client server).

Have you ever seen something like this before or can you give me a hint?





Thanks for your inquiry.

To ensure a timely and accurate response, please attach the following detail here for testing:

  • If you are facing any exception while using the shared code example, please share the exception detail.
  • If you are facing the incorrect output, please attach the output Word file.
  • Please share your expected output document that shows the desired behavior.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.


This is the error:

com.aspose.words.FileCorruptedException: The document appears to be corrupted and cannot be loaded.

The files are attached.
The dotx file is the original, the other 3 files are all derived from that… (221.7 KB)



Thanks for sharing the documents. Perhaps, you are using older version of Aspose.Words; as with Aspose.Words 17.8, we are unable to reproduce this problem on our side using following code. We would suggest you please upgrade to the latest version of Aspose.Words for Java 17.8 and let us know how it goes on your side. Hope this helps you.

Document docx = new Document(MyDir + "Bewilligung.docx");
Document dotx = new Document(MyDir + "Bewilligung.dotx");


Hi, as mentioned in my first post I am working with 17.8.

I too have no issues when running the code form within IntelliJ but as soon as it runs in my own application, through JWS (client server) it is an issue.

I did not have this issue with previous versions or maybe it is related to previous java (now using J8).

So my question is, do you know if this ever happened to somebody before?



Thanks for sharing the detail. We are investigating this issue and will get back to you soon.



Thanks for your patience. We have deployed the sample application as Java Web Start application using Aspose.Words for Java 17.8, JDK 1.8.0_141 and Apache Tomcat-8.5.11. But I am afraid, we are unable to replicate your reported exception. We will appreciate it if you please share some more details to reproduce the issue at our end.

We are sorry for the inconvenience.



So that is not the reason.

It used to work though so here are a couple of questions I have:

  1. Did you change (essential) code or libraries for reading the DOCX and DOTX files?
  2. Could it be that you (started) use(ing) an open library, maybe wrapped in your jar, that could be interfering with another and/or older library?
  3. Is there anything else you can think of that makes for this behavior (there must be something different in reading these two file formats from the rest)?

Just looking for reasons because I need to solve this…





Thanks for your feedback. We will appreciate it if you please confirm which version was working fine at your end previously and share complete stack trace of error as well. We will further investigate the issue and will guide you.

Furthermore, please note we have not changed any thing in our API to read DOCX/DOTX.


There is no stacktrace :frowning:

It just produces an empty document.

I will have to check what version worked/works.



Thanks for your feedback. As per your statement, we assumed that you are getting some exception/error from Aspose.Words API. We are also getting empty document when attaching DOTX file to an empty DOCX file using setAttachedTemplate method and as already stated above it is expected behavior.

However, please confirm which version was working differently. So we will investigate it and will guide you accordingly.



It is not an issue with setAttachedTemplate and it is also not a client-server thing (I found that out after building a simple app myself to be completely sure).

It looks like, but I am not 100% sure yet, an issue with mixing different libraries.
No definitive answer yet but you can lay this one to rest unless I report back again…



Thanks for your feedback. Sure, we will investigate it further as soon as you share some more information to replicate the issue at our end.