ScreenshotNeo

BlogHow-to

How to Screenshot a Hindi Webpage in Go Using chromedp

Use Go and chromedp to capture a Hindi webpage as a viewport, full-page, or element screenshot, and troubleshoot Devanagari rendering.

By the ScreenshotNeo team4 October 20267 min read

Use chromedp to drive Chrome from Go: navigate to the Hindi page, wait for the content and fonts your page needs, capture the viewport, full page, or a visible element, then save the returned bytes. For a full-page PNG, use chromedp.FullScreenshot(&image, 100). A successful capture does not guarantee correct Devanagari glyphs: rendering depends on Chrome, available fonts, and the page’s CSS and font resources, so inspect the output in the environment where the code runs.

1. Install chromedp and capture a full-page PNG

Create a Go module and add chromedp:

mkdir hindi-shot
cd hindi-shot
go mod init example.com/hindi-shot
go get github.com/chromedp/chromedp

Save this as main.go. Replace the example URL with the page you are authorized to capture.

package main

import (
	"context"
	"log"
	"os"

	"github.com/chromedp/chromedp"
)

func main() {
	ctx, cancel := chromedp.NewContext(context.Background())
	defer cancel()

	var image []byte
	err := chromedp.Run(ctx,
		chromedp.Navigate("https://example.com/hindi-page"),
		// Add a page-specific readiness action here if the page renders
		// content or loads fonts asynchronously.
		chromedp.FullScreenshot(&image, 100),
	)
	if err != nil {
		log.Fatal(err)
	}
	if err := os.WriteFile("hindi-page.png", image, 0o644); err != nil {
		log.Fatal(err)
	}
}

Run it with go run .. The program writes hindi-page.png in the current directory. This follows the project’s documented navigation, screenshot, and file-writing pattern: chromedp project and examples.

2. Choose viewport, full-page, or element capture

Pick the screenshot action according to the area you need. These calls have different scopes:

Goal Action Output behavior
Visible browser viewport chromedp.CaptureScreenshot(&image) Captures the current viewport.
Entire page chromedp.FullScreenshot(&image, 100) Captures beyond the viewport. Quality 100 selects PNG; other quality values select JPEG.
One visible DOM element chromedp.Screenshot("main", &image, chromedp.NodeVisible) Captures the selected element’s visible bounds as PNG.

For an element screenshot, replace main with a selector that matches the page. For example, the capture portion of the action list can be:

chromedp.Navigate("https://example.com/hindi-page"),
chromedp.Screenshot("article", &image, chromedp.NodeVisible),

Keep the same error handling and os.WriteFile call. If the selector is missing, misspelled, or not visible, the element capture can fail; verify the selector against the rendered page. The APIs and their distinctions are documented in the chromedp source and examples.

3. Make Hindi and dynamic content render before capture

chromedp controls Chrome; it does not provide a universal Hindi font. Devanagari output depends on the browser environment, the page’s CSS, and whether required web fonts and content have finished loading. Navigation completing is not proof that an application has rendered its final content.

  1. Check the actual browser environment. Minimal containers may differ from a developer workstation. Confirm that the deployed Chrome can render Devanagari.
  2. Wait for the page’s real readiness condition. For a dynamically rendered page, wait for a selector that appears when the relevant content is ready. If the page uses a web font, include a page-specific readiness check for that font where appropriate.
  3. Capture after readiness. Put the screenshot action after the condition in the same chromedp.Run sequence.
  4. Inspect the saved image. Open it from the actual runtime environment and check for missing glyphs, replacement boxes, clipped lines, and unexpected fallback fonts.

A fixed delay can be useful when a page has a known, short asynchronous step, but it is less reliable than checking the condition that matters. There is no chromedp setting that universally installs or guarantees a Hindi font; choose any OS font package based on the base image and verify it there. The reviewed project sources document browser and screenshot behavior, not a certified Devanagari font setup.

4. Set viewport and headless Chrome behavior

