WordsProcessing Protected Document Doesnt Unlock

1 Answer 75 Views
WordsProcessing
Erik
Top achievements
Rank 1
Erik asked on 23 Jul 2024, 03:32 PM

I am generating a RadFlowDocument, and at the end protecting the entire document with a custom password like below..

                editor.Protect("TestPassword");
This works when I open the word document as expected, but when I go in MS Word to UNLOCK the document with my password, I am constantly told the password is incorrect.. Any advise on what I am doing wrong? 

1 Answer, 1 is accepted

Sort by
1
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 24 Jul 2024, 06:55 AM

Hi, Erik,

Your question has already been answered in the support thread, Ticket ID: 1659187, you have opened on the same topic. However, I am posting the answer here as well in order the community to benefit from it.

Following the provided information, I have prepared a sample project to test the behavior on my end:

            RadFlowDocument document = new RadFlowDocument();
            RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
            editor.InsertText("Hello world!");

            editor.Protect("telerik", Telerik.Windows.Documents.Flow.Model.Protection.ProtectionMode.ReadOnly);

            Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider provider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
            string outputFilePath = "ProtectedDocument.docx";
            File.Delete(outputFilePath);
            using (Stream output = File.OpenWrite(outputFilePath))
            { 
                provider.Export(document, output);
            }
            Process.Start(new ProcessStartInfo() { FileName = outputFilePath, UseShellExecute = true });

It seems to work as expected and when I enter the password to a protected document with ProtectionMode.ReadOnly, it allows editing:

More information about the supported protection modes is available in the following section of the online documentation: Operating with Permission Ranges.

If you are observing a different behavior than the illustrated one from the above gif, please let me know what are the exact steps that are needed to observe the undesired behavior.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Erik
Top achievements
Rank 1
commented on 24 Jul 2024, 11:53 AM

Dess, 

Thank you for this response! I have solved my issue.. I didn't know that there was a password length maximum on an MS Word Document..

To replicate exactly what I was doing, use a password that is 16 or more characters.. When you do so, even if the first 15 you type are correct, it says the password is incorrect.. If you insert a password that is 15 or less characters, the unlock works as expected..

Thank you again for your help! 

Tags
WordsProcessing
Asked by
Erik
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or