ScreenshotNeo

BlogHow-to

Capture a webpage screenshot in Tamil with Go chromedp and install the right fonts

Capture Tamil webpages with Go chromedp, install Tamil fonts in the Chromium runtime, and choose the right screenshot bounds for your page.

By the ScreenshotNeo team4 October 20267 min read

To capture Tamil text correctly with Go and chromedp, install a Tamil-capable font in the same host or container that runs Chromium, then navigate to the page and take a screenshot after its content and fonts are ready. On Ubuntu, fonts-noto-core includes Noto Sans Tamil regular and bold. The correct package command depends on your distribution and release, so verify the browser runtime before installing.

1. Install Tamil fonts where Chromium runs

Chromedp controls Chrome or Chromium through the Chrome DevTools Protocol. A font installed on your laptop is not automatically available to Chromium in a CI job or container. Install the font in the environment that launches the browser.

For Ubuntu, the fonts-noto-core package is one option; the Ubuntu Jammy package manifest lists NotoSansTamil-Regular.ttf and NotoSansTamil-Bold.ttf. See the Ubuntu package record and its file manifest. Package names and commands vary by OS and version.

For a Debian or Ubuntu based image, the package installation step is commonly:

apt-get update
apt-get install -y fonts-noto-core

Run this while building the image or preparing the same runtime environment that starts Chromium. On another distribution, identify its Tamil font package and package manager first. Check font availability in that runtime, for example with fc-list if Fontconfig utilities are installed:

fc-list | grep -i tamil

This check reports fonts registered in the environment; it does not guarantee a specific webpage will select the font or that every glyph will look as intended. Inspect the resulting screenshot using the actual page and browser image.

2. Add chromedp and make Chromium available

Start with a Go module and add chromedp:

go mod init example.com/tamil-shot
go get github.com/chromedp/chromedp

Chromedp needs a Chrome or Chromium executable available to the process. In headless environments it runs Chrome headlessly by default. The project README also identifies chromedp/headless-shell as a straightforward headless option. Choose and pin an image version appropriate to your environment rather than relying on an unpinned image.

3. Capture a page in Go

This runnable program navigates to a Tamil webpage, waits for the document to reach load, waits briefly for delayed rendering, and writes both a viewport screenshot and a full-page PNG. Replace the example URL with the page you need to capture. A load event and fixed delay are only basic readiness measures; for an application page, use a selector that indicates the content you need is ready.

package main

import (
	"context"
	"log"
	"os"
	"time"

	"github.com/chromedp/chromedp"
)

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

	ctx, cancel = context.WithTimeout(ctx, 60*time.Second)
	defer cancel()

	var viewport []byte
	var fullPage []byte

	err := chromedp.Run(ctx,
		chromedp.Navigate("https://ta.wikipedia.org/wiki/தமிழ்"),
		chromedp.WaitReady("body"),
		chromedp.Sleep(2*time.Second),
		chromedp.CaptureScreenshot(&viewport),
		chromedp.FullScreenshot(&fullPage, 100),
	)
	if err != nil {
		log.Fatal(err)
	}

	if err := os.WriteFile("viewport.png", viewport, 0644); err != nil {
		log.Fatal(err)
	}
	if err := os.WriteFile("full-page.png", fullPage, 0644); err != nil {
		log.Fatal(err)
	}
}

The chromedp upstream example shows the same context, navigation, screenshot action, and file-writing structure; see its examples and API documentation.

Pick the screenshot bounds and format

Action What it captures Use it when
chromedp.CaptureScreenshot The current browser viewport You need only the visible area.
chromedp.FullScreenshot The full page beyond the viewport You need a long page in one image.
chromedp.Screenshot A selected DOM element You need one visible component or region.

FullScreenshot uses quality 100 for PNG output. Other quality values select JPEG, within its documented 0–100 quality range. For element captures, select the element by its CSS selector and ensure it is present and visible before capturing. See the FullScreenshot API and Screenshot API.

Wait for the content you actually need

Navigation finishing does not prove that a single-page application has rendered its final content, that remote images have loaded, or that web fonts have finished loading. The sample waits for the body and then sleeps briefly as a simple fallback. Prefer a page-specific readiness signal when available:

chromedp.WaitVisible("main .article-content"),

Choose a selector that appears only when the Tamil text you need is rendered. If the site loads its own web font, waiting for that content does not by itself prove the font has loaded; inspect the result and adjust the wait for the page. There is no universal delay that guarantees readiness for every site.

