Installation
Leave feedback
On this page
GroupDocs.Conversion for Java enables seamless conversion between multiple document formats with high fidelity. This guide provides steps to integrate the library into your Java project.
- Java Development Environment: Ensure you have Java Development Kit (JDK) installed. The library supports versions 8 and above.
- Build Tool: Compatible with Maven, Gradle, Kotlin and others for dependency management.
- GroupDocs.Conversion for Java License (optional): Use the API in evaluation mode or apply for a free temporary license.
All Java packages are hosted at GroupDocs Artifact Repository. You can easily reference the GroupDocs.Conversion for Java API directly in your project using the following steps.
First, you need to specify repository configuration/location in your project as follows:
<repositories>
<repository>
<id>GroupDocs Artifact Repository</id>
<name>GroupDocs Artifact Repository</name>
<url>https://releases.groupdocs.com/java/repo/</url>
</repository>
</repositories>
repositories {
maven {
url "https://repository.groupdocs.com/repo/"
}
}
repositories {
maven(url = "https://repository.groupdocs.com/repo/")
}
<ivysettings>
<settings defaultResolver="chain"/>
<resolvers>
<chain name="chain">
<ibiblio name="GroupDocs Repository" m2compatible="true" root="https://releases.groupdocs.com/java/repo/"/>
</chain>
</resolvers>
</ivysettings>
resolvers += Resolver.url("GroupDocs Repository", url("https://releases.groupdocs.com/java/repo/"))
Then define the GroupDocs.Conversion for Java API dependency in your project as follows:
<dependencies>
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-conversion</artifactId>
<version>24.11</version>
</dependency>
</dependencies>
dependencies {
implementation 'com.groupdocs:groupdocs-conversion:24.11'
}
dependencies {
implementation("com.groupdocs:groupdocs-conversion:24.11")
}
<dependency org="com.groupdocs" name="groupdocs-conversion" rev="24.11">
<artifact name="groupdocs-conversion" ext="jar"/>
</dependency>
libraryDependencies += "com.groupdocs" % "groupdocs-conversion" % "24.11"
You can also download the JAR files directly from the GroupDocs Downloads page and include them in your project manually.
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>24.11</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
NoteNote: 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.
For more examples, visit the developer guide
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.