Watermark
Watermark PDF files - stamp a PDF with the text, image, or another fileExplore the product
It is easy to start converting documents using Java in a few simple steps:
Sign up for free and receive 250 conversions to try and evaluate our service. You will receive a free trial with no credit card required upon registration!
On your account dashboard you will access an intuitive UI tool that allows you to set up the conversion, adjust the parameters, and try the conversion online with zero code.
Once you have set up the conversion parameters and are happy with the conversion results, you will receive an auto-generated Java code snippet with your custom parameters!
The ConvertAPI Java library is a comprehensive, developer-focused solution for versatile document conversion and enhancement. With extensive support across hundreds of file formats, you can efficiently transform PDFs, Office documents, images, and more. Whether merging files, compressing large assets, extracting data, or applying secure redactions, this flexible toolkit integrates seamlessly into your Java environment.
High-performance and unbeatable accuracy document converter suite with support for over 500+ conversion.
Generate dynamic DOCX and PDF documents like invoices, contracts, reports, on the fly.
Protect, redact, compare, watermark, flatten, compress and modify your documents using ConvertAPI Java SDK.
Protect and unprotect PDFs, MS Office Powerpoint and MS Office Word documents.
Built to scale with your business, whether you're handling a few conversions or thousands.
Reduce file sizes without losing quality. Archive converters are designed to handle over 100 different file formats.
Configure your file conversion directly online using our intuitive interface. Select the desired parameters and see the results in real-time. Once you're satisfied, we’ll automatically generate the Java code for you, making integration into your project effortless. No need to start from scratch—just copy the code and implement it seamlessly into your Java application!
Get started nowThe ConvertAPI Java library empowers developers to seamlessly integrate advanced document conversion and manipulation capabilities into their Java applications. Supporting hundreds of file formats—including PDFs, Office documents, images, and more—it streamlines complex tasks like merging files, compressing large documents, extracting valuable data, and securely redacting sensitive information.
With intuitive methods and flexible parameters, the library reduces development overhead and speeds up integration, allowing you to focus on delivering reliable, high-quality document processing solutions within a familiar Java environment.
To get started, install the ConvertAPI Java package using Maven:
<dependency>
<groupId>com.convertapi.client</groupId>
<artifactId>convertapi</artifactId>
<version>2.10</version>
</dependency>
The ConvertAPI Java library makes it effortless to convert PPTX presentations into PDFs while offering a wide range of customizable parameters to meet your specific requirements. Whether you need to adjust page size, define conversion quality, embed fonts, or include speaker notes, the library provides intuitive options right out of the box.
With straightforward integration into your Java application, converting PPTX files to PDF is not only reliable and efficient, but also easily adaptable to suit the exact presentation standards and design elements your project demands.
This example demonstrates how to execute a document conversion directly from a remote URL. This illustrates how to convert a file hosted on a remote server by providing its direct URL.
It is useful for automating the conversion of files available online without manual intervention.
/**
* Example of conversion remote file. Converting file must be accessible from
* the internet.
*/
public class ConvertRemoteFile {
public static void main(String[] args) throws ExecutionException, InterruptedException {
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a
System.out.println("Converting remote PPTX to PDF");
CompletableFuture<ConversionResult> result = ConvertApi.convert("pptx", "pdf",
new Param("file", "https://cdn.convertapi.com/cara/testfiles/presentation.pptx")
);
Path pdfFile = Paths.get(System.getProperty("java.io.tmpdir") + "/myfile.pdf");
result.get().saveFile(pdfFile).get();
System.out.println("PDF file saved to: " + pdfFile.toString());
}
}
Shows how to perform file conversions entirely in memory using streams, eliminating the need for temporary file downloads and uploads.
/**
* Example of the file conversion when data is passed as a stream.
*/
public class ConvertStream {
public static void main(String[] args) throws ExecutionException, InterruptedException, IOException {
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a
// Creating file data stream
InputStream stream = Files.newInputStream(new File("src/main/resources/test.docx").toPath());
System.out.println("Converting stream of DOCX data to PDF");
CompletableFuture<ConversionResult> result = ConvertApi.convert("docx", "pdf",
new Param("file", stream, "test.docx")
);
Path pdfFile = Paths.get(System.getProperty("java.io.tmpdir") + "/myfile.pdf");
result.get().saveFile(pdfFile).get();
System.out.println("PDF file saved to: " + pdfFile.toString());
}
}
This example demonstrates converting a live web page into a PDF document by providing its URL.
It is ideal for archiving web pages or generating PDF versions of online content for offline access or record-keeping.
/**
* Example of converting Web Page URL to PDF file
* https://www.convertapi.com/web-to-pdf
*/
public class ConvertWebToPdf {
public static void main(String[] args) throws ExecutionException, InterruptedException {
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a
System.out.println("Converting WEB to PDF");
CompletableFuture<ConversionResult> result = ConvertApi.convert("web", "pdf",
new Param("url", "https://en.wikipedia.org/wiki/Data_conversion"),
new Param("filename", "web-example")
);
Path tmpDir = Paths.get(System.getProperty("java.io.tmpdir"));
CompletableFuture<Path> pdfFile = result.get().saveFile(tmpDir);
System.out.println("PDF file saved to: " + pdfFile.get().toString());
}
}
Demonstrates chaining multiple conversions in a single workflow, such as converting a PDF to JPG and compressing result files into a ZIP archive.
It is extremely useful for complex workflows requiring multiple file transformations in a specific sequence.
/**
* Short example of conversions chaining, the PDF pages extracted and saved as
* separated JPGs and then ZIP'ed
* https://www.convertapi.com/doc/chaining
*/
public class ConversionChaining {
public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a
System.out.println("Converting PDF to JPG and compressing result files with ZIP");
CompletableFuture<ConversionResult> jpgResult = ConvertApi.convert("docx", "jpg", new Param("file", Paths.get("files/test.docx")));
System.out.println("ConvertApi.convert is not blocking method, proceeding to ZIP conversion");
CompletableFuture<ConversionResult> zipResult = ConvertApi.convert("jpg", "zip", new Param("files", jpgResult));
System.out.println("Saving result file (blocking operation)");
Path tempDir = Paths.get(System.getProperty("java.io.tmpdir"));
CompletableFuture<Path> path = zipResult.get().saveFile(tempDir);
System.out.println("DOCX -> JPG conversion cost: " + jpgResult.get().conversionCost());
System.out.println("DOCX -> JPG conversion result file count: " + jpgResult.get().fileCount());
System.out.println("JPG -> ZIP conversion cost: " + zipResult.get().conversionCost());
System.out.println("ZIP file saved to: " + path.get().toString());
}
}
Below you will find some examples of advanced usage scenarios, including setting custom timeout and deleting the files from ConvertAPI servers manually.
/**
* Example of HTTP client setup to use HTTP proxy server.
*/
public class Advanced {
public static void main(String[] args) throws ExecutionException, InterruptedException {
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a
// Advanced HTTP client setup
Config.setDefaultHttpBuilder(builder -> {
return builder
// .proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.0.0.1", 8888))) // Setting Proxy server
.connectTimeout(3, TimeUnit.SECONDS); // Setting connect timeout
// More settings can be tuned here
});
// Conversion
Param fileParam = new Param("file", "https://cdn.convertapi.com/cara/testfiles/presentation.pptx");
System.out.println("Converting remote PPTX to PDF");
CompletableFuture<ConversionResult> result = ConvertApi.convert("pptx", "pdf", fileParam);
Path pdfFile = Paths.get(System.getProperty("java.io.tmpdir") + "/myfile.pdf");
result.get().saveFile(pdfFile).get();
// Leaving no files on convertapi.com server
System.out.println("Deleting source file from convertapi.com server");
fileParam.delete().get();
System.out.println("Deleting result files from convertapi.com server");
result.get().deleteSync();
System.out.println("PDF file saved to: " + pdfFile.toString());
}
}
The final example illustrates how to retrieve account information, such as usage statistics and remaining conversion credits, using the ConvertAPI Java SDK. It is important for monitoring account usage and managing conversion quotas programmatically.
/**
* Retrieve user information
* https://www.convertapi.com/doc/user
*/
public class UserInformation {
public static void main(String[] args) {
Config.setDefaultApiCredentials(getenv("CONVERTAPI_CREDENTIALS")); //Get your api credentials at https://www.convertapi.com/a
User user = ConvertApi.getUser();
System.out.println("API Key: " + user.ApiKey);
System.out.println("Email: " + user.Email);
System.out.println("Name: " + user.FullName);
System.out.println("Status: " + user.Status);
System.out.println("Active: " + user.Active);
System.out.println("Total Conversions: " + user.ConversionsTotal);
System.out.println("Conversions Consumed: " + user.ConversionsConsumed);
}
}
}
With our Java SDK, you’ll unlock a wide range of over 500+ converters and document management capabilities—conveniently accessible from a single, unified platform.
You can provide documents via URLs, use file streams, or reference local file paths, ensuring that file handling fits seamlessly into your existing environment. To further enhance efficiency, consider employing conversion workflows to manage multiple tasks concurrently.
For in-depth examples and expert tips, be sure to explore our GitHub repository.
Take control of your documents with our Java document management SDK. From basic conversions to full workflow automation, we provide the expertise and tools you need to manage your documents efficiently.
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
Explore the product
We ensure that all document processing is handled securely in the cloud, adhering to industry-leading standards like ISO 27001, GDPR, and HIPAA. To enhance security even further, we can ensure that no files or data are stored on our servers and never leave your country.
Learn more about securityHighest rated File Conversion API on major B2B software listing platforms: Capterra, G2, and Trustpilot.
"ConvertAPI has been a game-changer for our document automation workflows. Their conversion accuracy and API reliability are unmatched in the industry for over 7 years."
"ConvertAPI is a reliable, cost-effective solution with a proven track record of stability. It has grown significantly in maturity, adopting enterprise-grade practices over the years."
"We've integrated ConvertAPI across our entire document processing platform. The performance is exceptional and the support team is always responsive. Highly recommended!"
The ConvertAPI Java library enables you to integrate powerful file conversion, manipulation, and document management capabilities directly into your Java applications. You can easily convert PDFs, Office documents, images, and many other file types with just a few lines of code.
If it’s hosted on Maven Central or a similar repository, simply add the dependency to your pom.xml and run mvn clean install. If you have a local JAR, you can install it into your Maven repository and then include it as a dependency. Refer to our documentation for exact steps.
The library supports hundreds of file formats—ranging from common PDF and Office documents to various image, text, and eBook file types. This flexibility makes it an all-in-one solution for diverse document processing needs.
Absolutely. The ConvertAPI Java library provides customizable parameters like image quality, color spaces, page ranges, metadata handling, and more. This ensures you get precisely the output you require for each document conversion.
Yes. The library is optimized for handling large files and supports workflows to process the documents efficiently. Asynchronous and parallel processing options help maintain performance in high-load scenarios.
You can explore our GitHub repository for code samples, advanced usage patterns, and best practices. For personalized assistance, our support team is ready to help with integration questions, troubleshooting, and guidance on optimizing performance.