• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to prepare a readonly word document in Java program  RSS feed

 
Vinod Vijay
Ranch Hand
Posts: 165
Java Tomcat Server Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have to write a java program which will generate a word document but most importantly thats should be in read-only mode. I googled a lot but I didn't find anything such. Any idea or reference for me to follow to have a word document in read only mode.
Thanks
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you creating the word doc? I would assume you are using some third party api...does the documentation for it tell you if there is a flag or something that needs to be set?
 
Tyson Lindner
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure on what level you need it to be read-only.

Files.setAttribute(...) will set it to read only in windows with the right parameters.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ah..i was thinking of something like a PDF file that can be generated and locked from further editing. If you just want to set the file permissions, that's a different issue.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you trying to achieve by that? Obviously, it would be trivial to copy all content and create a new document that has whatever changes the viewer desires.
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Obviously, it would be trivial to copy all content and create a new document that has whatever changes the viewer desires.


Yes... and that's exactly what it says on this Microsoft documentation page: Make a document read only. Specifically:

Making your document a read-only file means that the document can be read or copied but not modified. If one of the reviewers tries to make changes to a read-only file, the changes can be saved only by giving the document a new name or saved to a new location.


And earlier in the document appears a use case for read-only documents:

If you don't want content reviewers to accidentally modify your document, you can make the document read only before sending it for review.


Whether that is Vinod's requirement or not, of course I have no idea.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!