Reputation: 278
I have generated an MS Word file from HTML using Jquery, but i need to add password protection to this file. Is there is any metadata to set a password before generatinga file?
Reference: https://www.jqueryscript.net/text/jQuery-Plugin-To-Save-Webpage-As-MS-Word-Document-Googoose.html
Code is from the library.
var html = '<html xmlns:o=\'urn:schemas-microsoft-com:office:office\' xmlns:w=\'urn:schemas-microsoft-com:office:word\' xmlns=\'http://www.w3.org/TR/REC-html40\'>\n';
html += '<head> <meta charset=\'utf-8\'>\n';
html += '<!--[if gte mso 9]>\n';
html += '<xml>\n';
html += '<w:WordDocument>\n';
html += ( '<w:View>' + options.display + '</w:View>\n' );
html += ('<w:Zoom>'+ options.zoom +'</w:Zoom>\n');
html += '<w:DoNotOptimizeForBrowser/>\n';
html += '</w:WordDocument>\n';
html += '<o:OfficeDocumentSettings>\n';
html += '<o:AllowPNG/>\n';
html +='</o:OfficeDocumentSettings>\n';
html += '</xml>\n';
html += '<![endif]-->\n';
html += '';
//close head
html += '</head>\n';
//Adding page content here
html + = '<body><div><p>Hai</p>';
//close body
html += '</div></body>\n';
//close doc
html += '</html>\n';
Upvotes: 0
Views: 189
Reputation: 2119
There no such option in googoose library.
For your reference,
https://github.com/aadel112/googoose#user-content-options.
Setting a password to file is not supported by JS or Jquery.
But I have seen setting a password for pdf using adobe extensions.
If you definitely want to set password then I would recommend you to move the logic to server side and use any server side library for setting password.
Upvotes: 1