Problems · Updated 2026-12-03
react-pdf right-to-left and Arabic problems
@react-pdf/renderer lets you write PDFs as React components. Current versions run a bidi algorithm and accept a direction style, so Arabic, Hebrew and Persian text mostly comes out in the right order. But there are still gaps that show up in real documents: dots drawn in the wrong place, text that copies out of the PDF backwards, and layouts you have to mirror by hand.
This page goes through the three GitHub issues people land on, what each one actually reports, what you can do today, and when an API is the simpler path.
#Symptoms
- Arabic letters render, but some dots or marks sit beside a letter instead of under it. The final yeh in
فيis the usual example. - The PDF looks right, but text copied out of it, or extracted by a parser, has letters swapped and brackets the wrong way round.
- Text is right-to-left inside a line, but the page layout (columns, totals, logo position) is still left-to-right.
- With no custom font registered, Arabic does not render at all.
#What the issues say
##3076: the RTL feature request
Issue #3076, "Request RTL feature to fix issue with RTL languages (Hebrew, Arabic, Persian)", was opened in February 2025. The whole description is "Simply I need support for RTL languages." It carries the new feature label and is still open, with no assignee and no linked pull request. The comments are mostly "following". One commenter suggests using fonts that support RTL scripts, naming Rubik, Cascadia Mono and Cascadia Code. There is no maintainer reply on the issue.
The current releases already cover part of the request: the current @react-pdf/textkit (7.1.0) depends on bidi-js and reorders mixed-direction runs, and @react-pdf/stylesheet types include direction?: 'ltr' | 'rtl'. The two newer issues below were both written against that code.
##3576: Arabic dots and combining marks misplaced
Issue #3576, opened in October 2026 against @react-pdf/renderer 4.9.0, reports that "GPOS mark positioning (xOffset / yOffset from fontkit) is effectively ignored when glyphs are drawn", so "Marks end up at the pen position instead of where the font places them". The author's example is Noto Sans Arabic, where the two dots of the final yeh in في and العربي are drawn beside the letter instead of under it. They trace it to the offsets being overwritten and mis-scaled in @react-pdf/textkit and @react-pdf/render, post a code change that fixed it for their eight Arabic test strings and Thai tone marks, and reference a related issue, #3555. At the time of writing the issue is open, with no comments and no linked pull request.
We reproduced it with @react-pdf/renderer 4.9.2, the current release: with Noto Sans Arabic, the dots of the final yeh in في, العربي and تجريبي sit beside the letter.
##3594: copied text comes out reversed
Issue #3594, opened in October 2026, is about the text layer, not the drawing. Arabic "renders correctly", but text read back out of the PDF is wrong in two ways:
- Pairs of letters drawn as one ligature glyph come out swapped when extracted with pdf.js. The author's analysis is that the glyph's ToUnicode entry is written in logical order while the glyphs are in visual order.
- Mirrored brackets:
(تجريبي)extracts as)تجريبي("in every reader tried".
A contributor opened pull request #3634 for the ligature part. The maintainer replied that it fixes extraction in pdf.js and Poppler but breaks it in macOS Preview and Safari, which already extract correctly, and suggested a different approach (/ActualText or /ReversedChars). The bracket part is out of scope for that PR. Both the issue and the PR are open at the time of writing.
In our own test with 4.9.2, pdftotext (Poppler) extracted (تجريبي) as )تجرتبي(: brackets reversed and one letter changed. This matters if your PDFs are searched, copied from, read by screen readers, or parsed by an accounting system.
#Fixes you can apply today
#1. Register a font that has Arabic
react-pdf's built-in fonts (Helvetica, Times, Courier) have no Arabic glyphs. Register one:
import { Document, Page, Text, View, Font, StyleSheet } from "@react-pdf/renderer";
Font.register({
family: "IBM Plex Sans Arabic",
fonts: [
{ src: "/fonts/IBMPlexSansArabic-Regular.ttf" },
{ src: "/fonts/IBMPlexSansArabic-Bold.ttf", fontWeight: 700 },
],
});
const styles = StyleSheet.create({
page: { padding: 40, fontFamily: "IBM Plex Sans Arabic", fontSize: 12 },
rtl: { direction: "rtl", textAlign: "right" },
row: { flexDirection: "row-reverse", justifyContent: "space-between", marginTop: 8 },
title: { fontSize: 22, fontWeight: 700 },
});
export function Invoice({ number, total }) {
return (
<Document>
<Page size="A4" style={styles.page}>
<Text style={[styles.rtl, styles.title]}>فاتورة رقم {number}</Text>
<Text style={styles.rtl}>في دول الخليج العربي</Text>
<View style={styles.row}>
<Text>المجموع</Text>
<Text>{total}</Text>
</View>
</Page>
</Document>
);
}In Node, src is a file path or URL. In the browser, use a URL your app serves.
#2. Set direction and mirror the layout yourself
direction: "rtl" with textAlign: "right" handles a paragraph. Layout is not mirrored for you: for every row, use flexDirection: "row-reverse", and swap any left and right padding, margins and borders. A table is a set of rows, so each row needs the same treatment.
#3. Choose a font that avoids the misplaced marks
According to the analysis in #3576, the bug affects marks that a font positions with GPOS offsets, so whether you see it depends on how the font draws each letter. We rendered the same text with three fonts under 4.9.2:
| Font | Final yeh dots |
|---|---|
| Noto Sans Arabic | Misplaced, beside the letter |
| IBM Plex Sans Arabic | Correct |
| Amiri | Correct |
This is a test of three strings, not a guarantee. Render the words your product prints, including vowel marks if you use them, and look at them before you commit to a font.
If you need a specific font that is affected, the issue includes the author's patch to resolveRunYOffset in @react-pdf/textkit. You can apply it with patch-package. We have not tested that patch.
#4. Know the limits of extracted text
There is no workaround in user code for #3594. If text extraction matters, test your PDFs in the readers and parsers your users rely on.
#Or use an API
If what you need is invoices, receipts, statements or certificates in Arabic, Hebrew and other languages, rendering in a full browser engine avoids these three problems: text is shaped with the font's own OpenType tables, marks are positioned by the font, and right-to-left layout comes from CSS. DevilPDF does that rendering for you:
const res = await fetch("https://devilpdf.com/v1/render", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.DEVILPDF_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
template: "invoice",
locale: "ar",
data: {
number: "INV-1024",
currency: "SAR",
customer: { name: "شركة الأفق للتجارة" },
items: [{ name: "استشارات", quantity: 3, unit_price: 1250 }],
},
}),
});
const doc = await res.json();
console.log(doc.url);With "locale": "ar" the starter's labels are translated, the money is formatted for the locale, and the whole page mirrors: columns run right to left and the totals move to the left side. You do not maintain a second layout. To use your own design, write the template in HTML with direction-neutral CSS (text-align: start, margin-inline-start) and it mirrors the same way. See templates and languages.
Keep react-pdf if you need its component model in the browser. If your PDFs are generated on a server from data, an API call replaces the renderer, the fonts and the RTL workarounds. Call it from your server so the API key stays secret. The free plan includes 500 documents a month.