Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Capture Hindi Web Pages with url2png

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Capturing Hindi web pages with url2png can be tricky because the service renders pages as images, and if the fonts or encoding aren’t handled correctly, you’ll end up with garbled text or missing characters. This guide walks you through the exact steps to get crisp, readable Hindi screenshots every time, whether you’re saving a news article, a blog post, or a government form.

What You'll Need

  • A url2png API key (free trial available at url2png.com)
  • A tool to make HTTP requests – cURL, Postman, or any programming language (Python, JavaScript, etc.)
  • Basic knowledge of URL encoding and query parameters
  • Optional: a local test HTML file with Hindi text to verify before using live pages

Step-by-Step

  1. Get your API key and secret – Sign in to your url2png dashboard. You’ll see an API key and a secret key. Keep these handy; you’ll need both to generate a token.
  2. Construct the base URL – The url2png API endpoint is https://api.url2png.com/v6/PORT/TOKEN/ where PORT is your API key and TOKEN is a hash you generate.
  3. Generate the token – The token is an MD5 hash of your secret key + the full target URL (including query parameters). For example, if your secret is SECRET and the target URL is https://example.com/hindi-page, the token is md5(SECRET + 'https://example.com/hindi-page'). Use any MD5 tool or library to compute it.
  4. Build the full API request URL – Append the target URL as a query parameter, plus any options. For Hindi pages, you must set the viewport to a desktop size (e.g., 1280x1024) and, crucially, add force to refresh the page if needed. A typical request looks like:
    https://api.url2png.com/v6/YOUR_KEY/YOUR_TOKEN/?url=https%3A%2F%2Fexample.com%2Fhindi-page&viewport=1280x1024&fullpage=true
  5. URL-encode the target URL – Always encode the target URL properly. Spaces become %20, colons become %3A, slashes become %2F. Most HTTP libraries handle this automatically, but if you’re building the URL manually, double-check.
  6. Add the accept_lang parameter – url2png supports an accept_lang parameter that tells the browser which language to prefer. Set it to hi or hi-IN to ensure the server sends Hindi content if the site is multilingual. For example: &accept_lang=hi-IN.
  7. Make the GET request – Use your HTTP client to fetch the API URL. The response will be a PNG image. Save it to a file, e.g., capture.png.
  8. Verify the output – Open the PNG and check that Hindi text appears correctly. If you see boxes or question marks, it means the font didn’t load. In that case, you may need to use a custom CSS or wait for webfonts.
  9. Handle dynamic content – If the page loads Hindi text via JavaScript (e.g., a React app), you might need to add a delay. url2png has a wait_for_selector parameter. For example, &wait_for_selector=.content will wait until that element appears.
  10. Use fullpage for long articles – For long Hindi articles, set fullpage=true to capture the entire page height. This is especially useful for PDF-like captures.

Common Mistakes

  • Not URL-encoding the target URL – This is the most common error. If the URL contains unencoded characters, the API returns an error or a wrong page.
  • Forgetting the secret key in the token – The token must be MD5 of secret + URL. If you use the API key alone, you’ll get a 401 error.
  • Using a small viewport – A mobile viewport (e.g., 375x812) may cause the page to render a mobile layout that hides Hindi text or uses a different font. Stick to desktop sizes for consistent results.
  • Ignoring webfonts – Many Hindi sites use Google Fonts (like Noto Sans Devanagari). If the page loads fonts via JavaScript, they might not be ready when the screenshot is taken. Use the wait_for_selector or a delay.
  • Not setting accept_lang – Without this, the server might return the English version of a bilingual site, so you won’t see Hindi at all.

Tips

  • Test with a static HTML file first – Upload a simple HTML file with Hindi text and a Google Font link to a test server, then capture it. This isolates font issues from dynamic content issues.
  • Use the force parameter – If you’ve captured a page before and it changed, add force=true to bypass the cache.
  • Combine with max_wait – The max_wait parameter (in milliseconds) tells url2png how long to wait for the page to load. Set it to 5000 or more for heavy pages.
  • Check the page’s character encoding – Ensure the target page uses UTF-8. Most modern sites do, but if not, you may see garbled text. You can’t change the page, but you can request a different URL if the site has a UTF-8 version.
  • Use a custom CSS if needed – url2png allows you to inject CSS via the custom_css parameter. You can force a specific font family like font-family: 'Noto Sans Devanagari', sans-serif; to override missing fonts.

Troubleshooting

  • Blank or white image – The page might be blocking bots or requiring JavaScript. Try adding javascript=true (it’s on by default) and increase max_wait. Also check if the page has a CAPTCHA.
  • Hindi text shows as boxes (□) – This means the font is not rendering. Use the custom_css parameter to import a Devanagari font from Google Fonts. For example: custom_css=@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Devanagari&display=swap'); and set the font-family.
  • Text is garbled (mojibake) – The page might be served in a non-UTF-8 encoding. Check the page’s meta charset. If it’s not UTF-8, you may need to find an alternate URL or use a proxy.
  • API returns 401 Unauthorized – Your token is wrong. Recompute the MD5 hash. Ensure you’re using the secret key, not the API key, and that you’re concatenating the secret with the full URL exactly as it appears in the request (including the query parameters).
  • Page loads but Hindi text is cut off – The viewport might be too small. Increase the height in the viewport parameter, or set fullpage=true.
  • Image is blurry – Increase the viewport width to 1920 or use the scale parameter (e.g., scale=2) for retina-quality captures.

Frequently Asked Questions

Does url2png support Hindi fonts automatically?

It depends on the page. If the page loads webfonts via CSS, they usually render. If not, you may need to inject a font using the custom_css parameter.

Can I capture a Hindi page that requires login?

Yes, but you’ll need to use the auth parameter with basic authentication, or use a session cookie via the cookie parameter. However, this is advanced and may not work with all sites.

Why does the capture show English instead of Hindi?

The site may be serving content based on the browser’s language. Set accept_lang=hi or hi-IN to request Hindi.

How do I capture a full page of a long Hindi article?

Add fullpage=true to your request. This will make url2png scroll the page and stitch together a full-length screenshot.

Is there a limit to the number of captures?

Yes, url2png offers different plans with monthly limits. Check your dashboard for your current quota.

Can I capture a Hindi page that uses JavaScript to load content?

Yes, url2png renders JavaScript by default. If the content is slow to load, increase max_wait or use wait_for_selector to wait for a specific element.