4. Verify Tamil rendering in the output

  1. Run the program in the same environment that contains the installed font and Chromium executable.
  2. Open the PNG and check that Tamil glyphs appear instead of blank areas or replacement boxes.
  3. If the screenshot is wrong, check the runtime’s font list, the webpage’s selected font and fallback behavior, and whether capture happened before the content or font was ready.
  4. Repeat the check in the production container or CI image, not only on a developer workstation.

The font package manifest establishes that the listed Tamil font files are part of the package; it cannot guarantee a particular site’s font stack, shaping, or final appearance. Validate the actual page in the target runtime.

5. Use cURL, Python, or Node.js when you do not need local browser control

For a direct screenshot without setting up Chromium yourself, ScreenshotNeo accepts a URL and returns an image or PDF. The following examples use the required API form; see the ScreenshotNeo API documentation for available options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://ta.wikipedia.org/wiki/தமிழ் -o shot.webp
import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://ta.wikipedia.org/wiki/தமிழ்"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({
  access_key: 'YOUR_API_KEY',
  url: 'https://ta.wikipedia.org/wiki/தமிழ்'
});
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())));

Or skip the browser setup

Make one request to ScreenshotNeo with the target URL. Consent banners are accepted like a visitor, and 60+ known consent platforms, newsletter popups, and chat widgets are removed before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://ta.wikipedia.org/wiki/தமிழ் -o shot.webp

Create a free account for 1,000 screenshots a month, with no card.

Common problems and fixes

Symptom Likely cause What to check or change
Tamil characters appear as boxes or are missing No Tamil-capable font is installed in the Chromium runtime, or the page’s font stack does not reach one. Install a Tamil font package in the host or container that launches Chromium. Check available fonts there and inspect the page’s font and fallback behavior.
Fonts exist on the host but not in CI The CI image is separate from the developer machine. Add font installation to the image or job setup used to run Chromium, then verify in that same environment.
The page is blank or incomplete Capture ran before application content appeared, or navigation failed. Check the destination and browser logs; wait for a page-specific selector that signals required content is present.
Text looks correct locally but different in a container The container may have different fonts, browser, or font configuration. Compare the runtime’s installed fonts and browser setup; deploy the font package in the capture image.
Screenshot cuts off the lower page Viewport capture was used. Use chromedp.FullScreenshot for a full-page image.
Screenshot is unexpectedly large or slow A full-page image includes much more area than a viewport capture. Capture only the required element or viewport when possible, and avoid capturing long pages if the consumer does not need them.
Chromedp cannot start the browser Chrome or Chromium is unavailable or not configured in the runtime. Install or provide a compatible browser executable, and use an appropriate headless runtime for CI or containers.
Program times out The page is slow, waiting is too short, or browser startup and navigation exceed the deadline. Use a realistic context timeout, wait for the content you require, and investigate slow navigation or browser startup rather than increasing the delay blindly.

Performance, reliability, and cost

  • Capture size: Full-page screenshots can contain far more pixels than viewport or element captures. Choose bounds to match the consumer’s need.
  • Readiness: A fixed sleep can add unnecessary latency and still miss slow content. A page-specific readiness selector is generally a more useful signal, but validate it against the target page.
  • Repeatability: Keep the browser runtime and font installation consistent between local, CI, and production capture environments. Pin the container image version you choose.
  • Failure handling: Set a context timeout and handle errors from navigation, screenshot capture, and file writes. A successful file write does not establish that the page rendered correctly; inspect output when correctness matters.
  • Cost: The chromedp route requires you to provide and operate the browser runtime; this guide makes no cost estimate for that infrastructure. ScreenshotNeo offers 1,000 shots monthly free without a card; paid plans are Starter $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.

FAQ

Does installing Noto Sans Tamil guarantee correct rendering?

No. It makes Tamil font files available to the browser, but the site may select a different font or have other rendering requirements. Check the actual output.

Should I use a viewport or full-page screenshot?

Use a viewport capture for the visible browser area and FullScreenshot when the entire long page must fit in one image.

Can I use chromedp in a headless container?

Yes, provided a compatible Chrome or Chromium runtime is available there. Install the Tamil font in that same runtime environment.

Why does the capture differ from my desktop?

The browser environment may differ in installed fonts, browser version, or page readiness. Compare the actual runtimes and inspect the capture from the target environment.