Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To render Arabic correctly in a Django PDF, make three separate choices: declare xhtml2pdf’s Arabic RTL mode with <pdf:language name="arabic"/>, embed a TrueType font that contains the Arabic glyphs, and use lang="ar" on the document when PDF language metadata matters. Add dir="rtl" where HTML direction semantics are appropriate, then inspect the generated PDF with the exact xhtml2pdf version and font used in deployment.

The minimum template change

xhtml2pdf processes the HTML and CSS that Django gives it; there is no separate Django setting that enables Arabic. Put the RTL declaration in the markup scope containing the Arabic content and assign an embedded Arabic-capable font to that content.

<html lang="ar">
<head>
  <style>
    @font-face {
      font-family: ArabicText;
      src: url("fonts/MarkaziText-Regular.ttf");
    }

    .arabic {
      font-family: ArabicText;
    }
  </style>
</head>
<body>
  <pdf:language name="arabic"/>
  <p class="arabic">مرحبا بالعالم</p>
  <p>English text remains left-to-right.</p>
</body>
</html>

This is the documented pattern using Markazi Text as an example font. Make sure the TTF path is resolvable by the converter in the production environment; a path that works in a development checkout may fail when templates and static files are packaged differently.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What each language and direction setting does

pdf:language activates xhtml2pdf RTL behavior

Use <pdf:language name="arabic"/> for Arabic. The documented RTL values also include hebrew, persian, urdu, pashto, and sindhi. In RTL mode, text runs are laid out from right to left, paragraphs are right-aligned unless you override that, and table columns flow in the opposite direction so the first cell is rightmost.

#1 Best Overall
MIKUSO Arabic English Keyboard,Wired Keyboard Not Fading Bilingual Letters
  • Arabic English Letters:This USB wired keyboard adopts advanced laser engraving technology, which will not fade when typing for a long time, allowing you to clearly see letters and symbols, bidding farewell to the trouble of character wear and tear causing unclear reading
  • Waterproof and anti slip: The keyboard is waterproof, comfortable to the touch, Reduce finger pressure.with a wire length of 1.6 meters and anti slip silicone pad on the back, making the keyboard work efficiently,The space bar has a crisp sound, not silent
  • Arabic QWERTY English 104 key keyboard layout with numeric keypad,Has all Arabic letters including commonly missed ones (see pics), suitable for offices and work. There are uppercase lock indicator lights and numeric lock indicator lights in the upper right corner of the keyboard
  • Efficient office work: The wired keyboard has 12 multimedia shortcut key combinations for instant access to music, volume, computer, email, and more.The space bar has a normal tapping sound, not a quiet keyboard
  • Plug and play: wired USB interface, no need to download programs, saving the trouble of replacing batteries or charging, suitable for Windows, Android, smart TV and Mac (Note:Mac systems may not be compatible with multimedia buttons)

dir="rtl" supplies HTML direction semantics

Add dir="rtl" to an element or container when the semantic HTML direction should be explicit:

<div dir="rtl" class="arabic">
  <p>نص عربي مع English داخل السطر</p>
</div>

Use it together with the xhtml2pdf language declaration when appropriate, but test mixed Arabic and Latin strings. RTL and bidirectional layout behavior has changed between xhtml2pdf releases.

lang="ar" is document metadata, not shaping

The special xhtml2pdf value arabic is an RTL-processing instruction, not a BCP 47 language tag. It does not by itself set the PDF /Lang entry. Put lang="ar" on the root HTML element when screen readers, PDF/UA checkers, or other consumers should identify the document as Arabic. You can use lang="en" on an English fragment inside an Arabic document when that fragment needs an explicit language.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose and embed an Arabic font

Why built-in PDF fonts fail

The built-in Base-14 families—Helvetica, Times-Roman, and Courier—do not contain Arabic glyphs. Selecting one of them can produce missing characters, boxes, or blank output. An embedded font is required for reliable Arabic rendering.

Define the font with @font-face

Use a TTF file and reference it in CSS:

@font-face {
  font-family: ArabicText;
  src: url("fonts/MarkaziText-Regular.ttf");
}

body { font-family: ArabicText; }
.latin { font-family: Helvetica; }

Font-family lists are matched per character in the current guide. You can therefore provide a fallback list for mixed scripts, but every character must exist in at least one specified font. If no listed font contains a character, xhtml2pdf warns about the missing glyph and the PDF may show a blank or a box.

Rank #2
M MC Saite MCSaite Wired Arabic/English Computer Keyboard, Full-Size Keyboard, 104-keys, USB Plug-and-Play, Foldable Stands, Compatible with PC, Laptop
  • Standard USB Arabic Keyboard - Offers 104 keys, including navigational controls, full functions and a 10-key keypad.
  • Ample Wire Length Connection - Keyboard's 5-ft. wired connection gives you plenty of room to setup your keyboard where you want it.
  • Comfortable switch - Provides you with improved typing speed and accuracy. Over 15 million keystroke tests, keyboard is durability.
  • High Quality ABS Production - Use strong grade and strong, environmental protection materials, the keyboard bottom has anti-slip mat, will not move, convenient your work.
  • USB PLUG AND PLAY, no additional driver needed.Compatible with Windows 7, Vista, XP, 2000 and 98.

