We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Protect document section or node example

I need to add nodes to a document, and then protect them (ie, set read-only but allow editing of those added nodes). This is similar to setting document protection but then allowing “everyone” editing to a part of the document.


It appears this featue was recently added:
WORDSNET-1067 /protection ranges/ Support protection of selected ranges in documents.



Would you please post an example of how to allow editing of the nodes as per the feature above?

Here’s more info:

http://office.microsoft.com/en-us/word-help/allow-changes-to-parts-of-a-protected-document-HA010372706.aspx

Thank you in advance.
Hi Joseph,

Thanks for your inquiry. EditableRangeStart, EditableRangeEnd and EditableRange (facade) classes are added as new public API model entities which can be preserved during DOC/DOCX/WML/RTF round trip. Let me show few more examples which will help you to get acquainted with new API:

1) Using new API you can make all editable ranges read-only, all that you need is remove them. In this case all content inside the editable regions will be preserved. Please see the following code:

NodeCollection editableRangeStarts = doc.GetChildNodes(NodeType.EditableRangeStart, true);

foreach (EditableRangeStart start in editableRangeStarts)

start.EditableRange.Remove();


2) Sometimes, due to a new permission policy, you have to change the editor of the editable range (it can be a single user or a group). In this case you can use the following code:

NodeCollection editableRangeStarts = doc.GetChildNodes(NodeType.EditableRangeStart, true);

// Change EditorGroup to Administrators, after this only users associated with the Administrators group shall be allowed

// to edit editable ranges using this editing type when document protection is enabled.

((EditableRangeStart)editableRangeStarts[0]).EditableRange.EditorGroup = EditorType.Administrators;

// Only SingleUser 'Aspose\\Andrey' will be able to change this region.

((EditableRangeStart)editableRangeStarts[1]).EditableRange.SingleUser = "Aspose\\Andrey";


3) You can do this operation for whole document (using ‘foreach’ like in the first example) or just for the particular editable range (you can find this range by editor (SingleUser) and EditorGroup name):

NodeCollection editableRangeStarts = doc.GetChildNodes(NodeType.EditableRangeStart, true);

foreach (EditableRangeStart start in editableRangeStarts)

{

// For example, restricted EditableRange can be opened for Everyone.

if (start.EditableRange.SingleUser == "Aspose\\Andrey")

start.EditableRange.EditorGroup = EditorType.Everyone;

}


Currently editable ranges are supported only at the inline-level, that is inside Paragraph, but editable range start and editable range end can be in different paragraphs.
Joseph:
I need to add nodes to a document, and then protect them (ie, set read-only but allow editing of those added nodes). This is similar to setting document protection but then allowing "everyone" editing to a part of the document.
I have logged a new feature request in our issue tracking system as WORDSNET-9000. Your request has also been linked to this issue and you will be notified as soon as it is supported. Sorry for the inconvenience.

Best regards,

> Currently editable ranges are supported only at the inline-level, that is inside Paragraph, but editable range start and editable range end can be in different paragraphs.

Thankyou for the response. I will look into using this feature. One important issue:

My requirement is also to be able to protect the entire document except to allow editing of the fields within a table, AND add rows to that table. It appears in Word2010 you must make the entire table editable to be able to add rows. Protecting the paragraphs within cells helps, but you cannot add a new row. I am concerned that the support for only paragraphs may restrict this. I will look into it, but if so, please add an enhancement request whereupon the editableRange classes also work with tables. Thankyou.

Hi Joseph,


Thanks for your request and for the additional information. I have updated the description of this issue as per your latest requirements. Our development team will investigate the best possible way to implement this feature. We will inform you as soon as this issue is implemented.

Best regards,

how do you add a new EditableRangeStart to a certain position of the document and how do you add text to this range from code (VB.NET)

I tried this following but don’t see any new editable ranges in the saved document except for the one I have in the original template even thou the number for editablerangestart is increasing

 Dim eNodeS As EditableRangeStart = doc.GetChildNodes(NodeType.EditableRangeStart, True)(0)
Dim eNodeE As EditableRangeEnd = doc.GetChildNodes(NodeType.EditableRangeEnd, True)(0)

eNodeS.EditableRange.EditorGroup = EditorType.Everyone

eNodeS = loopitem.BookmarkStart.ParentNode.InsertAfter(eNodeS.Clone(False), bookmark.BookmarkStart.ParentNode.FirstChild)
eNodeE = loopitem.BookmarkStart.ParentNode.InsertAfter(eNodeE.Clone(False), eNodeS)



Hi Akram,


