This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dws-processor/tools-and-api/pdf-to-html-api.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. PDF-to-HTML API

Use Nutrient DWS Processor API to convert PDFs to HTML for web publishing, content migration, or document review in a browser.

The /build endpoint handles PDF-to-HTML conversion. Refer to the build document endpoint API reference for request details.

Configure the conversion with these steps:

  1. Add the source PDF as a parts item.
  2. Set output.type to html.

For signup, pricing, and examples, refer to the PDF-to-HTML API overview page.

Convert a PDF to HTML

The following example converts document.pdf to result.html:

curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer your_api_key_here" \
-o result.html \
--fail \
-F file=@document.pdf \
-F instructions='{
"parts": [
{
"file": "file"
}
],
"output": {
"type": "html"
}
}'

Use page layout or reflow layout

HTML output supports two layout modes:

  • Page layout (page) preserves the original page structure and separates content by page.
  • Reflow layout (reflow) creates continuous content without page breaks.

Use page layout to preserve page boundaries. Use reflow layout for a web article or another continuous document.

Use this instructions object to set the layout to reflow:

{
"parts": [
{
"file": "document"
}
],
"output": {
"type": "html",
"layout": "reflow"
}
}

Convert a PDF from a URL

To convert a remotely hosted PDF, send a JSON request with the source URL in parts[].file.url:

{
"parts": [
{
"file": {
"url": "https://example.com/document.pdf"
}
}
],
"output": {
"type": "html",
"layout": "page"
}
}

Shell

Run this request to convert a PDF from a URL:

Terminal window
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"parts": [
{
"file": {
"url": "https://example.com/document.pdf"
}
}
],
"output": {
"type": "html",
"layout": "page"
}
}' \
-o result.html

Convert selected PDF pages

Use parts[].pages to convert only a page range from the source PDF. Page indexes are zero-based, and negative values count from the end of the document.

The following example converts the first three pages to HTML:

{
"parts": [
{
"file": "document",
"pages": {
"start": 0,
"end": 2
}
}
],
"output": {
"type": "html",
"layout": "page"
}
}

The end value is inclusive, so { "start": 0, "end": 2 } includes pages zero, one, and two.

Convert password-protected PDFs

For a password-protected PDF, include the password in the source part’s password field:

{
"parts": [
{
"file": "protected_document",
"password": "document-password"
}
],
"output": {
"type": "html",
"layout": "reflow"
}
}

Nutrient DWS Processor API uses the password only to open the source document for processing.

Choose a layout

Choose the HTML layout based on how you’ll use the output.

LayoutUse when
pagePreserve the document’s page boundaries and structure.
reflowCreate continuous HTML for content migration, web publishing, indexing, or responsive display.

PDF uses a fixed layout, while HTML supports flowing content. Review the converted HTML for layout and content accuracy, especially for complex layouts, scanned pages, and documents with many images.

Compare PDF-to-HTML and data extraction

Use PDF-to-HTML conversion when your application needs HTML output.

Use the Data Extraction API for these outputs:

  • Structured data based on document layout.
  • Bounding boxes, key-value pairs, and tables.
  • JSON that follows a schema.
  • Markdown for retrieval-augmented generation (RAG) pipelines.

Refer to the data extraction guide for details.

Combine PDF-to-HTML with other processing

The /build endpoint supports document assembly before HTML conversion. For example, a single request can merge multiple PDFs and convert the merged document to HTML.

Use this instructions object to merge two PDFs and convert them to HTML:

{
"parts": [
{
"file": "cover"
},
{
"file": "body"
}
],
"output": {
"type": "html",
"layout": "page"
}
}

To select pages before conversion, set parts[].pages.

Reference

A PDF-to-HTML request uses the Build API output object with HTML output:

type HTMLOutput = {
type: "html",
// The layout type to use for HTML conversion.
layout?: "page" | "reflow",
};
type FilePart = {
// Multipart field name, or a remote URL object.
file: string | { url: string },
// Optional password for encrypted input PDFs.
password?: string,
// Optional page range to convert.
pages?: {
start?: number,
end?: number,
},
};
type BuildInstructions = {
parts: FilePart[],
output: HTMLOutput,
};

Refer to the build document endpoint API reference for conversion, page selection, and document assembly options.

Use these resources for other conversion and processing tasks: