How to Convert Excel to PDF using Java API

How to Convert Excel to PDF using Java API
Convert Excel to PDF in Java using REST API

Excel spreadsheet is one of the most used software applications, developed by Microsoft for Windows. PDF (Portable Document Format) is a reliable, secure, and cross-platform file format. It may contain flat text, structuring elements, annotations and graphics. You can convert Excel spreadsheet XLSX or XLS to PDF programmatically in Java on the cloud using REST API. As a Java developer, you may need to convert Excel spreadsheets to PDF file programmatically in your Java applications. So, in this article, we will see how to convert Excel to PDF using Java API.

The following topics shall be covered in this article:

Excel to PDF Converter Free download online API – Installation

To export JSON to CSV or large CSV to JSON in java, I will be using the Java SDK of GroupDocs.Conversion Cloud API. This Java library is easy to install and offers a wide range of methods to achieve CSV to JSON and JSON to CSV conversion, without installing any 3rd party software. Java file format conversion API allows you to convert your documents and images of any supported file format to any format you need. Quickly convert between more than 50 types of documents and images online like Word, PDF, PowerPoint, Excel, HTML, CAD, raster images, etc.

However, you can either download the APIs JAR file or install API using Maven configurations. Add repository and dependency into your project’s pom.xml file. Below are the steps for Maven:

Maven Repository:

<repository>
    <id>groupdocs-artifact-repository</id>
    <name>GroupDocs Artifact Repository</name>
    <url>https://repository.groupdocs.cloud/repo</url>
</repository>
Maven Dependency: 

<dependency>
    <groupId>com.groupdocs</groupId
    <artifactId>groupdocs-conversion-cloud</artifactId>
    <version>22.10</version>
    <scope>compile</scope>
</dependency>

Please get your Client ID and Secret from the dashboard before following the mentioned steps. Once you have your ID and secret, add code snippet in a Java-based application:

How to Convert XLSX to PDF Online in Java using REST API

You can convert Excel to PDF file format by following the simple steps given below:

  1. Upload the Excel file to the Cloud
  2. Convert Excel to PDF using Java
  3. Download the converted PDF file

Upload the File

Firstly, upload the excel file to the Cloud using the following code sample:

As a result, the uploaded excel file will be available in the files section of your dashboard on the cloud.

Convert Excel into PDF Online using Java

Please follow the steps mentioned below to convert XLSX file to PDF programmatically:

  • Create an instance of ConvertApi
  • Create ConvertSettings instance
  • Set the storage name and input Excel XLSX file path
  • Now, provide the output file format as “pdf”
  • Nex, set the output file path
  • Create ConvertDocumentRequest with convert settings as parameter
  • Finally, invoke conversion using the ConvertApi.convertDocument() method

The following code example shows how to convert Excel format to PDF file in Java using REST API:

How to convert Excel into PDF Online using Java
Convert Excel into PDF Online using Java

Download the Converted File

The above code sample will save the converted PDF file on the cloud. You can download it using the following code sample:

Convert Excel Spreadsheet to PDF in Java using Advanced Settings

Please follow the steps mentioned below to convert XLSX file to PDF programmatically:

  • Create an instance of ConvertApi
  • Create ConvertSettings instance
  • Set the storage name and input Excel XLS file path
  • Next, set “pdf” as output file format
  • Create an instance of the PdfConvertOptions
  • Set various convertOptions like setFromPage, setPagesCount, setZoom, setImageQuality, setPassword, setHeight, setMarginTop, setDpi, etc.
  • Now set convertOptions and output file path
  • Create ConvertDocumentRequest with convert settings as parameter
  • Finally, get output file by invoking the ConvertApi.convertDocument() method

The following code snippet shows how to convert Excel file to PDF file online in Java using REST API:

How to convert Excel Spreadsheet to PDF in Java using Advanced Settings
Convert Excel Spreadsheet to PDF in Java using Advanced Settings

Online Excel to PDF Converter Free

How to convert XLSX to PDF online free? Please try the following free online XLSX to PDF converter, which is developed using the above API.

Conclusion

In this article, you have learned:

  • how to convert Excel format to PDF file in java on the cloud;
  • programmatically upload the Excel file and then download the converted PDF file from the cloud;
  • how to convert Excel to PDF online in java using advanced settings;
  • free Excel to PDF converter online;

You can learn more about GroupDocs.Conversion Cloud API using the documentation, or by examples available on GitHub. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser.

Finally, groupdocs.cloud is writing new blog articles on different file formats conversions using REST API. So, please stay in touch for the latest updates.

Ask a question

You can ask your queries/questions about how to convert Excel to PDF format, via our forum.

FAQs

How do I convert Excel data to PDF in Java?

Please follow this link to learn the Java code snippet for how to convert Excel file to PDF quickly and easily.

How to convert Excel table to PDF in Java using REST API?

Create an instance of ConvertApi, set the values of the convert settings and invoke the convertDocument method with ConvertDocumentRequest to for converting Excel file to PDF.

How to save Excel to PDF free online?

Excel spreadsheet to PDF converter online free allows you to export Excel to PDF file, quickly and easily. Once the conversion is completed, you can download the PDF file.

How do I convert Excel XLSX to PDF online free?

  • Open online Excel to PDF converter free
  • Click inside the file drop area to upload Excel sheet or drag & drop Excel file.
  • Click on Convert Now button, online XLSX to PDF converter will turn Excel table to PDF file.
  • Download link of output file will be available instantly after converting convert Excel to PDF online.

How to install convert Excel to PDF online library?

Install Excel to PDF converter free download Java library to create, and convert Excel to PDF programmatically.

How do I convert Excel to PDF in windows?

Please visit this link to download Excel file to PDF converter. This offline converter can be used to turn Excel spreadsheet to PDF in windows, using a single click.

See Also

Please visit the following links to learn more about: