How to convert PDF to XLSX (XLS) in Java using Cloud API (low level) - ByteScout

How to convert PDF to XLSX (XLS) in Java using Cloud API (low level)

  • Home
  • /
  • Articles
  • /
  • How to convert PDF to XLSX (XLS) in Java using Cloud API (low level)

The sample source code below will show how to convert PDF to XLSX or XLS spreadsheet in Java using ByteScout Cloud API (low level).

Check other articles to learn how to work with spreadsheets in JavaScript, jQuery and PHP using Cloud API.

PDF to XLS

POST/GET endpoint:

https://api.pdf.co/v1/pdf/convert/to/xls

Code Sample:

import Bytescout\Client\API.*;
import Bytescout\Client\API.auth.*;
import Bytescout\Client\API.model.*;
import Bytescout\Client\API.api.DefaultApi;

import java.io.File;
import java.util.*;

public class DefaultApiExample {

    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        
        // Configure API key authorization: api_key
        ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
        api_key.setApiKey("YOUR API KEY");
        // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
        //api_key.setApiKeyPrefix("Token");

        DefaultApi apiInstance = new DefaultApi();
        String pages = pages_example; // String | 
        String name = name_example; // String | 
        String url = url_example; // String | 
        try {
            SingleResponseModel result = apiInstance.pdfConvertToXlsPost(pages, name, url);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling DefaultApi#pdfConvertToXlsPost");
            e.printStackTrace();
        }
    }
}

PDF to XLSX

POST/GET endpoint:

https://api.pdf.co/v1/pdf/convert/to/xlsx

Code Sample (PDF to CSV):

import Bytescout\Client\API.*;
import Bytescout\Client\API.auth.*;
import Bytescout\Client\API.model.*;
import Bytescout\Client\API.api.DefaultApi;

import java.io.File;
import java.util.*;

public class DefaultApiExample {

    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        
        // Configure API key authorization: api_key
        ApiKeyAuth api_key = (ApiKeyAuth) defaultClient.getAuthentication("api_key");
        api_key.setApiKey("YOUR API KEY");
        // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
        //api_key.setApiKeyPrefix("Token");

        DefaultApi apiInstance = new DefaultApi();
        String pages = pages_example; // String | 
        String name = name_example; // String | 
        String url = url_example; // String | 
        try {
            SingleResponseModel result = apiInstance.pdfConvertToXlsxPost(pages, name, url);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling DefaultApi#pdfConvertToXlsxPost");
            e.printStackTrace();
        }
    }
}

Tutorials:

prev
next