-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathformats.go
92 lines (85 loc) · 1.67 KB
/
formats.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package rtfdoc
import (
"errors"
)
func getSize(format string, layout string) (size, error) {
switch format {
case FormatLetter:
switch layout {
case OrientationLandscape:
return size{
width: 15936,
height: 12188,
}, nil
case OrientationPortrait:
return size{
width: 12188,
height: 15936,
}, nil
default:
return size{}, errors.New("Incorrect document orientation")
}
case FormatA5:
switch layout {
case OrientationLandscape:
return size{
width: 11952,
height: 16848 / 2,
}, nil
case OrientationPortrait:
return size{
width: 16848 / 2,
height: 11952,
}, nil
default:
return size{}, errors.New("Incorrect document orientation")
}
case FormatA4:
switch layout {
case OrientationLandscape:
return size{
width: 16848,
height: 11952,
}, nil
case OrientationPortrait:
return size{
width: 11952,
height: 16848,
}, nil
default:
return size{}, errors.New("Incorrect document orientation")
}
case FormatA3:
switch layout {
case OrientationLandscape:
return size{
width: 11952 * 2,
height: 16848,
}, nil
case OrientationPortrait:
return size{
width: 16848,
height: 11952 * 2,
}, nil
default:
return size{}, errors.New("Incorrect document orientation")
}
case FormatA2:
switch layout {
case OrientationLandscape:
return size{
width: 16848 * 2,
height: 11952 * 2,
}, nil
case OrientationPortrait:
return size{
width: 11952 * 2,
height: 16848 * 2,
}, nil
default:
return size{}, errors.New("Incorrect document orientation")
}
default:
return size{}, errors.New("Incorrect document format")
}
}