forked from thecodingmachine/gotenberg-go-client
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add new split routes * fix: linter issues fixes --------- Co-authored-by: Alexander Pikeev <[email protected]>
- Loading branch information
Showing
13 changed files
with
441 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package gotenberg | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/starwalkn/gotenberg-go-client/v8/document" | ||
) | ||
|
||
type SplitIntervalsRequest struct { | ||
pdfs []document.Document | ||
|
||
*baseRequest | ||
} | ||
|
||
func NewSplitIntervalsRequest(pdfs ...document.Document) *SplitIntervalsRequest { | ||
br := newBaseRequest() | ||
br.fields[fieldSplitMode] = "intervals" | ||
|
||
return &SplitIntervalsRequest{ | ||
pdfs: pdfs, | ||
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 | ||
} | ||
|
||
// SplitSpan sets the interval for split. | ||
func (req *SplitIntervalsRequest) SplitSpan(span int) { | ||
req.fields[fieldSplitSpan] = strconv.Itoa(span) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package gotenberg | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/starwalkn/gotenberg-go-client/v8/document" | ||
) | ||
|
||
type SplitPagesRequest struct { | ||
pdfs []document.Document | ||
|
||
*baseRequest | ||
} | ||
|
||
func NewSplitPagesRequest(pdfs ...document.Document) *SplitPagesRequest { | ||
br := newBaseRequest() | ||
br.fields[fieldSplitMode] = "pages" | ||
|
||
return &SplitPagesRequest{ | ||
pdfs: pdfs, | ||
baseRequest: br, | ||
} | ||
} | ||
|
||
func (req *SplitPagesRequest) endpoint() string { | ||
return "/forms/pdfengines/split" | ||
} | ||
|
||
func (req *SplitPagesRequest) formDocuments() map[string]document.Document { | ||
files := make(map[string]document.Document) | ||
|
||
for _, pdf := range req.pdfs { | ||
files[pdf.Filename()] = pdf | ||
} | ||
|
||
return files | ||
} | ||
|
||
// SplitSpan sets the interval for split. | ||
func (req *SplitPagesRequest) SplitSpan(span string) { | ||
req.fields[fieldSplitSpan] = span | ||
} | ||
|
||
func (req *SplitPagesRequest) SplitUnify(val bool) { | ||
req.fields[fieldSplitUnify] = strconv.FormatBool(val) | ||
} |
Oops, something went wrong.