Skip to content

Commit

Permalink
feat: add image formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Pikeev committed Mar 23, 2024
1 parent 18f3d8a commit 8afc2c4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions chrome.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
scale string = "scale"
skipNetworkIdleEvent string = "skipNetworkIdleEvent"
singlePage string = "singlePage"
format string = "format"
)

// nolint: gochecknoglobals
Expand Down Expand Up @@ -49,6 +50,13 @@ var (
LargeMargins = [4]float64{2, 2, 2, 2}
)

// nolint: gochecknoglobals
var (
PNG = "png"
JPEG = "jpeg"
WebP = "webp"
)

type chromeRequest struct {
header Document
footer Document
Expand Down Expand Up @@ -119,3 +127,11 @@ func (req *chromeRequest) SkipNetworkIdleEvent() {
func (req *chromeRequest) SinglePage() {
req.values[singlePage] = "true"
}

// Format sets format form field
func (req *chromeRequest) Format(format string) {
req.values[format] = format
if format == "" {
req.values[format] = JPEG
}
}

0 comments on commit 8afc2c4

Please sign in to comment.