Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) and Java applications (J2SE and J2EE) with fast and high quality performance.

Mon Jan 17, 2011 2:13 am

I have an important document which I want to make it be read-only. Can Spire.Doc support it?

Mortimer
 
Posts: 9
Joined: Thu Dec 23, 2010 2:45 am

Mon Jan 17, 2011 11:09 am

Thank you for your inquiry!
You can realize it through Encrypt method with the following code: document.Encrypt("your password");
e-iceblue support
User avatar

iceblue support
 
Posts: 240
Joined: Tue Dec 21, 2010 2:56 am

Wed Jul 20, 2011 3:03 pm

Hi. Encrypt is NOT read only. Encrypt puts a password on the document that prevents anyone from opening it without the password. Is there any way to make it READ-ONLY, so that the document is not editable at all, but still viewable without a password?

danielzborovski
 
Posts: 3
Joined: Wed Jul 13, 2011 4:04 pm

Thu Jul 21, 2011 1:48 am

Dear danielzborovski,
Thanks for your inquiry.
You can use Protect() Method to do so.
Code: Select all
doc.Protect(ProtectionType.AllowOnlyFormFields);
Justin
Technical Support / Developer,
e-iceblue Support Team
User avatar

Justin Weng
 
Posts: 110
Joined: Mon Mar 28, 2011 5:54 am

Mon Feb 18, 2019 11:13 am

Is there a way to make only a certain page read only while creating document. For e.g I have 3 pages in the document and i want Page 1 to be editable but page 2 and Page 3 to be read Only

charan9501
 
Posts: 1
Joined: Sat Feb 09, 2019 3:08 pm

Tue Feb 19, 2019 8:53 am

Hello Charan,

Thanks for your inquiry.
It is infeasible to make a certain "page" read only, because our Spire.DOC is based on MS Word, the Word document is a flow document and does not contain any information about its layout into pages. But, our Spire.DOC supports making the specified content read only while creating document. Please refer to the following sample code to achieve it, if there is any question, just feel free to write back.
Code: Select all
Document doc = new Document();
Section section = doc.AddSection();
Paragraph para1 = section.AddParagraph();
//add  permission start
para1.ChildObjects.Insert(0, new PermissionStart(doc, "myPermission"));
para1.AppendText("this is para1.");
//add  permission end
para1.ChildObjects.Add(new PermissionEnd(doc, "myPermission"));
//set document other parts to be readonly
doc.Protect(ProtectionType.AllowOnlyReading, "123");
Paragraph para2 = section.AddParagraph();
para2.AppendText("this is para2.");
Paragraph para3 = section.AddParagraph();
para3.AppendText("this is para3.");
doc.SaveToFile("result.docx");

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 946
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Doc