forked from thecodingmachine/gotenberg-go-client
-
Notifications
You must be signed in to change notification settings - Fork 3
/
pdfengines.go
54 lines (40 loc) · 1.21 KB
/
pdfengines.go
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
package gotenberg
import (
"strconv"
"github.com/starwalkn/gotenberg-go-client/v8/document"
)
const endpointMerge = "/forms/pdfengines/merge"
// MergeRequest facilitates work with PDF files with the Gotenberg API.
type MergeRequest struct {
pdfs []document.Document
*baseRequest
}
func NewMergeRequest(pdfs ...document.Document) *MergeRequest {
return &MergeRequest{pdfs, newBaseRequest()}
}
func (req *MergeRequest) endpoint() string {
return endpointMerge
}
func (req *MergeRequest) formDocuments() map[string]document.Document {
files := make(map[string]document.Document)
for _, pdf := range req.pdfs {
files[pdf.Filename()] = pdf
}
return files
}
// PdfA sets the PDF/A format of the resulting PDF.
func (req *MergeRequest) PdfA(pdfa PdfAFormat) {
req.fields[fieldMergePdfA] = string(pdfa)
}
// PdfUA enables PDF for Universal Access for optimal accessibility.
func (req *MergeRequest) PdfUA() {
req.fields[fieldMergePdfUA] = strconv.FormatBool(true)
}
// Metadata sets the metadata to write.
func (req *MergeRequest) Metadata(md []byte) {
req.fields[fieldMetadata] = string(md)
}
// Compile-time checks to ensure type implements desired interfaces.
var (
_ = multipartRequester(new(MergeRequest))
)