Any OpenDocument 'odt'/'ods'/etc. file, any Microsoft Office 'doc'/'docx'/'xls'/'xlsx'/etc. file, or any PDF file. Applicable also to OpenOffice.
Topics
About: UNO (Universal Network Objects)
About: LibreOffice
About: Apache OpenOffice
About: Java programming language
About: C++
About: Microsoft .NET Framework
About: Python programming language
About: LibreOffice Basic
About: Apache OpenOffice Basic
The table of contents of this article
- Starting Context
- Target Context
- Orientation
- Main Body
- 1: How to Open Any Valid Encrypted-with-Password File
- 2: The Conclusion and Beyond
Notation
- 'Office' means LibreOffice or Apache OpenOffice.
Starting Context
- The reader is a programmer (not particularly has to be any professional programmer).
- The reader has knowledge of the core logic of file conversion with the UNO API in Java, C++, .NET Framework (C# or Visual Basic.NET), Python, or Office Basic.
Target Context
- The reader will know how to open or convert an encrypted-with-password document file (any OpenDocument 'odt', 'ods', etc. file, any Microsoft Office 'doc', 'docx', 'xls', 'xlsx', etc. file, or any PDF file) using the UNO API.
Here are Hypothesizer 7, Objector 31A, and Objector 31B in front of a computer.
Orientation
Hypothesizer 7
In this article, we will know how to open or convert an encrypted-with-password document file (any OpenDocument 'odt', 'ods', etc. file, any Microsoft Office 'doc', 'docx', 'xls', 'xlsx', etc. file, or any PDF file) programmatically, using LibreOffice or Apache OpenOffice.
Objector 31A
Oh? I can't figure out how to make 'soffice --convert-to' convert any password-protected 'doc' file . . .
Hypothesizer 7
Sir, if you dismiss 'soffice --convert-to' and instead directly use the UNO API, it will be quite easy, actually.
Objector 31A
I don't believe such a nonsense! You are a liar!
Hypothesizer 7
. . . But that is true. I can show you a proof.
Objector 31A
Nonsense! I know what your proof is like: an out-of-focus picture of a flying lightening bug, right?
Hypothesizer 7
. . . No . . .. Picture? Lightening bug?
Objector 31A
You can fabricate any picture of UFO!
Hypothesizer 7
"UFO"? . . . No, I said 'UNO', not "UFO".
Objector 31A
. . . What the hell is that?
Hypothesizer 7
Well, while there is an article on that, in short, the UNO API is an API you can use in order to handle an Office instance.
Objector 31A
"handle an Office instance"? I don't want to do such a thing.
Hypothesizer 7
. . . When you use 'soffice --convert-to', you are exactly doing it.
Objector 31A
Why can't I use 'soffice --convert-to'?
Hypothesizer 7
I do not say that you cannot use it, but if it does not satisfy your requirements, probably, it is not the right choice.
Objector 31B
You say that it is easy, but how easy is it? You know, anything can be claimed to be easy by anyone who has already mastered it.
Hypothesizer 7
Madam, if you already know how to open a file using the UNO API, it is as easy as setting a single file-opening property.
Objector 31B
"if" . . .. Anything can be easy if you set an arbitrary condition. Certainly, it is easy to complete a full marathon if I am already at 1cm before the goal; it is easy to land on the moon if I am already at 1m above the surface; it is easy to be loved if I am already thin!
Hypothesizer 7
. . . I do not understand the last one very well.
Objector 31B
I was turned down because I was fat!
Stage Direction
Objector 31B breaks down crying.
Hypothesizer 7
. . . I am not sure whether that was the reason.
Objector 31B
He said so!
Hypothesizer 7
Well . . ., obviously, he was not worth you, I must say.
Stage Direction
Objector 31B sobs convulsively.
Hypothesizer 7
. . . In fact, there is a working sample of opening any valid file and storing the document in any valid format (which is nothing but file conversion), in Java, C++, C#, Python, or LibreOffice Basic.
Main Body
1: How to Open Any Valid Encrypted-with-Password File
Hypothesizer 7
We should set the 'Password' file-opening property at the password string.
That is all, actually.
In fact, the logic is implemented in a working sample of Java, C++, .NET Framework (C# or Visual Basic.NET), Python, or LibreOffice Basic.
How to get and build the project and how to execute the programs are described in the previous article.
2: The Conclusion and Beyond
Hypothesizer 7
Opening any valid encrypted-with-password file is as easy as setting a file-opening property at the password.
Converting any valid encrypted-with-password file is just opening the file in the converted-from-file-opening phase of the core logic of file conversion with the UNO API.
If someone is still struggling in fulfilling his or her requirements in the confinement of not directly using the UNO API, . . . it is a shame, in my opinion.