Getting started with DWS Processor API
Nutrient Document Web Services (DWS) Processor API is a service that enables fast and easy integration to instantly generate, convert, and modify PDF documents in your workflows.
This guide explains the steps to get started with DWS Processor API via DWS dashboard.
Sign up(opens in a new tab) for a free account in the DWS dashboard.
On the page that appears, select the DWS Processor API card.

Copy your live API key and select an API tool(opens in a new tab) to get started. Below you’ll see a demonstration of the PDF generation API.
To make requests using your account, pass the API key to every call you make.
Add an HTML file named
index.htmlto your project folder. You can also use our sample file.Copy the code below and run it from the same folder you added the files to. For a list of all programming languages that support HTTP requests, refer to our supported languages guide.
POST https://api.nutrient.io/processor/generate_pdf HTTP/1.1Content-Type: multipart/form-data; boundary=--customboundaryAuthorization: Bearer <add-your-live-API-key-here>
--customboundaryContent-Disposition: form-data; name="html"; filename="index.html"Content-Type: text/html
(html data)--customboundary--<?php
$FileHandle = fopen('result.pdf', 'w+');
$curl = curl_init();
curl_setopt_array($curl, array( CURLOPT_URL => 'https://api.nutrient.io/processor/generate_pdf', CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_POSTFIELDS => array( 'html' => new CURLFILE('index.html') ), CURLOPT_HTTPHEADER => array( 'Authorization: Bearer <add-your-live-API-key-here>' ), CURLOPT_FILE => $FileHandle,));
$response = curl_exec($curl);
curl_close($curl);
fclose($FileHandle);import requestsimport json
response = requests.request( 'POST', 'https://api.nutrient.io/processor/generate_pdf', headers = { 'Authorization': 'Bearer <add-your-live-API-key-here>' }, files = { 'html': open('index.html', 'rb') }, stream = True)
if response.ok: with open('result.pdf', 'wb') as fd: for chunk in response.iter_content(chunk_size=8096): fd.write(chunk)else: print(response.text) exit()// This code requires Node.js. Do not run this code directly in a web browser.
const axios = require("axios");const FormData = require("form-data");const fs = require("fs");
const formData = new FormData();formData.append("html", fs.createReadStream("index.html"));(async () => { try { const response = await axios.post( "https://api.nutrient.io/processor/generate_pdf", formData, { headers: formData.getHeaders({ Authorization: "Bearer <add-your-live-API-key-here>", }), responseType: "stream", }, );
response.data.pipe(fs.createWriteStream("result.pdf")); } catch (e) { const errorString = await streamToString(e.response.data); console.log(errorString); }})();
function streamToString(stream) { const chunks = []; return new Promise((resolve, reject) => { stream.on("data", (chunk) => chunks.push(Buffer.from(chunk))); stream.on("error", (err) => reject(err)); stream.on("end", () => resolve(Buffer.concat(chunks).toString("utf8"))); });}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/processor/generate_pdf");
var request = new RestRequest(Method.POST) .AddHeader("Authorization", "Bearer <add-your-live-API-key-here>") .AddFile("html", "index.html");
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); } }}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( "html", "index.html", RequestBody.create( MediaType.parse("text/html"), new File("index.html") ) ) .build();
final Request request = new Request.Builder() .url("https://api.nutrient.io/processor/generate_pdf") .method("POST", body) .addHeader("Authorization", "Bearer <add-your-live-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()); } }}curl -X POST https://api.nutrient.io/processor/generate_pdf \ -H "Authorization: Bearer <add-your-live-API-key-here>" \ -o result.pdf \ --fail \ -F html=@index.htmlcurl -X POST https://api.nutrient.io/processor/generate_pdf ^ -H "Authorization: Bearer <add-your-live-API-key-here>" ^ -o result.pdf ^ --fail ^ -F html=@index.htmlSimilarly, you can use other DWS Processor API endpoints to convert, modify, and manipulate documents. To explore more endpoints, try other DWS Processor API endpoints(opens in a new tab) in our API playground.