Add a PDF named document.pdf to your project folder. You can use our sample document.
The file name is case sensitive. Make sure the file name matches the file name in the sample code.The file name is case sensitive. Make sure the file name matches the file name in the sample code.
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 PspdfkitApiExample {
public static void main(final String[] args) throws IOException {
final RequestBody body = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart(
"document",
"document.pdf",
RequestBody.create(
MediaType.parse("application/pdf"),
new File("document.pdf")
)
)
.addFormDataPart(
"instructions",
new JSONObject()
.put("parts", new JSONArray()
.put(new JSONObject()
.put("file", "document")
)
)
.put("output", new JSONObject()
.put("type", "pdfua")
).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("result.pdf"),
StandardCopyOption.REPLACE_EXISTING
);
} else {
// Handle the error
throw new IOException(response.body().string());
}
}
}
using System;
using System.IO;
using System.Net;
using RestSharp;
namespace PspdfkitApiDemo
{
class Program
{
static void Main(string[] args)
{
var client = new RestClient("https://api.nutrient.io/build");
var request = new RestRequest(Method.POST)
.AddHeader("Authorization", "Bearer your_api_key_here")
.AddFile("document", "document.pdf")
.AddParameter("instructions", new JsonObject
{
["parts"] = new JsonArray
{
new JsonObject
{
["file"] = "document"
}
},
["output"] = new JsonObject
{
["type"] = "pdfua"
}
}.ToString());
request.AdvancedResponseWriter = (responseStream, response) =>
{
if (response.StatusCode == HttpStatusCode.OK)
{
using (responseStream)
{
using var outputFileWriter = File.OpenWrite("result.pdf");
responseStream.CopyTo(outputFileWriter);
}
}
else
{
var responseStreamReader = new StreamReader(responseStream);
Console.Write(responseStreamReader.ReadToEnd());
}
};
client.Execute(request);
}
}
}
Optical character recognition and layout models identify structural elements: headings, paragraphs, lists, tables, and artifacts.
Semantic tagging
Elements are mapped to the PDF structure tree with correct roles (headings, tables, and more) and logical reading order.
Output
Embeds PDF/UA metadata and returns the tagged PDF.
Key capabilities
Heading detection
H1–H6 roles, supports multi-column layouts
Lists semantics
Ordered and unordered lists
Table structure
Table, row, and cell tagging with scope attributes
Reading order
Reflows content for assistive technologies
Annotation handling
Moves comments and form widgets into the structure tree
Artifact cleanup
Flags decorative items to skip by screen readers
Security is our top priority
No document storage
No input or resulting documents are stored on our infrastructure. All files are deleted as soon as a request finishes. Alternatively,
check out
our self-hosted product.
HTTPS encryption
All communication between your application and Nutrient is done via HTTPS to ensure your data is encrypted when it’s sent to us.
Safe payment processing
All payments are handled by Paddle. Nutrient DWS Processor API never has direct access to any of your payment data.
Ready to try it?
Create an account to get your API key and start making API calls.