Go ChromeDP not using any css either internal or external styles (only those, that was written in html, not other file). I using method
page.SetDocumentContent(frameTree.Frame.ID, string(buf.Bytes())).Do(ctx)
to add html file to chromedp, and
buf, _, err: = page.PrintToPDF().Do(ctx)
if err != nil {
return err
}
_, err = outputBuf.Write(buf)
if err != nil {
return err
}
to print to pdf, but pdf in result not styled (even with external css fileserver). I tried to add it with page.GetResourceTree().Do(ctx)
+ css.CreateStyleSheet(resourceTree.Frame.ID).Do(ctx)
+
css.SetStyleSheetText(stylesheet, `.c {
color: red;
font-size: 30px;
background-color: aqua;
}
`).Do(ctx)
and it worked, but it sad to use it every time I want generate pdf, especially in my case, because I am using html from html/template. Maybe there are easy way to add external css into single html file? What do you think?
Thanks for any answer
Bohdan
I want to convert go template with external css, images and font into pdf using chromedp, but it ignored anything beyond main html file.