The following example will show you how to translate the text content of a PDF document while preserving its original layout and formatting. Keep in mind that the translated document will retain the existing structure, styles, and embedded elements by default.
You can translate PDF files very easily using the Translate PDF tool, as shown in this code:
You can add as many files as you want to translate. To process your files, simply choose the Translate PDF tool.
You can configure the input language, output language, and the desired output format for the translated document.
By default, the output format is set to pdf, which tries to keep the same format as the original document.
Simply set the properties language_input, language_output, and output_format with your desired values like this:
These are the available output formats:
You can also define the source and target languages using their language codes.
For example:
The REST API translates your documents according to the selected input and output languages, returning the translated file in the chosen output format.