Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk6 min

HTML to PDF in Python on Ubuntu with Indian-Language Fonts

A practical WeasyPrint workflow for creating PDFs from Python on Ubuntu and checking that the fonts used by the renderer cover your target Indian-language script.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use WeasyPrint to turn HTML into a PDF from Python on Ubuntu, then make sure the font selected by Pango and Fontconfig actually contains the Indian-language script you need. A successful Python call alone does not guarantee correct glyphs: install and verify the font in the same environment that runs the PDF job, and test real text from your target language.

Install WeasyPrint on Ubuntu

WeasyPrint provides a Python API for converting HTML to PDF. Its installation has native-library requirements, which can vary with the current release and Ubuntu version. Follow the current official installation instructions rather than relying on commands written for an older Ubuntu release.

As an Amazon Associate I earn from qualifying purchases.

  1. Install WeasyPrint using either the Ubuntu distribution package or the documented virtual-environment method, including the native dependencies listed for your chosen method.
  2. Confirm the installed application and its environment with weasyprint --info, which the documentation provides for checking the installation.
  3. Install a font that covers the script you need, using the package manager for your Ubuntu release or making a font file available to Fontconfig. Check the font’s licensing and deployment terms before bundling or distributing it.

There is no single font package established here as a guaranteed choice for every Indian language or Ubuntu release. Choose based on actual script coverage, then verify it on the target system.

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

Check which font Ubuntu will use

WeasyPrint accesses fonts through Pango and Fontconfig. Use Fontconfig’s tools to inspect what is installed and which family a request resolves to:

#1 Best Overall
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".
  • fc-list lists fonts visible to Fontconfig.
  • fc-match "Your Font Family" reports the font Fontconfig selects for that family pattern. Replace the example with the family you intend to use.

Run these checks as the same service account, inside the same container or virtual machine, and with the same environment as the PDF-producing process. A font visible in an interactive shell may not be available to a web worker or scheduled job.

Render HTML to PDF in Python

Once WeasyPrint and an appropriate font are available, call HTML(...).write_pdf(...). This minimal example reads a local HTML file and writes a PDF:

Rank #2
KB518 Oker Keyboard Thai Language Black Waterproof from USB Slim+Desktop
  • Thai Language and English Keys QWERTY
  • Waterproof Keyboard USB
  • 15,000,000 Life expectancy keys
  • Wired
  • Color , Blue , Pink, Black with silicon saftey cover
from weasyprint import HTML

HTML(filename="input.html").write_pdf("output.pdf")

For a string of HTML, pass string instead of filename:

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

html = """<!doctype html>
<html lang="hi">
<head>
  <meta charset="utf-8">
  <style>
    body { font-family: "Your Font Family", sans-serif; }
  </style>
</head>
<body>
  <p>यहाँ अपने लक्ष्य भाषा का वास्तविक पाठ रखें।</p>
</body>
</html>"""

HTML(string=html).write_pdf("output.pdf")

Replace Your Font Family with a family installed and verified on your Ubuntu image, and replace the sample text with representative content in the script you need. Declaring a family in CSS asks for that family; it does not install it or prove that it covers every character.

Rank #3
Sale
Bilingual Bluetooth Keyboard, Slim Wireless Keyboard for Computer Smart TV Tablet Smartphone, Compatible with Windows iOS
  • Effortless Bilingual Typing & Multi Device Connectivity: Switch seamlessly between languages with this bilingual Bluetooth keyboard, designed for efficient typing on computer, smart TV, tablet, and smartphone. Its advanced Bluetooth technology connects up to 3 devices simultaneously, allowing you to type across your iPad, Android, and devices with a simple key press, boosting your productivity at home or in the office.
  • Ultra Slim & Portable Wireless Design: The slim wireless keyboard features a sleek, lightweight profile that measures only
  • insert thickness: thick, making it the perfect travel companion. Whether you’re working from a coffee shop or controlling your smart TV in the living room, this compact design slips easily into any bag, eliminating the need for a bulky carrying case.
  • Full Compatibility with iOS & Android: Enjoy universal compatibility across all major operating systems. This keyboard works flawlessly with , , iOS, and Android devices, ensuring a stable connection for your computer, tablet, or smartphone. No driver installation is required—simply pair and type immediately for a hassle free experience.
  • Quiet & Comfortable Ergonomic Keypad: The low profile keys provide a quiet, responsive typing experience that reduces noise in shared spaces. Designed with an ergonomic layout and a built in numeric keypad, this wireless keyboard minimizes finger strain during long typing sessions, making it ideal for work, study, or casual browsing on your smart TV.

Load a font explicitly with CSS

