是否可以从 HTML 模板而不是URL
chrome dp 库中生成 PDF/屏幕截图?
func printToPDF(urlstr string, res *[]byte) chromedp.Tasks {
return chromedp.Tasks{
chromedp.Navigate(urlstr),
//page.SetDocumentContent("body", "<h1>Hello world</h1>"), Something like this is this possible?
chromedp.ActionFunc(func(ctx context.Context) error {
buf, _, err := page.PrintToPDF().WithPrintBackground(false).Do(ctx)
if err != nil {
return err
}
*res = buf
return nil
}),
}
}