summaryrefslogtreecommitdiff
path: root/support/arara/scripts/rules/arara-rule-pdfcrop.yaml
blob: 3c4b3e00fe5ebbb7e5642a72ab51f4a5cb8e43d1 (plain)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
!config
# Arara, the cool TeX automation tool
# Copyright (c) 2021, Island of TeX
# All rights reserved.
#
# This rule is part of arara.
identifier: pdfcrop
name: PDFCrop
authors:
- Island of TeX
commands:
- name: The cropping tool
  command: >
    @{
        base = getBasename(reference.getName());
        input = base.concat('.pdf');
        return getCommand('pdfcrop', verbose, debug, engine,
               margins, clip, hires, ini, restricted, papersize,
               resolution, bbox, uncompress, options, input, output);
    }
arguments:
- identifier: output
  flag: >
    @{
        return isEmpty(parameters.output,
               getBasename(reference.getName()).
               concat('-crop.pdf'),
               parameters.output);
    }
  default: ''
- identifier: verbose
  flag: >
    @{
        return isTrue(parameters.verbose, '--verbose', '--noverbose');
    }
- identifier: debug
  flag: >
    @{
        return isTrue(parameters.debug, '--debug', '--nodebug');
    }
- identifier: engine
  flag: >
    @{
        engines = [ 'pdftex', 'xetex', 'luatex' ];
        if (engines.contains(parameters.engine)) {
            return '--'.concat(parameters.engine);
        }
        else {
            throwError('The provided engine is invalid.');
        }
    }
- identifier: margins
  flag: >
    @{
        if (isList(parameters.margins)) {
            if (parameters.margins.size() != 4) {
                throwError('Margins require 4 elements.');
            }
            else {
                ms = [];
                foreach (m : parameters.margins)
                    ms.add(m.toString());
                return [ '--margins', String.join(' ', ms) ];
            }
        }
        else {
          throwError('I was expecting a list.');
        }
    }
- identifier: clip
  flag: >
    @{
        return isTrue(parameters.clip, '--clip', '--noclip');
    }
- identifier: hires
  flag: >
    @{
        return isTrue(parameters.hires, '--hires', '--nohires');
    }
- identifier: ini
  flag: >
    @{
        return isTrue(parameters.ini, '--ini', '--noini');
    }
- identifier: restricted
  flag: >
    @{
        return isTrue(parameters.restricted, '--restricted');
    }
- identifier: papersize
  flag: >
    @{
        return [ '--papersize', parameters.papersize ];
    }
- identifier: resolution
  flag: >
    @{
        return [ '--resolution', parameters.resolution ];
    }
- identifier: bbox
  flag: >
    @{
        if (isList(parameters.bbox)) {
            if (parameters.bbox.size() != 4) {
                throwError('Bounding box require 4 elements.');
            }
            else {
                ms = [];
                foreach (m : parameters.bbox)
                    ms.add(m.toString());
                return [ '--margins', String.join(' ', ms) ];
            }
        }
        else {
          throwError('I was expecting a list.');
        }
    }
- identifier: uncompress
  flag: >
    @{
        return isTrue(parameters.uncompress, '--uncompress');
    }
- identifier: options
  flag: >
    @{
        if (isList(parameters.options)) {
            return parameters.options;
        }
        else {
            throwError('I was expecting a list of options.');
        }
    }