Install GroupDocs.Conversion for Java
Leave feedback
On this page
All Java packages are hosted at GroupDocs Artifact Repository. You can easily reference the GroupDocs.Conversion for Java API directly in your Maven project using the following steps.
First, you need to specify the repository configuration/location in your Mavenpom.xml
file as follows:
<repositories>
<repository>
<id>GroupDocs Artifact Repository</id>
<name>GroupDocs Artifact Repository</name>
<url>https://releases.groupdocs.com/java/repo/</url>
</repository>
</repositories>
Then define the GroupDocs.Conversion for Java API dependency in yourpom.xml
file as follows:
<dependencies>
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-conversion</artifactId>
<version>23.12</version>
</dependency>
</dependencies>
Create following project structure:
|--- pom.xml
|--- sample.txt
|--- src
|--- main
|-- java
|-- com
|-- mycompany
|-- app
|-- App.java
Below is a content of the project files:
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>conversion-helloworld</artifactId>
<version>1.0-SNAPSHOT</version>
<name>conversion-helloworld</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-conversion</artifactId>
<version>23.12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<mainClass>com.mycompany.app.App</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
<Specification-Vendor>My Company</Specification-Vendor>
<Implementation-Vendor>My Company</Implementation-Vendor>
</manifestEntries>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>GroupDocs Artifact Repository</id>
<name>GroupDocs Artifact Repository</name>
<url>https://releases.groupdocs.com/java/repo/</url>
</repository>
</repositories>
</project>
App.java
package com.mycompany.app;
import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
/**
* Hello world!
*/
public class App {
public static void main(String[] args) {
try (Converter converter = new Converter("sample.txt")) {
converter.convert("sample.pdf", new PdfConvertOptions());
}
System.out.println("Conversion complete");
}
}
sample.txt
Sample text
To run the application first build it (from the root project directory where pom.xml is located):
mvn clean package
Next run it:
java -jar target/conversion-helloworld-1.0-SNAPSHOT-jar-with-dependencies.jar
Here is a program output:
Conversion complete
After that you can see and open sample.pdf file in the root project directory
Note: you can create and run this project in your favourite IDE instead. Also you can build and run it without Maven usage, for example using the IDE dependency and build system or for example using Gradle.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.