ScreenshotNeo

BlogHTML to image & PDF

Html2Pdf.app Not Capturing Devanagari Text Correctly: Fixes for Hindi PDFs

Fix missing Hindi text, boxes, and broken matras in Html2Pdf.app PDFs by checking font coverage, resource access, loading time, and print CSS.

By the ScreenshotNeo team4 October 20269 min read

If Html2Pdf.app produces missing Hindi text, boxes, disconnected letters, or misplaced matras, first check whether the PDF renderer can fetch and use a font that includes Devanagari glyphs. Explicitly load a Devanagari-capable web font, confirm its stylesheet and font files are publicly reachable, allow time for asynchronous loading with waitFor, and check whether your Hindi styles are present in the selected screen or print media mode.

Html2Pdf.app says it renders with headless Chromium and notes that available fonts and resources, CSS media mode, and JavaScript loading time can affect output. Its listed NotoSans and NotoSerif font names alone do not establish that the deployed builds include Devanagari glyphs. Load a known script-capable font explicitly and inspect the resulting PDF.

1. Confirm the HTML contains the intended Hindi text

Before changing PDF settings, verify the source document contains the actual Devanagari characters you expect, rather than replacement characters or text that is inserted incorrectly by an upstream system. Keep the HTML document encoded as UTF-8 and inspect the input sent to the conversion API. These are general diagnostics, not a special Html2Pdf.app guarantee.

<!doctype html>
<html lang="hi">
<head>
  <meta charset="utf-8">
  <title>Hindi PDF check</title>
</head>
<body>
  <p>यह हिंदी पाठ है। कृपया मात्राएँ, संयुक्ताक्षर और विराम चिह्न जाँचें।</p>
</body>
</html>

Use representative text from the document. Include the words, conjuncts, matras, punctuation, and numerals that have failed in the real output. A short generic sample can pass while a less common glyph in your content still falls back to another font.

2. Explicitly load a Devanagari-capable font

Set the font on the Hindi text and the relevant containing elements. Do not rely only on a generic family such as sans-serif, the browser on your own computer, or an undocumented assumption about fonts installed in the conversion environment.

Html2Pdf.app documents loading Google Fonts or self-hosted web fonts with CSS. For example, the following pattern uses a Google Fonts stylesheet; confirm the stylesheet and the font files it references can be reached from the conversion service:

<!doctype html>
<html lang="hi">
<head>
  <meta charset="utf-8">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Devanagari:wght@400;700&display=swap" rel="stylesheet">
  <style>
    body, .hindi {
      font-family: "Noto Sans Devanagari", sans-serif;
    }
  </style>
</head>
<body>
  <p class="hindi">यह हिंदी पाठ है। संयुक्ताक्षर और मात्राओं को PDF में जाँचें।</p>
</body>
</html>

This is a setup pattern, not a guarantee that every network or conversion environment can access Google Fonts. If you host the font yourself, use an @font-face rule whose src points to a publicly reachable font file, and make sure the server returns the file without a login, session cookie, IP allowlist, or firewall restriction.

<style>
@font-face {
  font-family: "HindiDocument";
  src: url("https://static.example.com/fonts/hindi-document.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
}
body { font-family: "HindiDocument", sans-serif; }
</style>

Replace the example host and file with your own. The URL must be accessible to the remote renderer, not merely to your logged-in browser. If the font has separate regular and bold files, declare the correct weight for each file rather than claiming one file covers weights it does not provide.

3. Check remote access to stylesheets and font files

A font can work in your browser and fail in the generated PDF because the conversion service fetches the page from its own environment. Check all of the following:

  • The HTML page or supplied URL is reachable by the conversion service.
  • The font stylesheet returns successfully without authentication.
  • Every font file referenced by the stylesheet or @font-face is publicly reachable.
  • Your server, CDN, firewall, or hotlink rules do not reject the renderer’s request.
  • The returned CSS includes the expected font family and source URL.
  • The Hindi text actually receives the intended font through its computed CSS styles.

Html2Pdf.app’s troubleshooting guidance for blank or unstyled output also recommends checking that the source URL and required CSS, fonts, and images are reachable. Avoid changing unrelated PDF options until these dependencies load correctly.

4. Allow asynchronous font loading to finish

If JavaScript, a stylesheet, or a font loads asynchronously, the conversion can start before the Hindi font is ready. Html2Pdf.app documents waitFor from 0 to 10 seconds, with a default of 0. Increase it to give the page time to finish loading, then use the smallest delay that reliably produces the expected output for your page.

The exact wait needed depends on your page and resource delivery. The documentation does not promise that one fixed value works for every site. If the font request is blocked or returns an error, waiting longer will not fix it.

5. Compare screen and print CSS

Html2Pdf.app’s media option accepts screen or print and defaults to screen. A page can define different fonts, visibility, or layout in print styles. Try the mode that your document is designed for and ensure that the chosen mode includes both the Hindi text and its font declaration.

/* Example: keep the Hindi font in both media modes */
body, .hindi { font-family: "Noto Sans Devanagari", sans-serif; }

@media print {
  .hindi { font-family: "Noto Sans Devanagari", sans-serif; }
}

Changing the media mode can affect much more than fonts, including which elements are visible and how the page is laid out. Compare the resulting PDF with the intended print design.

6. Convert a page with Html2Pdf.app

Once the page URL and font resources are reachable, call the conversion endpoint with your API key, URL, media mode, and a suitable wait. The following uses the documented cURL endpoint and parameter style; check the current API documentation for any account-specific requirements.

curl -X POST "https://api.html2pdf.app/v1/generate" \
  -H "Content-Type: application/json" \
  -d '{
    "apiKey": "YOUR_API_KEY",
    "url": "https://example.com/hindi-document",
    "media": "screen",
    "waitFor": 3
  }' \
  --output hindi-document.pdf

