0

I would like to directly translate the PDF document (not to extract only text and then return it back). I would also like to keep all images and layout of the original document.

I want to do it programmatically, so I would send a PDF document and then wait for the API/Service to return the translated document.

What is the best API/Service to do it? Any suggestion is welcomed.

1
  • "I would also like to keep ... layout of the original document." Since the length of text can change when translating, how do you expect the translated PDF to look? For instance, what if the translated string is longer than the original text? Would the new text run over top of adjacent text? Run off the edge of the page? PDF format is fixed layout, not reflow. PDF is more like OpenGL than HTML.
    – Ryan
    Commented Apr 19, 2021 at 22:09

2 Answers 2

1

https://libretranslate.com/ has example

const res = await fetch("https://libretranslate.com/translate", {
method: "POST",
body: JSON.stringify({
    q: "hello world",
    source: "en",
    target: "es"
}),
headers: { "Content-Type": "application/json" }
});

console.log(await res.json());

Example reply

{
    "translatedText": "Hola mundo"
}

(It is Made by UAV4GEO and powered by Argos Translate, Argos Translate is Open-source offline translation library written in Python. Uses OpenNMT for translations, SentencePiece for tokenization, Stanza for sentence boundary detection, and PyQt for GUI.)

License: AGPLv3

Hopefully your language pair is implemented there!

0

well from my research I found this link https://docs.microsoft.com/en-us/azure/cognitive-services/translator/migrate-to-v3

I hope it helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.