Check joining and shaping, not just glyph coverage

Arabic letters change form according to their position and neighboring letters. ReportLab does not perform shaping itself; xhtml2pdf chooses contextual letter forms. The font guide cautions that some OpenType-oriented fonts contain base Arabic characters but few or no presentation forms. Such a font can contain the letters yet still render them unjoined. Test words with isolated, initial, medial, and final forms, plus punctuation and numerals, rather than checking only a single character.

Integrate the template in Django

A typical view renders the HTML template and passes it to xhtml2pdf’s PDF response helper. The exact helper setup depends on your project, but the Arabic work belongs in the template and CSS:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from django.http import HttpResponse
from django.template.loader import get_template
from xhtml2pdf import pisa


def invoice_pdf(request, invoice_id):
    template = get_template("billing/invoice.html")
    html = template.render({"invoice_id": invoice_id})

    response = HttpResponse(content_type="application/pdf")
    response["Content-Disposition"] = 'inline; filename="invoice.pdf"'
    result = pisa.CreatePDF(html, dest=response)
    if result.err:
        return HttpResponse("PDF generation failed", status=500)
    return response

Keep the font file available to the process that calls pisa.CreatePDF. If you use relative URLs, configure xhtml2pdf’s link and file-resolution callbacks or switch to a deployment path that the converter can read. A missing font URL is a deployment error, not an Arabic-language setting problem.

Arabic tables, alignment, and mixed content

Tables

With Arabic RTL mode enabled, xhtml2pdf reverses table column flow: the first cell is rendered on the right. Do not assume that a Django list written left-to-right will occupy the visual columns you expect. Build a small table fixture containing headers, numbers, dates, and Arabic labels, then verify the visual order in the PDF.

Mixed Arabic and Latin text

URLs, invoice numbers, email addresses, currency symbols, and English product names often appear inside Arabic sentences. Wrap fragments with appropriate language and direction where needed:

Rank #3
M MC Saite Arabic and English 78 Keys Wired Mini Keyboard - with Keyboard Cover USB Computer keypad for Laptop MAC Windows 10/8 / 7 / Vista/XP
  • Portable 78-Key Computer Wired Keyboard, signal transmission is stable, and the line length is 1.3 meters (equal to 51 inches). Size:28x12x1.8cm
  • Comfortable switch - Provides you with improved typing speed and accuracy. Over 15 million keystroke tests, keyboard is durability.
  • High Quality ABS Production - Use strong grade and strong, environmental protection materials, the keyboard bottom has anti-slip mat, will not move, convenient your work.
  • FN Shortcuts - Easy access to media controls such as playback, pause, next and previous tracking, increase volume, etc. The Number Function keys Hide under the letter, saving your space, and more convenient and fast.
  • Simple Plug and PLay for Windows - Compatible with desktops and laptops with Windows 10, Windows 8, 7, Vista, XP, Chrome OS.
<p dir="rtl" class="arabic">
  رقم الطلب:
  <span dir="ltr" lang="en">INV-2026-0042</span>
</p>

Inspect punctuation, parentheses, decimal separators, and adjacent Latin text. A string can have correct glyphs but still appear visually confusing if its directional runs are not delimited.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Right alignment is not always correct

RTL declarations right-align paragraphs by default. For a centered heading or a left-aligned Latin block, override the alignment explicitly:

.arabic-title { text-align: center; }
.latin-block { direction: ltr; text-align: left; }

Version and deployment checks

Version behavior matters. The documentation landing page displayed 0.2.21, while the latest font and release-note pages displayed 0.2.20 and the stable HTML API displayed 0.2.19. The 0.2.20 release notes, dated 2026-09-15, describe changes to RTL layout, mixed-direction handling, Arabic joining, and font fallback. Check the package actually installed in your application before relying on a version-specific result:

python -c "import xhtml2pdf; print(getattr(xhtml2pdf, '__version__', 'unknown'))"
pip show xhtml2pdf

Pin the version in your deployment, include the exact font files in the build artifact, and regenerate a known Arabic fixture after upgrades. The 0.2.20 notes say Arabic letters are no longer replaced by empty boxes when a font has no presentation form for them; that release-note statement is not a guarantee that every font will join correctly in every document.

Testing checklist before production

  • Render isolated, connected, and mixed Arabic words.
  • Include Arabic punctuation, Arabic-Indic digits if your data uses them, Latin numbers, URLs, and currency symbols.
  • Test paragraphs, headings, nested spans, lists, and tables.
  • Open the PDF in more than one viewer and zoom in to check glyph outlines and joining.
  • Confirm the output metadata language if accessibility requires /Lang.
  • Run the test with the same xhtml2pdf version, operating system, font files, and URL-resolution configuration used in production.

Troubleshooting common failures

Arabic appears as boxes or disappears