Set media to print if your Hindi font declaration and document layout are intended for print CSS. Adjust waitFor within the documented 0–10 second range based on the actual page’s loading behavior. The request above is a template; use the endpoint and parameter names in the provider’s current API documentation for your account.

For a cURL reference from the provider, see Html2Pdf.app’s cURL examples; for options and configuration, see its official documentation.

7. Inspect the generated PDF

Open the output and check the exact content that failed. Look for missing glyphs or empty boxes, detached or misplaced matras, incorrectly shaped conjuncts, unexpected line breaks, and differences between normal and bold text. Check whether text is selectable and searchable if that matters to your workflow. These are practical inspection steps; they are not a promise about how every PDF viewer exposes text.

If the result remains wrong, reduce the page to a minimal HTML sample with one Hindi paragraph, one explicit font, and no unrelated scripts or styles. Check the browser console and network errors in a local browser as an initial clue, then separately confirm remote access from the conversion environment. A successful local render does not prove that the service can fetch the same resources.

8. Troubleshooting common Hindi PDF failures

Symptom Likely cause What to check or change
Hindi text is missing in my PDF The source text is absent or replaced, the element is hidden by selected CSS media, or a required font/resource failed to load. Inspect the submitted HTML and text, compare screen and print, and confirm the page, stylesheet, and font URLs are reachable without authentication.
Devanagari letters appear as boxes in the PDF The active font may lack the needed glyphs and fallback may not work in the renderer. Explicitly load a font that supports Devanagari and apply it to the affected text. Do not assume the listed NotoSans or NotoSerif names prove coverage.
Hindi renders in the browser but not in the PDF Your browser may use a locally installed font or authenticated resources that the remote renderer cannot access. Use a public font URL, inspect server and CDN access rules, and test the conversion output after verifying resource availability.
Some words render correctly but others do not The chosen font may not cover every character or style used, or some content may receive a different CSS font. Test the failing characters and weights, inspect computed styles, and check that bold/italic rules point to suitable font files.
The first conversion fails, but a later one works Resources may load asynchronously or inconsistently. Try a larger waitFor value within 0–10 seconds and investigate slow or intermittent font hosting. A delay cannot repair a blocked URL.
Changing the font has no effect The selected media mode may override the rule, the selector may not match, or the stylesheet may not load. Confirm the font rule is in the selected media mode, check selector specificity and resource access, then isolate a minimal example.
The PDF is blank or missing styles The source page or required CSS, fonts, or images may not be reachable by the converter. Verify each resource can be fetched publicly and inspect page/network errors. Fix access before tuning unrelated output options.

9. Reliability, performance, and cost considerations

External font delivery introduces a dependency: the PDF result depends on the page, stylesheet, and font file all being reachable when conversion occurs. A self-hosted font can give you control over its URL and availability, while a public font service can simplify setup; either way, verify the remote renderer can fetch the resources. Increasing waitFor may reduce failures caused by slow asynchronous loading, but adds waiting time and cannot correct missing glyph coverage or access errors.

The research reviewed for this article does not establish a Devanagari-specific success rate, a font version installed in Html2Pdf.app, or a performance benchmark for Hindi documents. Treat output inspection as part of the workflow, especially after changing fonts, stylesheets, or the source page. Consult the provider’s current documentation for API pricing and request limits rather than relying on assumptions.

10. Or skip the browser setup

If your task is to capture a webpage as an image for documentation, review, or an AI workflow, ScreenshotNeo provides a website screenshot API and MCP server. It is not an HTML-to-PDF replacement; use it when a clean webpage screenshot is the output you need. See ScreenshotNeo and the ScreenshotNeo API documentation.

One GET request returns a PNG, JPEG, WebP, or PDF capture. For example, save a clean webpage capture with cURL:

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

Equivalent Python:

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)

Equivalent Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
  • Cookie banners, popups, and chat widgets are removed before the shot; each cleanup step can be turned off.
  • Bot checks, blank pages, and failed loads are never billed. Response headers identify the page verdict and billing status.
  • An MCP server lets AI agents, including Claude, Cursor, and other MCP clients, take screenshots.
  • 1,000 screenshots a month are free with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

11. Frequently asked questions

Does changing the PDF paper size fix missing Devanagari letters?

Usually, paper size is unrelated to font glyph coverage or resource loading. First verify the font, its remote accessibility, loading time, and the selected CSS media mode.

Can I assume Html2Pdf.app’s NotoSans or NotoSerif includes Hindi?

No. The documentation lists those family names but does not specify their script coverage, version, or a Devanagari rendering guarantee. Explicitly load a suitable font and inspect the output.

What value should I use for waitFor?

There is no universal value. The documented range is 0–10 seconds; start with a reasonable delay for your page, then verify repeatable output and address any resource errors that waiting cannot solve.

Why does Hindi work on my computer but not in the converted PDF?

Your local browser may have a font or authenticated resource unavailable to the remote Chromium renderer. Make the needed stylesheet and font files publicly reachable and apply the font explicitly.

Will ScreenshotNeo fix Hindi text in an HTML-to-PDF conversion?

ScreenshotNeo captures webpages as images or PDFs and offers cleanup features for screenshots. It does not guarantee Devanagari font coverage in Html2Pdf.app; diagnose the font and resource configuration in the renderer producing your Hindi PDF.