Viewport dimensions affect line wrapping and therefore the screenshot’s appearance. Use chromedp.EmulateViewport when the page should render at a particular viewport, and specify the intended device behavior for your use case. The API notes that its defaults force landscape orientation and disable mobile and touch emulation unless options are provided.

Be careful when combining emulation with a full-page capture: chromedp.FullScreenshot overrides device emulation settings. If later actions depend on the emulated state, restore or reapply the intended settings after the full-page capture. See the chromedp API and examples for the current options.

For headless deployment, the project documents a chromedp/headless-shell image containing a headless Chrome build that chromedp can locate by default. Check the image and browser version used by your deployment: browser behavior and image contents can change.

5. Or skip the browser setup

If you need a screenshot without running Chrome yourself, ScreenshotNeo provides a website screenshot API and MCP server. Its API accepts a URL and returns an image or PDF; the one-call example below saves a WebP response. See the ScreenshotNeo API documentation for request options and formats.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com/hindi-page -o shot.webp
import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.com/hindi-page"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({
  access_key: 'YOUR_API_KEY',
  url: 'https://example.com/hindi-page'
});
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await import('node:fs/promises').then(fs => fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer())));

ScreenshotNeo accepts cookie or consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks and CAPTCHAs, 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 Claude, Cursor, and other MCP clients the take_screenshot, get_page_info, and capture_pdf tools. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

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

6. Troubleshooting

Symptom Likely cause What to do
Hindi letters are missing, boxed, or replaced The Chrome environment lacks a suitable font, or the page’s font resource did not load. Inspect the image from the runtime environment. Check the page’s font loading and the environment’s Devanagari font availability; there is no universal chromedp font switch.
Content is absent or incomplete The application renders after navigation, or content is lazy-loaded. Wait for the page-specific selector or readiness condition before capturing. For full-page capture, confirm the required content has been loaded.
Element screenshot fails The CSS selector does not match, or the selected element is not visible. Check the selector on the final rendered page and capture a visible element with chromedp.NodeVisible.
Image is only the visible screen The viewport capture action was used. Use chromedp.FullScreenshot for the full page.
Later actions use unexpected device metrics A full-page screenshot overrides device emulation settings. Reapply the intended viewport or device state after the capture if later actions rely on it.
Chrome cannot start in a container The container does not provide a compatible Chrome runtime or configuration. Review the deployment’s browser setup and the project’s headless-shell image; verify the actual browser version and image contents.
Saved file cannot be opened as PNG A non-100 quality value was passed to FullScreenshot, which selects JPEG. Use quality 100 for PNG, or save the file with the appropriate JPEG extension.

7. Performance, reliability, and cost

With chromedp, your application is responsible for starting and maintaining the Chrome runtime, managing concurrent browser work, choosing readiness checks, and storing screenshots. Capture time and resource use depend on the page, browser environment, and capture scope; the reviewed sources provide no universal benchmark. Full-page captures can contain substantially more content than viewport captures, so select the smallest scope that satisfies the task.

For reliability, set operational deadlines in the surrounding Go application, handle navigation and capture errors, and validate that the saved bytes match the expected format. Readiness checks should target page conditions that matter, especially for delayed content and fonts. chromedp itself does not charge per screenshot; hosting and operating the browser environment may have costs that depend on your deployment.

ScreenshotNeo instead charges by plan: Free includes 1,000 shots monthly with no card; Starter is $5 for 3,000, Growth $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000, and Business $249 for 1,000,000. Yearly billing gives two months free, and every feature is on every plan. Only clean shots are billed; the response includes X-Page-Verdict and X-Billed headers. See ScreenshotNeo for the service and plan details.

8. Frequently asked questions

Does chromedp translate a page into Hindi?

No. It automates Chrome to capture what the page renders; it does not translate the page.

Can I save a selected element as PNG?

Yes. Use chromedp.Screenshot with a matching visible selector and chromedp.NodeVisible.

Does a successful capture prove the Hindi font rendered correctly?

No. Check the resulting image in the same browser environment used for capture.

Should I use a viewport or full-page screenshot?

Use a viewport capture for the visible screen, a full-page capture for the whole document, and an element capture for one visible region.