forked from thecodingmachine/gotenberg-go-client
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsplit_intervals.go
More file actions
68 lines (51 loc) 路 1.58 KB
/
Copy pathsplit_intervals.go
File metadata and controls
68 lines (51 loc) 路 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package gotenberg
import (
"strconv"
"github.com/starwalkn/gotenberg-go-client/v8/document"
)
type SplitIntervalsRequest struct {
pdfs []document.Document
embeds []document.Document
*baseRequest
}
func NewSplitIntervalsRequest(pdfs ...document.Document) *SplitIntervalsRequest {
br := newBaseRequest()
br.fields[fieldSplitMode] = splitModeIntervals
return &SplitIntervalsRequest{
pdfs: pdfs,
embeds: []document.Document{},
baseRequest: br,
}
}
func (req *SplitIntervalsRequest) endpoint() string {
return "/forms/pdfengines/split"
}
func (req *SplitIntervalsRequest) formDocuments() map[string]document.Document {
files := make(map[string]document.Document)
for _, pdf := range req.pdfs {
files[pdf.Filename()] = pdf
}
return files
}
func (req *SplitIntervalsRequest) formEmbeds() map[string]document.Document {
embeds := make(map[string]document.Document)
for _, embed := range req.embeds {
embeds[embed.Filename()] = embed
}
return embeds
}
func (req *SplitIntervalsRequest) Embeds(docs ...document.Document) {
req.embeds = append(req.embeds, docs...)
}
// SplitSpan sets the interval for split.
func (req *SplitIntervalsRequest) SplitSpan(span int) {
req.fields[fieldSplitSpan] = strconv.Itoa(span)
}
// Flatten defines whether the resulting PDF should be flattened.
func (req *SplitIntervalsRequest) Flatten(val bool) {
req.fields[fieldSplitFlatten] = strconv.FormatBool(val)
}
func (req *SplitIntervalsRequest) Encrypt(userPassword, ownerPassword string) {
req.fields[fieldUserPassword] = userPassword
req.fields[fieldOwnerPassword] = ownerPassword
}