This project shows you how to use Microsoft's Graph for OpenXML (docx/pptx/xlsx) to PDF conversion from Java.
(Similar code would work to convert doc or rtf to docx, or for binary .ppt or .xls to pdf etc)
Different combinations of libraries can be used to do this, and the purpose of this project is to make it easier for you to assess your options.
The dimensions include:
Each permutation is in its own module (aka sub-project), and available in Maven Central, https://search.maven.org/search?q=graph-convert Choose ONE of:
<dependency>
<groupId>org.plutext.graph-convert</groupId>
<artifactId>using-graph-sdk</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.plutext.graph-convert</groupId>
<artifactId>using-graph-sdk-core-only</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.plutext.graph-convert</groupId>
<artifactId>without-graph-sdk-using-msal4j</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.plutext.graph-convert</groupId>
<artifactId>without-graph-sdk-using-scribe</artifactId>
<version>1.0.3</version>
</dependency>
Which module works best for you may depend on:
Whichever you choose, you can look at the graph-convert-sample module; just specify your chosen module in the pom there.
(Copy the pom and Java source code from this module into your IDE as a new project)
Before you start, you'll need to set some stuff up in Microsoft's cloud. I followed https://medium.com/medialesson/convert-files-to-pdf-using-microsoft-graph-azure-functions-20bc84d2adc4 but the following may also help:
This info you then setup in the graph-convert-sample module's AuthConfigImpl.
Once you've done that, you can run https://github.com/plutext/java-docx-to-pdf-using-Microsoft-Graph/blob/master/graph-convert-sample/src/main/java/samples/ConvertDocxToPdfExample.java. You'll need to specify a docx file of course.
Notes/caveats: