1

是否可以从 HTML 模板而不是URLchrome 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
        }),
    }
}

图书馆链接:https ://github.com/chromedp/chromedp

4

0 回答 0