Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Cmd = &cobra.Command{ Use: "pdf [url] [filename]", Args: cobra.ExactArgs(2), Short: "Opens a website and create a PDF file.", RunE: func(cmd *cobra.Command, args []string) error { options := Options{ Url: args[0], Viewport: &Viewport{ Width: *width, Height: *height, }, Insecure: *insecure, JavaScript: *javascript, Wait: *wait, } filename := args[1] log.Printf("options %v\n", options) log.Printf("viewport %v\n", options.Viewport) ctx, cancel := chromedp.NewContext( context.Background(), ) defer cancel() var res []byte if err := chromedp.Run(ctx, MakePdf(options, &res)); err != nil { log.Fatal(err) return err } if err := os.WriteFile(filename, res, 0o644); err != nil { log.Fatal(err) return err } log.Printf("wrote %s as %s\n", options.Url, filename) return nil }, }
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.