> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/pdf-editing/reflow.md).

# Reflow PDF Documents Using XLIFF Data

Document reflow using XLIFF is designed to eliminate formatting headaches when translating PDFs. Instead of manually copy-pasting content and fixing layouts, it extracts text into XLIFF format, an ind

Content reflow is designed to eliminate formatting headaches when translating or updating PDFs. Instead of manually copy-pasting content and fixing layouts, it extracts text into XLIFF format, an industry-standard translation file that maintains

* Fonts
* Layouts
* Tables

No more manual reformatting.

The format provides seamless integration with translation tools and enterprise scalability.

{% hint style="info" %}
**Trial mode page limit**

When in trial mode, output is limited to 10 pages. Once licensed, there is no page limit.
{% endhint %}

### How Does Content Reflow Work for my translation needs?

Unlike traditional translation workflows that require manually extracting and reinserting text, XLIFF Reflow automates this process by converting text into XLIFF format, an industry-standard file type for translation workflows.

{% hint style="info" %}
**Important**

The XLIFF translation feature requires PDFs with extractable text; scanned or image‑only PDFs result in malformed XLIFF files and missing content. If required glyphs are missing from an embedded font, the system applies font substitution, which may affect visual output but does not fail the operation.
{% endhint %}

Right-to-left (RTL) language translation is supported for RTL languages for Arabic and Hebrew. You can use `SetFlipPageContentsForBiDirectionalTranslations(bool)` to invert the position of images and text on the x-axis and invert vector artwork on the x-axis.You may want to invert the position of text, position of images and vector artwork in a RTL translation as it can, in some cases, improve the look of the translated page.

#### Step 1

Extract Text into XLIFF Format and save the fielded PDF

{% tabs %}
{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
// Open a PDF to translate.
PDFDoc doc(input_path + "document.pdf");

// Optionally, subset the pages to process
// This PDF only has a single page, but you can specify a subset of pages like this
// options.SetPages("-2,5-6,9,11-");

// Optionally, set the XLIFF exported version, default is 1.2
// options.SetXLIFFVersion(TransPDFOptions::e_xliff_version_2);

// Extract the xlf to file and field the PDF for translation
TransPDF::ExtractXLIFF(doc, output_path + "output.xlf", pageSet);

// Save the fielded PDF
doc.Save(output_path + "document-fielded.pdf", SDFDoc::e_linearized);
```

{% endcode %}
{% endtab %}

{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// Open a PDF to translate.
FileStream istm = new FileStream(input_path + "document.pdf", FileMode.Open, FileAccess.Read);

using (PDFDoc doc = new PDFDoc(istm))
{
    // Optionally, subset the pages to process
		// This PDF only has a single page, but you can specify a subset of pages like this
		// options.SetPages("-2,5-6,9,11-");

		// Optionally, set the XLIFF exported version, default is 1.2
		// options.SetXLIFFVersion(TransPDFOptions.XLIFFVersion.e_xliff_version_2);

    // Extract the xlf to file and field the PDF for translation
    TransPDF.ExtractXLIFF(doc, output_path + "output.xlf", pageSet);
    
    // Save the fielded PDF
    doc.Save(output_path + "document-fielded.pdf", SDFDoc.SaveOptions.e_linearized);
}
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
// Open a PDF document to translate
PDFDoc doc = new PDFDoc(input_path + "document.pdf")

// Optionally, subset the pages to process
// This PDF only has a single page, but you can specify a subset of pages like this
// options.setPages("-2,5-6,9,11-");

// Optionally, set the XLIFF exported version, default is 1.2
// options.setXLIFFVersion(TransPDFOptions.XLIFFVersion.e_xliff_version_2);

// Extract the xlf to file and field the PDF for translation
TransPDF.extractXLIFF(doc, output_path + "original.xlf", options);

// Save the fielded PDF
doc.save(output_path + "document-fielded.pdf", SDFDoc.SaveMode.LINEARIZED, null);
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
        # Open a PDF document to translate
        doc = PDFDoc(input_path + "find-replace-test.pdf")
        options = TransPDFOptions()

        # Set the source language in the options
        options.SetSourceLanguage("en")

        # Set the number of pages to process in each batch
        options.SetBatchSize(20)

        # Optionally, subset the pages to process
        # This PDF only has a single page, but you can specify a subset of pages like this
        # options.SetPages("-2,5-6,9,11-")

        # Optionally, set the XLIFF exported version, default is 1.2
        # options.SetXLIFFVersion(TransPDFOptions.e_xliff_version_2)

        # Extract the xlf to file and field the PDF for translation
        TransPDF.ExtractXLIFF(doc, output_path + "find-replace-test.xlf", options)

        # Save the fielded PDF
        doc.Save(output_path + "find-replace-test-fielded.pdf", SDFDoc.e_linearized)
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Step 2

Do your translation. Here you would send the XLIFF file to your preferred computer assisted software, online or running locally.

#### Step 3

Reflow Translated Text Back into the fielded PDF

{% tabs %}
{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
// Open the fielded PDF generated by ExtractXLIFF
PDFDoc doc(output_path + "document-fielded.pdf");

// Perform the translation using the pre-prepared translated xliff
TransPDF::ApplyXLIFF(doc, input_path + "translated_output_(en_to_fr).xlf", options);

// Save the translated PDF
doc.Save(output_path + "document-fr.pdf", SDFDoc::e_linearized);
```

{% endcode %}
{% endtab %}

{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// Open the fielded PDF generated by ExtractXLIFF
FileStream istm = new FileStream(output_path + "document-fielded.pdf", FileMode.Open, FileAccess.Read);

using (PDFDoc doc = new PDFDoc(istm))
{
  // Perform the translation using the pre-prepared translated xliff
  TransPDF.ApplyXLIFF(doc, input_path + "translated_output_(en_to_fr).xlf", options);

  // Save the translated PDF
  doc.Save(output_path + "document-fr.pdf", SDFDoc.SaveOptions.e_linearized);
  doc.Close();
}
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
// Open the fielded PDF generated by ExtractXLIFF
PDFDoc doc = new PDFDoc(output_path + "document-fielded.pdf")

// Perform the translation using the pre-prepared translated xliff
TransPDF.applyXLIFF(doc, input_path + "translated_output_(en_to_fr).xlf", options);

// Save the translated PDF
doc.save(output_path + "document-fr.pdf", SDFDoc.SaveMode.LINEARIZED, null);
doc.close();
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code lineNumbers="true" %}

```python
# The extracted xlf can be translated in a system of your choice.
# In this sample a pre-prepared translated file is used - find-replace-test_(en_to_fr).xlf

# Perform the translation using the pre-prepared translated xliff
TransPDF.ApplyXLIFF(doc, input_path + "find-replace-test_(en_to_fr).xlf", options)

# Save the translated PDF
doc.Save(output_path + "find-replace-test-fr.pdf", SDFDoc.e_linearized)
doc.Close()
```

{% endcode %}
{% endtab %}
{% endtabs %}

For more extensive code samples please go to the [Document Translation Reflow](/core/get-started/samples/document-translation-reflow.md) samples page.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/pdf-editing/reflow.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