Thanks for your inquiry. I am afraid, adding new editable ranges in API is not supported yet. We will inform you via this thread as soon as WORDSNET-9000 is resolved. We apologize for any inconvenience.

Best regards,

Hi Awais,

Thanks for the prompt reply. How long should I expect to wait for such a change? this is something kind of urgent for us.

Regards

Hi Akram,


Thanks for your inquiry. Our development team needs to investigate the best possible way to fix this issue. This issue actually requires us to implement a new feature in Aspose.Words’ API. Unfortunately, we can’t provide you any reliable estimate at the moment as the implementation of this issue has been postponed till a later date. We will be sure to inform you as soon as this issue is resolved. We apologize for your inconvenience.

Although we try our best to deal with every customer request in a timely fashion, we unfortunately cannot guarantee a delivery date to every customer issue. Our developers work on issues on a first come, first served basis. We feel this is the fairest and most appropriate way to satisfy the needs of the majority of our customers.

That being said, we fully understand that you are keen to get a fix to your particular issues, please have a look at this page - http://www.aspose.com/corporate/services/priority-support-policies.aspx - purchasing Priority Support will allow you to post your issues in our Priority Support forum and raise the priority of these issues directly with our development teams, if possible, we will then aim to get a resolution to your issue as soon as we can. Many Priority Support customers find that this leads to their issue being fixed in the next release of the software.

If you would like to take advantage of Priority Support then please request a quote in our purchase forum - http://www.aspose.com/community/forums/aspose.purchase/220/showforum.aspx

Best regards,

Hi Awais,

I will look into the option of purchasing priority support once I gather all the requests that I need for our application.

Meanwhile, I have another question regarding the editable fields.

I have the attached word document and I’m trying to read every single editable field.
I wrote the following code and I’m able to get the list of EditableRanges, what I’m trying to get is the value of those fields either text or rtf text.

the code is giving me the following results (using NextSibling.GetText):
Gleason Grade 3+3=6 test test
Positive c 4
sdfasd
Overall
Some Gorss Desc
Check new micro
Red present.


as you can see this is text only values and some of them are cutoff.
what function can I use to get RTF text.

        Dim doc As New Document(MyDir & “Test.doc”)
Dim eNodeCol As NodeCollection = doc.GetChildNodes(NodeType.EditableRangeStart, True)
For Each eNode As EditableRangeStart In eNodeCol
Console.WriteLine(eNode.NextSibling.GetText)
Next

Hi Akram,


Thanks for your inquiry. In this case, you need to capture all the run nodes which are contained within EditableRangeStart and EditableRangeEnd region. Please try running the following code:

Dim doc As New Document(“C:\Temp\test.doc”)

Dim editableRangeStarts As NodeCollection = doc.GetChildNodes(NodeType.EditableRangeStart, True)

For Each start As EditableRangeStart In editableRangeStarts

Dim sb As StringBuilder = New StringBuilder()

Dim currentNode As Node = start

Dim flag As Boolean = True

Do While currentNode IsNot Nothing AndAlso flag

If currentNode.NodeType = NodeType.EditableRangeEnd Then

flag = False

End If

Dim nextNode As Node = currentNode.NextPreOrder(currentNode.Document)

If currentNode.NodeType = NodeType.Run Then

sb.Append(currentNode.ToString(SaveFormat.Text))

End If

currentNode = nextNode

Loop

Console.WriteLine(sb.ToString())

Next start


I hope, this helps.

Best regards,

what if I need to get the RTF text of the editable fields. what’s the best way to do so?

Thanks

Hi Akram,


Thanks for your inquiry. Currently, you can directly get HTML and TEXT representations of a document element for example a Paragraph by using Paragraph.ToString(SaveFormat.Html) and Paragraph.ToString(SaveFormat.Text) methods. Do you want to export content of each node contained inside EditableRangeStart and EditableRangeEnd region to string in RTF format (Paragraph.ToString(SaveFormat.Rtf))?

Best regards,

yes that’s exactly what I need. the RTF text of the nodes contents.

Hello,

I want to find out if we have any updates on adding editable ranges on the fly from code
(WORDSNET-9000)

it’s been almost a year when this ticket was open

Thanks

Hi Akram,


Thanks for being patient. Regarding WORDSNET-9000 and WORDSNET-9111, these problems actually require us to implement new features in Aspose.Words and we regret to share with you that implementation of these issues has been postponed for now. However, the fixes of these problems may definitely come onto the product roadmap in the future. Unfortunately, we can not promise a resolution any time soon. We apologize for your inconvenience.

Best regards,

The issues you have found earlier (filed as WORDSNET-9000) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(2)