ScreenshotNeo

BlogHTML to image & PDF

How to Render Hindi Text Correctly in PDFs Made with PDFShift

Use a Devanagari-capable font with PDFShift, make font loading predictable, and inspect the PDF for correct Hindi shaping.

By the ScreenshotNeo team4 October 20266 min read

To render Hindi correctly in a PDF made with PDFShift, supply a font that covers the Devanagari characters in your document, define it with CSS @font-face, and apply it to the Hindi text. Make the font available from a reliably reachable local URL or embed its data where practical, then inspect the generated PDF for both glyph coverage and shaping. A CSS declaration and valid Unicode input alone do not guarantee correctly shaped Devanagari.

PDFShift accepts custom font CSS through its css conversion parameter. Its guidance says local or base64-encoded fonts load more consistently than remote fonts, which may not finish loading before conversion begins. The sources reviewed do not certify a Hindi font list or identify PDFShift’s rendering engine and version, so treat the output PDF as the final check. PDFShift documentation

1. Choose and validate a Devanagari font

Pick a font that has the Devanagari glyphs your content uses and suitable OpenType shaping behavior. Devanagari is an abugida: consonants have an inherent vowel, vowel signs modify it, and consonant clusters can involve virama and context-sensitive forms. A shaping system may reorder marks in the displayed result relative to their stored character order. W3C Indic Layout Requirements · Microsoft OpenType Devanagari guidance

Do not assume a font supports Hindi just because it is multilingual or because it works for Latin text. Check the actual glyph coverage and test representative content, including vowel signs, conjuncts, virama behavior, and punctuation. PDFShift’s custom-font example demonstrates changing a font; it does not establish that its sample font is suitable for Hindi.

2. Apply the font in PDFShift CSS

Define the font family and apply it to the Hindi content. Replace the example family name and URL with a font you have validated and that the conversion process can access.

@font-face {
  font-family: 'Your Devanagari Font';
  font-style: normal;
  font-weight: 400;
  src: url('https://your-host.example/fonts/devanagari-font.woff2') format('woff2');
}
.hindi {
  font-family: 'Your Devanagari Font', sans-serif;
}

Use the css parameter to pass CSS with the conversion request. PDFShift documents that this parameter can be a CSS string or a URL. Confirm the request format and authentication details against the PDFShift API documentation.

3. Make font loading predictable

  1. Prefer a dependable source. Use a font file reachable to the converter, or base64-encoded font data in the CSS when that fits your workflow. PDFShift recommends local or base64 sources for more consistent loading.
  2. If using a remote font, check access. The URL must be reachable from the conversion environment. A font that loads in your own browser may still be unavailable to the converter.
  3. Allow time for external resources. PDFShift suggests experimenting with a delay or its wait_for JavaScript option when an external font may still be loading at conversion time. Consult the current API documentation for the exact request syntax.
  4. Keep the font declaration aligned with the content. Apply the family to the Hindi text or its containing section, and account for any weights and styles used by the document.

External URL delivery is usually simpler to configure, but can be inconsistent if conversion starts before the font finishes loading. Local or base64 delivery requires more setup or request data, but PDFShift identifies it as the more reliable loading approach.

4. Inspect the generated PDF

Check the actual PDF artifact rather than relying on the HTML preview or successful API response. Use a short test document that includes ordinary Hindi words as well as cases that exercise combining marks and clusters.

  • Verify that every character is present and no boxes, blanks, or fallback glyphs appear.
  • Check that vowel signs appear in the expected visual position.
  • Check representative consonant clusters and virama behavior.
  • Inspect punctuation, line breaks, and text near page boundaries.
  • Repeat the check after changing the font source, CSS, or conversion wait behavior.

This checklist follows from Devanagari’s shaping requirements; the cited sources do not provide a PDFShift-specific Hindi validation suite.

5. Troubleshoot Hindi rendering problems

What you see Likely cause What to check or change
Boxes, blanks, or replacement glyphs The font lacks one or more needed Devanagari glyphs, or the font failed to load. Verify coverage for the characters in the document and confirm that the conversion process can fetch the font. Try a local or base64 source.
Some Hindi appears, but vowel signs or clusters look wrong The font and shaping behavior may not produce the needed contextual forms. Test a simple word and a sample with matras and conjuncts. Try a font with appropriate Devanagari shaping support. CSS cannot guarantee a renderer will shape every sequence correctly.
The output changes between conversions An external font may load intermittently or too late. Use a local or base64-encoded font where practical. If the font remains external, investigate PDFShift’s delay or wait_for options.
Hindi works in a browser preview but not in the PDF The preview and PDF conversion may have different font access or rendering behavior. Check the PDF conversion’s font URL accessibility, CSS, and final output independently; do not treat browser display as proof of PDF correctness.
Only part of a document uses the intended font The CSS selector may not cover all Hindi text, or some content may use another weight or style. Apply the font to the relevant container or text elements and define the weights and styles the document uses.

These causes are troubleshooting inferences from the documented external-font timing risk and Devanagari font and shaping requirements. PDFShift’s reviewed material does not establish a specific rendering engine version or guarantee identical results for every font.

6. Performance, reliability, and cost considerations

  • Font delivery affects reliability. A remotely hosted font adds a resource that must be accessible and loaded before conversion. Local or base64 delivery can make that dependency more predictable, at the cost of hosting work or a larger CSS payload.
  • Wait behavior affects conversion time. A delay or resource wait can help when external fonts load late, but avoid adding more waiting than the document needs. Use PDFShift’s current documentation for supported options.
  • Validate changes with a small representative document. A compact sample containing the Hindi forms your production documents use makes it easier to isolate font-loading and shaping issues.
  • Budget and pricing are service-specific. The research sources cited here do not establish PDFShift pricing or conversion limits. Check PDFShift’s current pricing and account terms before estimating production costs.

7. Or skip the browser setup

If your goal is a clean screenshot of a page that contains Hindi, ScreenshotNeo returns a screenshot or PDF from one API request. For PDFShift specifically, use the font workflow above: ScreenshotNeo is a website screenshot API, not a replacement for configuring PDFShift’s Hindi PDF typography.

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 output and request options. Cookie banners, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

Sign up for 1,000 free screenshots a month, with no card.

Frequently asked questions

Does Unicode Hindi text guarantee a correct PDF?

No. Unicode represents the text, but the font needs the relevant glyphs and the rendering path must shape Devanagari correctly.

Can I use any WOFF2 font with @font-face?

No. The file must be reachable by the converter, cover the text, and work with the renderer’s shaping behavior. Validate the output PDF.

Does PDFShift publish a verified list of Hindi fonts?

The reviewed PDFShift material explains custom fonts and loading approaches, but does not provide a Hindi-specific compatibility list.

Should I use an external URL or embed the font?

Use an external URL when convenient and reliably accessible. For more consistent loading, PDFShift recommends local or base64-encoded font sources.