Can we pass any user defined object to conversion from Docx to Doc

Hi Aspose,
i have code which need to convert from Docx to Doc, while conversion , Aspose not able to maintain password protection, which was in my last thread, so for time begin , while aspose release patch i want to handle in differnt way.

Letter letter = new letter();
letter = Some thing by user object
// letter.CreatePackage(stream); // password protection want to use end of line
// Docx to Doc Conversion
Aspose.Words.SaveFormat outputFormat = Aspose.Words.SaveFormat.Doc;
Aspose.Words.Document doc = new Aspose.Words.Document(stream);
Aspose.Words.Document doc = new Aspose.Words.Document(letter);
[i want]
Aspose.Words.ProtectionType protectionType = doc.ProtectionType;
doc.Save(stream, outputFormat);
doc.Save(letter, outputFormat);
[i want]
letter.CreatePackage(stream); // here want to use

can i do.
below code sinppset how old and how new which i want to look like
old Code

letter.CreatePackage(stream);
// Docx to Doc Conversion
Aspose.Words.SaveFormat outputFormat = Aspose.Words.SaveFormat.Doc;
Aspose.Words.Document doc = new Aspose.Words.Document(stream);
Aspose.Words.ProtectionType protectionType = doc.ProtectionType;
doc.Save(stream, outputFormat);

NEW Code [ i want , wish can work]

Aspose.Words.SaveFormat outputFormat = Aspose.Words.SaveFormat.Doc;
Aspose.Words.Document doc = new Aspose.Words.Document(letter);
Aspose.Words.ProtectionType protectionType = doc.ProtectionType;
doc.Save(letter, outputFormat);
letter.CreatePackage(stream);

Thanks and Regards

Hi

Thanks for your request. Actually, I do not understand how you would like to work this problem around.
Let me explain the reason of the problem. In Word documents protection password is stored as hash code. But in DOCX and DOC formats different algorithms of hashing are used. As you may know, it is impossible to get the original value from hash, so when you enter password, hash code of this password is calculated then calculated hash and hash, which is stored in the document, are compared.
It is possible, however, to preserve password during converting DOC to DOCX because DOCX hash is calculated like shown below:

[Original Password] -> [Calculating DOC hash] -> [Performing additional actions on DOC hash to calculate DOCX hash]

So it is possible to get hash code stored in the DOC file and calculate hash code for DOCX document, but it is impossible to perform inverse actions to calculate DOC hash from DOCX hash.
You can also try saving your DOCX document to DOC using MS Word and you will see that in DOC file password is lost as well. So I close the issue in our defect database, because it is not a bug, but expected behavior.
The only way to preserve password is “reprotect” document before saving. For instance, see the following code:

Document doc = new Document(@"Test001\in.docx");
doc.Protect(ProtectionType.ReadOnly, "mypassword");
doc.Save(@"Test001\out.doc");

But in this case you should know the original password.
Hope this helps.
Best regards.

I think This is good idea, i can set password,

doc.Protect(ProtectionType.ReadOnly, "mypassword");

but can i set password as
Hash = “1qYbFPV2bFX/WpB/ii0KfllanDc=”,
Salt = “hIqOl99kIr/+N0hyovEq7Q==”
so i can keep same format, and due to security reason i can keep same way

Hi

Thanks for your request. There is no way to set password as hash.
Best regards,