Skip to main content

Quick Start for Java

Java supports wkhtmltopdf integration, but Puppeteer requires additional workarounds due to its lack of native support. PDFBolt provides a faster and more reliable solution for HTML to PDF conversion. Follow these steps to get started with Java.

1️⃣ Get Your API Key

  • Your API Key is available in the Admin Dashboard or in the welcome email sent after you signed up.
  • Ensure you keep this key secure, as it’s required for authenticating requests to the PDFBolt API.

2️⃣ Make Your First Request

Use the following example to quickly make a request to the PDFBolt API and generate your first PDF document:

import kong.unirest.Unirest; //simple java library
import kong.unirest.HttpResponse;
import java.io.FileOutputStream;
import java.io.IOException;

public class PdfBoltRequest {
public static void main(String[] args) {
try {
HttpResponse<byte[]> response = Unirest.post("https://api.pdfbolt.com/v1/direct")
.header("Content-Type", "application/json")
.header("API_KEY", "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
.body("{\"url\":\"https://example.com\"}")
.asBytes();

try (FileOutputStream fos = new FileOutputStream("example.pdf")) {
fos.write(response.getBody());
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

3️⃣ What’s next?

Unlock the full potential of PDFBolt by exploring its powerful features and customization options. Start with the API Endpoints and delve into the Conversion Parameters to tailor your integration to your needs.