How to PDF to HTML in Java using Cloud API (low level)

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

This tutorial will show you how to convert PDF to HTML in Java using ByteScout Cloud API.

It is also possible to convert HTML to PDF using Cloud API.

POST/GET endpoint:

https://bytescout.io/v1/pdf/convert/to/html

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 simple = simple_example; // String | Set 'true' to convert to a plain HTML format. Default is the rich HTML & CSS format keeping the document design.
        String columns = columns_example; // String | Set 'true' if the PDF document is arranged in columns like a newspaper. Default is 'false'.
        String url = url_example; // String | URL of the source PDF file.
        String name = name_example; // String | File name for generated result.
        try {
            SingleResponseModel result = apiInstance.pdfConvertToHtmlPost(simple, columns, url, name);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling DefaultApi#pdfConvertToHtmlPost");
            e.printStackTrace();
        }
    }
}
prev
next