Cause: a Base-14 font or another font without the required glyphs is being used, or the TTF URL cannot be resolved. Fix: embed an Arabic-capable TTF with @font-face, apply that family to the Arabic element, and verify the converter can open the file from its deployment path.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
JPYXKM Wireless Arabic Keyboard, Minority Language Ultra Thin Lightweight Silent Bluetooth Keyboards for Laptop/PC/Tablet/Desktop/Smart TV (Arabic)
  • 【ENHANCE YOUR WORKSPACE】Whether you are working from home or taking online courses, our keyboard will give you slim size, comfortable and ergonomic feel. Purpose built for Windows/Apple/Androids Systems, it features a 78-key layout, 6 multimedia keys, 10 languages, 13 shortcut keys, and visually stunning aluminum body.
  • 【STRONG WIRELESS CONNECTION】Connect With Bluetooth 3.0, the cordless keyboard establishes a stable connection from up to 32ft away via Bluetooth. This eliminates excess cables and clutter, providing a clean workspace.
  • 【A SOPHISTICATED TYPING EXPERIENCE】Each keycap on our low profile wireless USB keyboard is designed with a concave shape and scissor flexor technology. This allows for smooth and responsive keystrokes. Also, for wrist comfort, an angled kickstand is integrated.
  • 【SIMPLE SETUP】This slim keyboard is completely connect and play. Simply connect Bluetooth with your computer and begin. Also, two AAA batteries provides up to 2-3 months of run time. (not include batteries).
  • 【ADD LANGUAGES LAYOUT ON PC】-Open the start menu and select "Control Panel". -Select "Change keyboards or other input methods" under the Clock, Language, and Region section. -In the new window, click on the button that says "Change keyboards...". -Another window will open and show all currently installed keyboards. -Click "Add..." -International should now show on the list of keyboards installed. Click "Apply" and then "OK".

Letters appear but do not connect

Cause: the font has base Arabic glyphs but lacks presentation forms expected by xhtml2pdf’s contextual selection. Fix: try a font documented to work with xhtml2pdf, such as Markazi Text, and test the actual words your application emits. Upgrading xhtml2pdf can change joining behavior, so retest after upgrades.

Arabic is present but runs left-to-right

Cause: the RTL language declaration is missing or outside the markup being converted. Fix: place <pdf:language name="arabic"/> in the relevant document scope and use dir="rtl" on semantic containers where needed.

English fragments or numbers are scrambled

Cause: bidirectional runs are ambiguous, especially inside tables and punctuation-heavy strings. Fix: wrap Latin fragments in dir="ltr", set their language where useful, and test the complete mixed string rather than separate words.

The PDF is visually Arabic but accessibility tools report no language

Cause: pdf:language controls RTL processing; it is not the PDF language metadata tag. Fix: add lang="ar" to the root HTML element and validate the resulting PDF with your accessibility tooling.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A table’s columns seem reversed

Cause: RTL mode intentionally places the first table cell on the right. Fix: reorder the template cells to match the intended visual reading order, or use an explicit LTR container for a table that is genuinely left-to-right.

Best Value
3PCS Arabic Keyboard Stickers for Laptop, MacBook Air/Pro, Desktop PC Computer, Replacement Keyboard Stickers, Orange Arabic Lettering with Non Transparent Black Background
  • COMPATIBILITY: The Arabic-English stickers which are designed for Apple Macbook, HP, Acer, Lenovo and Dell Laptops and other computers, desktops keyboards.
  • RENEW YOUR WORN-OUT KEYBOARD: It's a great way to update your keyboard worn-out letter keys with a different fresh new look,and Matte process with better touch feeling.
  • EASY TO APPLY AND REMOVE: Blend well with your keyboard, you can easily convert your keyboard keys to another language and no residue leaves on your keyboard when you remove it.
  • SAVES MONEY AND KEEP NEW LOOK: No need to buy another expensive multilingual keyboard ever again. And it will will help to protect your keyboard from small scratches and keep it clean and nice!
  • PACKAGE INCLUDES: 3pcs of keyboard replacement stickers, you can change it when it wear or fade at any time.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your next step is capturing a rendered web page rather than generating an Arabic PDF inside Django, ScreenshotNeo provides a one-request screenshot API. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server includes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.

See the ScreenshotNeo documentation for all options. A cURL call is:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://your-site.example/report -o shot.webp

There is a free allowance of 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to try it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Does Django need a separate Arabic or RTL setting for xhtml2pdf?

No. Arabic handling occurs in the HTML/CSS passed to xhtml2pdf. Declare pdf:language, embed and apply an Arabic-capable font, and use HTML direction and language attributes where appropriate.

Can I use Helvetica for Arabic if I also declare RTL?

No. Helvetica, Times-Roman, and Courier are Base-14 PDF fonts without Arabic glyphs. Embed a suitable TTF instead.

Is lang="ar" a replacement for pdf:language?

No. lang="ar" identifies the document language, while pdf:language name="arabic" activates xhtml2pdf’s RTL processing.

Why should I retest after upgrading xhtml2pdf?

RTL layout, mixed-direction handling, Arabic joining, and font fallback have changed across releases, including changes described in the 0.2.20 release notes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.