How to convert TIFF files to PDF using Java

Table of contents

    Convert TIFF images to PDFs for universal compatibility, web integration, and enhanced security. This tutorial demonstrates programmatic TIFF-to-PDF conversion using Java and Nutrient API for document-heavy workflows that require standardized formats.
    How to convert TIFF files to PDF using Java
    Summary

    Convert TIFF files to PDF using Nutrient’s TIFF-to-PDF Java API. Create a free account, get API credentials, and implement conversion using OkHttp and JSON libraries. Combine with 30+ other API tools for merging, OCR, and watermarking.

    Convert TIFF files to PDF using Nutrient’s TIFF-to-PDF Java API. You get 200 free credits to start — no payment required. Different operations use different amounts of credits, so you’ll be able to process varying numbers of documents. Create a free account(opens in a new tab) to get your API key.

    Why convert TIFF to PDF?

    Converting TIFF files to PDF is essential for document workflows that require standardized, shareable formats. Common use cases include:

    • Universal compatibility — Convert TIFF images to PDFs that open on any device without specialized software, ensuring recipients can view documents regardless of platform.
    • Reduced file sizes — Multipage TIFF files often compress better as PDFs, reducing storage costs and improving transfer speeds for document-heavy workflows.
    • Enhanced security — Add password protection, digital signatures, and encryption when converting to PDF, securing sensitive scanned documents or medical records.
    • Web integration — PDFs render consistently in browsers, while TIFFs require plugins or downloads, improving user experience for web-based document viewers.
    • Archival compliance — Many industries require PDF/A format for long-term document preservation, making TIFF-to-PDF conversion critical for regulatory compliance.

    The TIFF-to-PDF API automates this process in your workflow.

    Nutrient DWS Processor API

    Converting TIFF to PDF is one of 30+ operations available through our PDF API tools. Combine TIFF conversion with other tools for complex workflows:

    Your account includes access to all PDF API tools.

    Step 1 — Creating a free account on Nutrient

    Go to our website(opens in a new tab) to create your free account.

    Free account at Nutrient DWS Processor API

    After creating your account, you’ll see your plan details.

    You start with 200 credits and can access all our PDF API tools.

    Step 2 — Obtaining the API key

    After verifying your email, get your API key from the dashboard. Click API keys in the left menu to see your keys.

    Convert TIFF to PDF Java API Key

    Copy the Live API key — you’ll need it for the TIFF-to-PDF API.

    Step 3 — Setting up folders and files

    For this tutorial, use IntelliJ IDEA as your code editor. Create a new project called tiff_to_pdf. You can choose any location, but select Java as the language, Gradle as the build system, and Groovy as the Gradle DSL.

    TIFF-to-PDF Java API Key

    Create a new directory in your project. Right-click your project’s name and select New > Directory. From there, choose the src/main/java option. Create a class file inside the src/main/java folder called processor.java, and create two folders in the root folder called input_documents and processed_documents.

    Copy your TIFF file to the input_documents folder and rename it to image.tiff. You can use our demo image as an example.

    Your folder structure will look like this:

    tiff_to_pdf
    ├── input_documents
    | └── image.tiff
    ├── processed_documents
    ├── src
    | └── main
    | └── java
    | └── processor.java

    Step 4 — Installing dependencies

    Install two libraries:

    • OkHttp — This library makes API requests.
    • JSON — This library will parse the JSON payload.

    Open the build.gradle file and add the following dependencies to your project:

    dependencies {
    implementation 'com.squareup.okhttp3:okhttp:4.9.2'
    implementation 'org.json:json:20210307'
    }

    Next, click the Add Configuration button in IntelliJ IDEA to open a dropdown menu.

    TIFF-to-PDF Java API **Add Configuration**

    Select Application from the menu.

    TIFF-to-PDF Java API Application

    Fill in the configuration form. Most fields are prefilled, but select java 18 in the module field and add -cp tiff_to_pdf.main as the main class and Processor in the field below it.

    TIFF-to-PDF Java API Setup

    Click Apply to save the settings.

    Step 5 — Writing the code

    Open the processor.java file and paste the code below into it:

    package com.example.pspdfkit;
    import java.io.File;
    import java.io.IOException;
    import java.nio.file.FileSystems;
    import java.nio.file.Files;
    import java.nio.file.StandardCopyOption;
    import org.json.JSONArray;
    import org.json.JSONObject;
    import okhttp3.MediaType;
    import okhttp3.MultipartBody;
    import okhttp3.OkHttpClient;
    import okhttp3.Request;
    import okhttp3.RequestBody;
    import okhttp3.Response;
    public final class Processor {
    public static void main(final String[] args) throws IOException {
    final RequestBody body = new MultipartBody.Builder()
    .setType(MultipartBody.FORM)
    .addFormDataPart(
    "file",
    "image.tiff",
    RequestBody.create(
    MediaType.parse("image/tiff"),
    new File("input_documents/image.tiff")
    )
    )
    .addFormDataPart(
    "instructions",
    new JSONObject()
    .put("parts", new JSONArray()
    .put(new JSONObject()
    .put("file", "file")
    )
    ).toString()
    )
    .build();
    final Request request = new Request.Builder()
    .url("https://api.nutrient.io/build")
    .method("POST", body)
    .addHeader("Authorization", "Bearer YOUR_API_KEY_HERE")
    .build();
    final OkHttpClient client = new OkHttpClient()
    .newBuilder()
    .build();
    final Response response = client.newCall(request).execute();
    if (response.isSuccessful()) {
    Files.copy(
    response.body().byteStream(),
    FileSystems.getDefault().getPath("processed_documents/result.pdf"),
    StandardCopyOption.REPLACE_EXISTING
    );
    } else {
    // Handle the error.
    throw new IOException(response.body().string());
    }
    }
    }

    Make sure to replace YOUR_API_KEY_HERE with your API key.

    Code explanation

    The code imports the necessary packages and creates a processor class. In the main function, you build the request body containing instructions for converting TIFF-to-PDF, and then call the API to process these instructions.

    The execute() function sends the request and saves the response to the processed_documents folder.

    Output

    To run the code, click the Run button (green arrow) next to the Processor configuration field.

    TIFF-to-PDF Java API Output

    After running the code, you’ll find result.pdf in the processed_documents folder.

    The folder structure will look like this:

    tiff_to_pdf
    ├── input_documents
    | └── image.tiff
    ├── processed_documents
    | └── result.pdf
    ├── src
    | └── main
    | └── java
    | └── processor.java

    Additional resources

    Explore more ways to work with Nutrient API:

    Conclusion

    You now know how to convert TIFF files to PDF documents programmatically in Java using the Nutrient API.

    The same API token lets you perform other operations like merging documents, adding watermarks, and more. To get started with a free trial, sign up(opens in a new tab).

    FAQ

    Does the Nutrient API preserve image quality when converting TIFF-to-PDF?

    Yes. The API maintains the original TIFF image quality during conversion. Multi-page TIFF files are automatically converted to multipage PDFs with each page preserved at its original resolution and color depth.

    Can I combine TIFF conversion with other PDF operations in a single API call?

    Yes. The Nutrient API supports chaining multiple operations in a single request. Use the actions array to convert TIFF files and then apply operations like watermarking, compression, OCR, or password protection to the resulting PDF document in one workflow.

    What Java libraries are required to use the Nutrient API?

    You need OkHttp (4.9.2+) for HTTP requests and org.json for JSON processing. Both libraries are available in Maven Central. The tutorial uses Gradle, but Maven works equally well. Java 8 or higher is required.

    How does the API handle multipage TIFF files?

    Multi-page TIFF files are automatically detected and converted to multipage PDFs. Each TIFF page becomes a separate PDF page in the output document, preserving page order and image properties. No special configuration is needed for multipage conversions.

    Jonathan D. Rhyne

    Jonathan D. Rhyne

    Co-Founder and CEO

    Jonathan joined PSPDFKit in 2014. As Co-founder and CEO, Jonathan defines the company’s vision and strategic goals, bolsters the team culture, and steers product direction. When he’s not working, he enjoys being a dad, photography, and soccer.

    Explore related topics

    FREE TRIAL Ready to get started?