As shown in the title, here is the result and my code. By the way, I am using a very low-end machine.
func main() {
chromeCTX, _ := chromedp.NewContext(context.Background())
emulation.SetDeviceMetricsOverride(1920, 1080, 1.0, false).Do(chromeCTX)
var width, height int64
var b []byte
err := chromedp.Run(chromeCTX,
chromedp.EmulateViewport(10, 10),
chromedp.Navigate(`The content of the file is in the code block below.html`),
chromedp.EvaluateAsDevTools(`document.documentElement.scrollWidth`, &width),
chromedp.EmulateViewport(width, 10),
chromedp.EvaluateAsDevTools(`document.documentElement.scrollHeight`, &height),
chromedp.EmulateViewport(width, height),
chromedp.FullScreenshot(&b, 100),
)
if err != nil {
log.Fatal(err)
}
err = ioutil.WriteFile("test.png", b, 0777)
if err != nil {
log.Fatal(err)
}
}
<!DOCTYPE html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="main">
# 123
123
$\sin(x)=\sum_{n=0}^{\infty} \frac{(-1)^n}{(2n+1)!}x^{2n+1} \sin(x)=\sum_{n=0}^{\infty} \frac{(-1)^n}{(2n+1)!}x^{2n+1} \sin(x)=\sum_{n=0}^{\infty} \frac{(-1)^n}{(2n+1)!}x^{2n+1} \sin(x)=\sum_{n=0}^{\infty} \frac{(-1)^n}{(2n+1)!}x^{2n+1}$
</div>
<script src="https://cdn.jsdelivr.net/npm/markdown-it-latex2img@0.0.6/dist/markdown-it-latex2img.min.js"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/markdown-it@11.0.0/dist/markdown-it.min.js"
crossorigin="anonymous"></script>
<script>
var main = document.getElementById("main");
var md = window.markdownit({ html: true });
md.use(window.markdownitLatex2img, { style: "filter: opacity(75%);transform:scale(0.75);text-align:center" });
var result = md.render(main.innerHTML);
main.innerHTML = result;
</script>
</body>
I guess maybe there is a setting for DPI? Or maybe it's because my machine is too weak? Unfortunately, I don't have more resources to explore the truth. So I'm asking for help from you guys, how can I make the screenshot clearer?