If a local font file is available to the renderer, CSS @font-face can identify it explicitly. When using this approach, create one FontConfiguration and pass it to both the stylesheet and the PDF write call, as in the official setup example:

from pathlib import Path

from weasyprint import CSS, HTML
from weasyprint.text.fonts import FontConfiguration

font_config = FontConfiguration()
font_path = Path("/app/fonts/your-font-file.ttf").resolve()

css = CSS(
    string=f"""
    @font-face {{
      font-family: "Target Script";
      src: url("{font_path.as_uri()}");
    }}
    body {{ font-family: "Target Script", sans-serif; }}
    """,
    font_config=font_config,
)

HTML(filename="input.html").write_pdf(
    "output.pdf",
    stylesheets=[css],
    font_config=font_config,
)

Use a real, readable path to the font file in your deployment. This example shows how to wire the font into WeasyPrint; it does not establish that any particular font file supports a particular Indian script.

Validate the target language in the PDF

Test on the Ubuntu image and under the account that will run in production. Include actual text from every required script, with the conjuncts, vowel signs, diacritics, punctuation, and numerals your documents contain. Inspect the generated PDF in a viewer; where appropriate, also check whether text can be selected or extracted. These checks help distinguish a font-rendering problem from a problem in the source HTML.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • If the expected family is not returned by fc-match, install it or correct the family name and Fontconfig visibility.
  • If the family matches but characters are missing, confirm that the chosen font covers those exact characters; a family match alone does not prove glyph coverage.
  • If the font is available system-wide but the PDF process cannot see it, check the service account, container image, and runtime environment. Try an explicit @font-face resource if needed.

WeasyPrint’s documentation says fonts are embedded in generated PDFs. Embedding does not add missing glyphs to a font that lacks them.

Best Value
Bewinner 78 Keys Minority Language Wired USB Keyboard with Multimedia Shortcut Keys, Compact Computer Keyboard for Laptop Desktop Smart TV Android (Russian)
  • Etched Keys: This wired keyboard features advanced etching technology, ensuring the letters and symbols remain clear even after prolonged use, eliminating the frustration of fading characters over time.
  • Water Proof Design: The keyboard offers a water proof outside with a comfortable touch, reducing finger strain. Its 1.35m cable and slip proof base ensure stability during use, while the space bar provides audible feedback.
  • Efficient Multimedia Shortcuts: The USB keyboard includes 12 multimedia shortcut keys for immediate access to music, volume, email, and more, enhancing productivity without the need for silent typing.
  • Plug and Play Compatibility: Wired USB interface, no need to download programs, eliminating the trouble of replacing battery or charging. Fit for , fit for Android, smart television. (note: multimedia buttons may not function support for IOS system)
  • Compact 78 Keys Layout: The small wired keyboard features a space saving 78s key design, making it portable for work space use, with clear indicator lights for caps and number lock.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common failures and fixes

Symptom Likely cause What to check
Squares appear instead of letters, or characters are absent The rendering process cannot access a suitable font, or the chosen font lacks the required glyphs. Use fc-list and fc-match in the rendering environment, verify script coverage, install a suitable font, or load it with @font-face. WeasyPrint’s missing-font guidance identifies font availability as the issue to address.
The family named in CSS is not used The family may not be installed or visible to Fontconfig, or the requested name may not match the installed family. Check the exact family reported by fc-list and the result of fc-match. Repeat the check as the PDF process’s account.
Python cannot import WeasyPrint or PDF generation fails during setup The application installation or a native dependency may be missing or incompatible with the selected installation method. Review the current installation instructions for your Ubuntu release and method, then run weasyprint --info to inspect the installation.
It works locally but fails on a server or in a container The deployed environment may not include the font or native dependencies, or may run under a different account. Install dependencies and fonts in the actual image or host, then run the same font checks and a representative render in that environment.

Security and deployment considerations

Do not treat HTML-to-PDF rendering as safe for arbitrary input. WeasyPrint’s documentation warns about security risks when processing untrusted HTML or CSS. Define an input policy and appropriate isolation and resource-access controls for your application; avoid allowing untrusted documents to trigger unrestricted access to local files or remote resources.

For repeatable deployment, keep the Ubuntu version, WeasyPrint installation method, native dependencies, font files, and CSS configuration consistent across environments. Re-run the representative-script PDF check whenever one of those changes. Font selection and deployment rights should be verified for the font you choose; the cited documentation does not establish licensing terms for a particular family.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server, not a Python HTML-to-PDF library. If your actual need is a screenshot of a public web page, one GET request can return an image or PDF:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server gives AI agents tools including take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots. It is not a substitute for rendering your own HTML or verifying Indian-script font coverage in a generated PDF. Sign up for 1,000 free screenshots a month with no card.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.