Page 1 of 1

DOCX to PDF

PostPosted: Wed Jun 08, 2022 10:30 pm
by Eugene.Asti
Guys please help!
I'm trying to convert DOCX file to PDF on android device. I've read a lot of manuals here and on git, but still can't understand what libraries I should use?
I'm struggling with docx4j libs about three days trying to make all things work, but everything useless.
I'm working on Android Studio with build.gradle
Some libraries in gradle file triyng to implement, and get error on compilation: Dublicate class, and so on and so on.
So at this moment I have theese problems:
1) Somebody tell me, please, the minimum number of libraries to convert Docx file to PDF and which ones?
2) I have two Android devices one on Android 5.1 and second is on Android 11. On Android 5.1
this command

val pkg = Docx4J.load(File(fromFileString))

throws Exception in this class: public abstract class OpcPackage extends Base implements PackageIdentifier

In this method:
private static OpcPackage load(PackageIdentifier pkgIdentifier, final InputStream inputStream, String password) throws Docx4JException {

//try to detect the type of file using a bufferedinputstream
final BufferedInputStream bis = new BufferedInputStream(inputStream);
bis.mark(0);
final byte[] firstTwobytes=new byte[2];
int read=0;
try {
read = bis.read(firstTwobytes);
bis.reset(); ---------------------------------- HERE throws Exception. It is because of inputStream which is unmarkable
}.....
On Android 11, there is no exception. If it is because of different libraries for different devices, so how can i bring all of them together for different divices?