-
Notifications
You must be signed in to change notification settings - Fork 208
/
insert.go
67 lines (60 loc) · 2.2 KB
/
insert.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
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import "fmt"
func (a *App) InsertPDF(inFile1 string, inFile2 string, insertPos int, dstPages string, posType string, outFile string) error {
logger.Printf("inFile1: %s, inFile2: %s, insertPos: %d, dstPages: %s, posType: %s, outFile: %s\n", inFile1, inFile2, insertPos, dstPages, posType, outFile)
args := []string{"insert"}
if insertPos != 0 {
args = append(args, "--insert_pos", fmt.Sprintf("%d", insertPos))
}
if posType != "" {
args = append(args, "--pos-type", posType)
}
if dstPages != "" {
args = append(args, "--page_range", dstPages)
}
if outFile != "" {
args = append(args, "-o", outFile)
}
args = append(args, inFile1)
args = append(args, inFile2)
logger.Println(args)
return a.cmdRunner(args, "pdf")
}
func (a *App) InsertBlankPDF(inFile string, outFile string, insertPos int, posType string, paper_size string, orientation string, count int) error {
logger.Printf("inFile: %s, outFile: %s, insertPos: %d, posType: %s, paper_size: %s, orientation: %s, count: %d\n", inFile, outFile, insertPos, posType, paper_size, orientation, count)
args := []string{"insert", "--method", "blank"}
args = append(args, "--insert_pos", fmt.Sprintf("%d", insertPos))
if posType != "" {
args = append(args, "--pos-type", posType)
}
if paper_size != "" {
args = append(args, "--paper_size", paper_size)
}
if orientation != "" {
args = append(args, "--orientation", orientation)
}
args = append(args, "--count", fmt.Sprintf("%d", count))
if outFile != "" {
args = append(args, "-o", outFile)
}
args = append(args, inFile, "placeholder.pdf")
logger.Println(args)
return a.cmdRunner(args, "pdf")
}
func (a *App) ReplacePDF(inFile1 string, inFile2 string, srcPages string, dstPages string, outFile string) error {
logger.Printf("inFile1: %s, inFile2: %s, srcPages: %s, dstPages: %s, outFile: %s\n", inFile1, inFile2, srcPages, dstPages, outFile)
args := []string{"replace"}
if srcPages != "" {
args = append(args, "--src_page_range", srcPages)
}
if dstPages != "" {
args = append(args, "--dst_page_range", dstPages)
}
if outFile != "" {
args = append(args, "-o", outFile)
}
args = append(args, inFile1)
args = append(args, inFile2)
logger.Println(args)
return a.cmdRunner(args, "pdf")
}