For a project that I am currently working on have a requirement to edit and protect the docx file using a password. Once the file is saved it should be possible to open and view the file, but it should be non-editable. When the user tries to edit it, it should ask for the password.
We could do it manually using libreOffice editor in 'SaveAs' option.
I am trying to do it programatically.
I tried CLI options but was not able to find support.
Also, I tried UNO APIs using C#. It has the option to set the password but when trying to set the read-only property and save it getting an exception with error code 7. I have added the code snippet below.
{
XComponent xComponent = xCompLoader.loadComponentFromURL(docPath, "_blank", 0, loadProps);
// Query for the XStorable interface
XStorable xStorable = (XStorable)xComponent;
// Set the password protection and specify the file format
PropertyValue[] storeProps = new PropertyValue[2];
storeProps[0] = new PropertyValue
{
Name = "ReadOnly",
Value = new uno.Any(true)
};
storeProps[1] = new PropertyValue
{
Name = "Password",
Value = new uno.Any("your_password")
};
// Save the document with password protection
string savePath = "file:///" + fileUri.LocalPath.Replace("\\", "/");
xStorable.storeAsURL(savePath, storeProps);
}
Hello, I recommend posting your question to the LibreOffice forum or StackOverflow, as it deals more with LibreOffice functionality rather than AWS Lambda Layer, which only packages it. Thanks!
For a project that I am currently working on have a requirement to edit and protect the docx file using a password. Once the file is saved it should be possible to open and view the file, but it should be non-editable. When the user tries to edit it, it should ask for the password.
We could do it manually using libreOffice editor in 'SaveAs' option.
I am trying to do it programatically. I tried CLI options but was not able to find support. Also, I tried UNO APIs using C#. It has the option to set the password but when trying to set the read-only property and save it getting an exception with error code 7. I have added the code snippet below.
Could you help me on this