/
destination.go
76 lines (56 loc) · 1.89 KB
/
destination.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
68
69
70
71
72
73
74
75
76
package hpdf
/*
#cgo LDFLAGS: -lhpdf -lpng -lz
#include "hpdf.h"
*/
import "C"
func (page *Page) CreateDestination() (*Destination, error) {
destination := C.HPDF_Page_CreateDestination(page.page)
if destination != nil {
return &Destination{destination, page}, nil
} else {
return nil, page.pdf.GetLastError()
}
}
type Destination struct {
destination C.HPDF_Destination
page *Page
}
func (destination *Destination) SetXYZ(left, top, zoom float32) error {
C.HPDF_Destination_SetXYZ(
destination.destination,
C.HPDF_REAL(left), C.HPDF_REAL(top), C.HPDF_REAL(zoom),
)
return destination.page.pdf.GetLastError()
}
func (destination *Destination) SetFit() error {
C.HPDF_Destination_SetFit(destination.destination)
return destination.page.pdf.GetLastError()
}
func (destination *Destination) SetFitH(top float32) error {
C.HPDF_Destination_SetFitH(destination.destination, C.HPDF_REAL(top))
return destination.page.pdf.GetLastError()
}
func (destination *Destination) SetFitV(left float32) error {
C.HPDF_Destination_SetFitV(destination.destination, C.HPDF_REAL(left))
return destination.page.pdf.GetLastError()
}
func (destination *Destination) SetFitR(left, bottom, right, top float32) error {
C.HPDF_Destination_SetFitR(
destination.destination,
C.HPDF_REAL(left), C.HPDF_REAL(bottom), C.HPDF_REAL(right), C.HPDF_REAL(top),
)
return destination.page.pdf.GetLastError()
}
func (destination *Destination) SetFitB() error {
C.HPDF_Destination_SetFitB(destination.destination)
return destination.page.pdf.GetLastError()
}
func (destination *Destination) SetFitBH(top float32) error {
C.HPDF_Destination_SetFitBH(destination.destination, C.HPDF_REAL(top))
return destination.page.pdf.GetLastError()
}
func (destination *Destination) SetFitBV(left float32) error {
C.HPDF_Destination_SetFitBV(destination.destination, C.HPDF_REAL(left))
return destination.page.pdf.GetLastError()
}