Free Support Forum - aspose.com

Aspose Word Password with HotDocs

We are having a problem with using Aspose Word to put a password on a document generated by HotDocs. When the document is generated by HotDocs it will allow Aspose to add a password to the RTF generated file. The problem is that when using Aspose Word to add the password to the RTF it will truncate part of the file. Without the Aspose Word adding the password the RTF document is complete.

We have been using Aspose Word to apply a password for some time to other HotDocs generated files but have not had any problems.

Have you ever seen this and if so what was the fix?

Here is the code used to apply the password to the RTF file:

// Apply the password here.
//
// Set the link to the template name for the user.
lnkDownloadDocument.Text = "Download " + _templateName;
// Open the document.
Document document = new Document(GetFilePathAndName(_fileName));
// Apply protection and password to the document.
document.Protect(ProtectionType.ReadOnly,WebConfigurationManager.AppSettings["WordPassword"]);
// Save the document.
document.Save(GetFilePathAndName(_fileName));
// Log to the database that the password was applied.
Utils.LogPasswordStatus(_fileName, _templateName, "Password has been added to the file.");

Hi,

Thanks for your inquiry. Could you please attach your input RTF document here for testing? I will investigate the issue on my side and provide you more information.

Attached is the RTF document that is cutoff. Let me kno wif you need anything.

Hi,


Thanks for sharing the file. I have tested the scenario and have not found any issue with output file while using latest version of Aspose.Words for .NET. Please use the latest version of Aspose.Words for .NET. I have attached the output RTF file with this post.

<span lang=“EN-GB” style=“font-size:10.0pt;font-family:“Courier New”;color:#2B91AF;mso-font-kerning:
0pt;mso-no-proof:yes”>Document<span lang=“EN-GB” style=“font-size:10.0pt;
font-family:“Courier New”;mso-font-kerning:0pt;mso-no-proof:yes”> doc = new Document(MyDir

  • “UCC-1_Test-v1_WITH_PASSWORD_APPLIED.rtf”);<o:p></o:p>

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

doc.Save(MyDir + "AsposeOut.rtf");