Plus plan

Translate a PDF and keep its layout

Translate a PDF and keep the pages looking the same
POST
/v1/ai/documents/translate-layout

About this tool

This tool translates the text of a PDF right where it sits. It covers the old words and writes the translation in the same place, as large as it fits, so the pages keep their look. It works with any alphabet, including languages written from right to left. It needs a PDF with real text and takes one file. An AI translates, so check the result.
For example, you have a brochure in Spanish and want an English copy that still looks like the original.

How to use it

  1. Choose this tool.
  2. Add your PDF with Upload or drag and drop (one file).
  3. Choose the language to translate into, and the original language if you know it.
  4. Optionally add a glossary of words with the translation you want.
  5. Press Generate and download the new PDF.

What you get back

You get a new PDF with the translated text in the same places. You can download it.
TEST IT LIVE

Try Translate a PDF and keep its layout in the Studio

One click opens the Studio with this tool already selected. Add your file and see the result in seconds.
Open in the Studio
Family
AI
Plan
Plus
Method
POST
Endpoint
/v1/ai/documents/translate-layout
Tool ID
ai.documents.translate-layout
Authentication
API key
Accepts
Text and settings
Background jobs
Yes
Usage group
Ai
For developers

Use it from your code

cURL

curl -X POST "https://app.h2i.davixlabs.io/v1/ai/documents/translate-layout" \
  -H "X-Api-Key: $DAVIX_H2I_API_KEY" \
  -F 'files=@document.pdf' \
  -F 'on_unsupported=error' \
  -F 'quality=standard' \
  -F 'target_language=xx'

Node.js

const { DavixH2I } = require('@davixlabs/h2i-sdk');

const h2i = new DavixH2I({ apiKey: process.env.DAVIX_H2I_API_KEY, baseUrl: process.env.DAVIX_H2I_URL });
const result = await h2i.ai.documents.translateLayout({
    "files": 'document.pdf',
    "on_unsupported": "error",
    "quality": "standard",
    "target_language": "xx"
  });
console.log(result.data, result.requestId);

PHP

<?php
require 'vendor/autoload.php';

$h2i = new \Davix\H2I\Client(['apiKey' => getenv('DAVIX_H2I_API_KEY'), 'baseUrl' => getenv('DAVIX_H2I_URL')]);
$result = $h2i->ai()->documents()->translateLayout([
    'files' => 'document.pdf',
    'on_unsupported' => 'error',
    'quality' => 'standard',
    'target_language' => 'xx',
]);
echo $result->requestId;
FAQ

Frequently asked questions

Translate the text of a PDF in place: code reads the text blocks with their places, the model translates each block by id, and code covers the old text and draws the translation in the same place, as large as fits; every script works, left-to-right or right-to-left. Readiness: unbenchmarked (see GET /v1/ai/capabilities/documents.translate-layout).

Classification: hybrid. Deterministic stages: file type detection from content, native PDF text extraction (Poppler), Tesseract OCR for pages without text, page rendering for vision fallback, token budgeting and chunking, text block extraction with positions (Poppler), text fitting and wrapping, page patching and drawing (pdf-lib, Sharp).

Translate a PDF and keep its layout works from text and settings, so no file is needed. The required inputs are target_language.

Not on the Free plan: Translate a PDF and keep its layout is available on the Plus plan and above. Free accounts can upgrade any time to use it. Each run uses credits from your monthly allowance.

Send a POST request to /v1/ai/documents/translate-layout with your API key in the X-Api-Key header. Official SDKs for Node.js, Python, PHP, Go, Java, .NET and Ruby do the same for you, and the code box on this page shows ready-to-copy examples. For large work it can also run as a background job, so your request returns straight away.