Free Support Forum - aspose.com

Document security

Dear sir, madam,


Currently I am working on the project Document management sys using Aspose.word which includes saving, editing, locking etc. Now my requirement is to lock the document once it is finalized and then add comments at the end. User can add comments / text at the end and don’t able to edit the main doc.

Please guide me how to go about this.

With kind regards,

Mansoor
Software Engineer

Hi Mansoor,


Thanks for your inquiry.

1) I think, in your case, you can protect particular Sections of Microsoft Word document by using AllowOnlyFormFields protection type. In this case end user will only be able to insert data only into form fields. Please follow the link to learn more about form fields:
http://www.aspose.com/docs/display/wordsjava/Form+Fields+in+Aspose.Words

2) Sure, you can add a comment at the end of document by using the following code snippet:

Calendar cal = Calendar.getInstance();
cal.set(2009, 11, 9); //year is as expected, month is zero based, date is as expected
Date dt = cal.getTime();

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.moveToDocumentEnd();
builder.write(“Some text is added.”);

Comment comment = new Comment(doc, “Amy Lee”, “AL”, dt);
builder.getCurrentParagraph().appendChild(comment);
comment.getParagraphs().add(new Paragraph(doc));
comment.getFirstParagraph().getRuns().add(new Run(doc, “Comment text.”));
doc.save(“C:\Temp\out.docx”);


Hope such approach will satisfy your needs. Please let me know if you need more information, I will be glad to help you.

Best regards,

Thanks for reply…

Currently I am using the below code to iterate through each section and its sub node.

Document oldDoc = new Document(“D:\test.docm”);
Iterator sectionIterator = oldDoc.getSections().iterator();
while(sectionIterator.hasNext())
{
Section section = (Section)sectionIterator.next();
Body bdy = section.getBody();
System.out.println("Body text : "+ bdy.getText());

Iterator headerItr = section.getHeadersFooters().iterator();
while(headerItr.hasNext())
{
HeaderFooter headerFooter = (HeaderFooter)headerItr.next();
System.out.println(“Node Name : " + headerFooter.getHeaderFooterType()+” text : "+ headerFooter.getText());
}

Iterator childNodesIterator = section.getBody().getChildNodes().iterator();
while(childNodesIterator.hasNext())
{
Node insertedNode = (Node)childNodesIterator.next();
System.out.println(“Node Name : " + insertedNode.getNodeType()+” text : "+ insertedNode.getText());
}

}

Using above i can see the header,footer and body …
Now i want to convert the complete document into 3 x StructuredDocumentTags (SdtType.RICH_TEXT)
for header,footer and body…

Please help to to resolve the matter.

Thanks


Hi Mansoor,


Thanks for your inquiry. Could you please attach your input Word document (test.docm) and your expected document (you can create your expected document manually by using Microsoft Word). I will investigate your scenario and provide you more information.

Best regards,