| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
MODULE = PDF::Make PACKAGE = PDF::Make::Redaction |
|
2
|
|
|
|
|
|
|
PROTOTYPES: ENABLE |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
void |
|
5
|
|
|
|
|
|
|
mark(class, page, ...) |
|
6
|
|
|
|
|
|
|
char *class |
|
7
|
|
|
|
|
|
|
pdfmake_page_t *page |
|
8
|
|
|
|
|
|
|
PREINIT: |
|
9
|
22
|
|
|
|
|
|
double x0 = 0, y0 = 0, x1 = 0, y1 = 0; |
|
10
|
|
|
|
|
|
|
pdfmake_redact_opts_t opts; |
|
11
|
|
|
|
|
|
|
pdfmake_redact_t *r; |
|
12
|
|
|
|
|
|
|
int i; |
|
13
|
|
|
|
|
|
|
CODE: |
|
14
|
|
|
|
|
|
|
PERL_UNUSED_VAR(class); |
|
15
|
22
|
|
|
|
|
|
memset(&opts, 0, sizeof(opts)); |
|
16
|
22
|
|
|
|
|
|
opts.overlay_font_size = 10; |
|
17
|
|
|
|
|
|
|
|
|
18
|
77
|
100
|
|
|
|
|
for (i = 2; i < items - 1; i += 2) { |
|
19
|
55
|
|
|
|
|
|
const char *key = SvPV_nolen(ST(i)); |
|
20
|
55
|
|
|
|
|
|
SV *val = ST(i + 1); |
|
21
|
55
|
100
|
|
|
|
|
if (strEQ(key, "x0")) x0 = SvNV(val); |
|
22
|
54
|
100
|
|
|
|
|
else if (strEQ(key, "y0")) y0 = SvNV(val); |
|
23
|
53
|
100
|
|
|
|
|
else if (strEQ(key, "x1")) x1 = SvNV(val); |
|
24
|
52
|
100
|
|
|
|
|
else if (strEQ(key, "y1")) y1 = SvNV(val); |
|
25
|
72
|
100
|
|
|
|
|
else if (strEQ(key, "rect") && SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVAV) { |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
26
|
21
|
|
|
|
|
|
AV *av = (AV *)SvRV(val); |
|
27
|
|
|
|
|
|
|
SV **e; |
|
28
|
21
|
50
|
|
|
|
|
if ((e = av_fetch(av, 0, 0))) x0 = SvNV(*e); |
|
29
|
21
|
50
|
|
|
|
|
if ((e = av_fetch(av, 1, 0))) y0 = SvNV(*e); |
|
30
|
21
|
50
|
|
|
|
|
if ((e = av_fetch(av, 2, 0))) x1 = SvNV(*e); |
|
31
|
21
|
50
|
|
|
|
|
if ((e = av_fetch(av, 3, 0))) y1 = SvNV(*e); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
42
|
100
|
|
|
|
|
else if (strEQ(key, "overlay_color") && SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVAV) { |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
34
|
12
|
|
|
|
|
|
AV *av = (AV *)SvRV(val); |
|
35
|
|
|
|
|
|
|
SV **e; |
|
36
|
12
|
50
|
|
|
|
|
if ((e = av_fetch(av, 0, 0))) opts.overlay_color[0] = SvNV(*e); |
|
37
|
12
|
50
|
|
|
|
|
if ((e = av_fetch(av, 1, 0))) opts.overlay_color[1] = SvNV(*e); |
|
38
|
12
|
50
|
|
|
|
|
if ((e = av_fetch(av, 2, 0))) opts.overlay_color[2] = SvNV(*e); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
18
|
100
|
|
|
|
|
else if (strEQ(key, "overlay_text")) opts.overlay_text = SvPV_nolen(val); |
|
41
|
1
|
50
|
|
|
|
|
else if (strEQ(key, "overlay_font_size")) opts.overlay_font_size = SvNV(val); |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
22
|
|
|
|
|
|
r = pdfmake_page_mark_redaction(page, x0, y0, x1, y1, &opts); |
|
45
|
22
|
50
|
|
|
|
|
if (!r) |
|
46
|
0
|
|
|
|
|
|
croak("PDF::Make::Redaction: mark failed"); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
void |
|
49
|
|
|
|
|
|
|
apply_page(class, page) |
|
50
|
|
|
|
|
|
|
char *class |
|
51
|
|
|
|
|
|
|
pdfmake_page_t *page |
|
52
|
|
|
|
|
|
|
CODE: |
|
53
|
|
|
|
|
|
|
PERL_UNUSED_VAR(class); |
|
54
|
0
|
0
|
|
|
|
|
if (pdfmake_page_apply_redactions(page) != PDFMAKE_OK) |
|
55
|
0
|
|
|
|
|
|
croak("PDF::Make::Redaction: apply failed"); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
void |
|
58
|
|
|
|
|
|
|
apply_doc(class, doc) |
|
59
|
|
|
|
|
|
|
char *class |
|
60
|
|
|
|
|
|
|
pdfmake_doc_t *doc |
|
61
|
|
|
|
|
|
|
CODE: |
|
62
|
|
|
|
|
|
|
PERL_UNUSED_VAR(class); |
|
63
|
0
|
0
|
|
|
|
|
if (pdfmake_doc_apply_redactions(doc) != PDFMAKE_OK) |
|
64
|
0
|
|
|
|
|
|
croak("PDF::Make::Redaction: apply failed"); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
void |
|
67
|
|
|
|
|
|
|
sanitize(class, doc) |
|
68
|
|
|
|
|
|
|
char *class |
|
69
|
|
|
|
|
|
|
pdfmake_doc_t *doc |
|
70
|
|
|
|
|
|
|
CODE: |
|
71
|
|
|
|
|
|
|
PERL_UNUSED_VAR(class); |
|
72
|
5
|
50
|
|
|
|
|
if (pdfmake_doc_sanitize_metadata(doc) != PDFMAKE_OK) |
|
73
|
0
|
|
|
|
|
|
croak("PDF::Make::Redaction: sanitize failed"); |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
UV |
|
76
|
|
|
|
|
|
|
count(class, page) |
|
77
|
|
|
|
|
|
|
char *class |
|
78
|
|
|
|
|
|
|
pdfmake_page_t *page |
|
79
|
|
|
|
|
|
|
CODE: |
|
80
|
|
|
|
|
|
|
PERL_UNUSED_VAR(class); |
|
81
|
9
|
|
|
|
|
|
RETVAL = pdfmake_page_redaction_count(page); |
|
82
|
|
|
|
|
|
|
OUTPUT: |
|
83
|
|
|
|
|
|
|
RETVAL |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
SV * |
|
86
|
|
|
|
|
|
|
rewrite_stream(class, content_sv, rects_sv) |
|
87
|
|
|
|
|
|
|
char *class |
|
88
|
|
|
|
|
|
|
SV *content_sv |
|
89
|
|
|
|
|
|
|
SV *rects_sv |
|
90
|
|
|
|
|
|
|
PREINIT: |
|
91
|
|
|
|
|
|
|
STRLEN in_len; |
|
92
|
|
|
|
|
|
|
const uint8_t *in_bytes; |
|
93
|
|
|
|
|
|
|
AV *rects_av; |
|
94
|
|
|
|
|
|
|
SSize_t n_rects; |
|
95
|
1
|
|
|
|
|
|
pdfmake_redact_t *rects = NULL; |
|
96
|
|
|
|
|
|
|
pdfmake_buf_t out; |
|
97
|
|
|
|
|
|
|
pdfmake_err_t err; |
|
98
|
|
|
|
|
|
|
CODE: |
|
99
|
|
|
|
|
|
|
PERL_UNUSED_VAR(class); |
|
100
|
1
|
|
|
|
|
|
in_bytes = (const uint8_t *)SvPVbyte(content_sv, in_len); |
|
101
|
|
|
|
|
|
|
|
|
102
|
1
|
50
|
|
|
|
|
if (!SvROK(rects_sv) || SvTYPE(SvRV(rects_sv)) != SVt_PVAV) { |
|
|
|
50
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
croak("PDF::Make::Redaction::rewrite_stream: rects must be an arrayref"); |
|
104
|
|
|
|
|
|
|
} |
|
105
|
1
|
|
|
|
|
|
rects_av = (AV *)SvRV(rects_sv); |
|
106
|
1
|
|
|
|
|
|
n_rects = av_len(rects_av) + 1; |
|
107
|
|
|
|
|
|
|
|
|
108
|
1
|
50
|
|
|
|
|
if (n_rects > 0) { |
|
109
|
1
|
|
|
|
|
|
rects = (pdfmake_redact_t *)calloc((size_t)n_rects, sizeof(*rects)); |
|
110
|
1
|
50
|
|
|
|
|
if (!rects) croak("PDF::Make::Redaction::rewrite_stream: out of memory"); |
|
111
|
3
|
100
|
|
|
|
|
for (SSize_t i = 0; i < n_rects; i++) { |
|
112
|
2
|
|
|
|
|
|
SV **e = av_fetch(rects_av, i, 0); |
|
113
|
2
|
50
|
|
|
|
|
if (!e || !SvROK(*e) || SvTYPE(SvRV(*e)) != SVt_PVAV) { |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
free(rects); |
|
115
|
0
|
|
|
|
|
|
croak("PDF::Make::Redaction::rewrite_stream: rect %ld not an arrayref", (long)i); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
2
|
|
|
|
|
|
AV *rav = (AV *)SvRV(*e); |
|
118
|
|
|
|
|
|
|
SV **v; |
|
119
|
2
|
50
|
|
|
|
|
if ((v = av_fetch(rav, 0, 0))) rects[i].rect[0] = SvNV(*v); |
|
120
|
2
|
50
|
|
|
|
|
if ((v = av_fetch(rav, 1, 0))) rects[i].rect[1] = SvNV(*v); |
|
121
|
2
|
50
|
|
|
|
|
if ((v = av_fetch(rav, 2, 0))) rects[i].rect[2] = SvNV(*v); |
|
122
|
2
|
50
|
|
|
|
|
if ((v = av_fetch(rav, 3, 0))) rects[i].rect[3] = SvNV(*v); |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
1
|
50
|
|
|
|
|
if (pdfmake_buf_init(&out) != PDFMAKE_OK) { |
|
127
|
0
|
|
|
|
|
|
free(rects); |
|
128
|
0
|
|
|
|
|
|
croak("PDF::Make::Redaction::rewrite_stream: buf init failed"); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
1
|
|
|
|
|
|
err = pdfmake_redact_rewrite_stream( |
|
132
|
|
|
|
|
|
|
in_bytes, (size_t)in_len, rects, (size_t)n_rects, &out); |
|
133
|
1
|
|
|
|
|
|
free(rects); |
|
134
|
1
|
50
|
|
|
|
|
if (err != PDFMAKE_OK) { |
|
135
|
0
|
|
|
|
|
|
pdfmake_buf_free(&out); |
|
136
|
0
|
|
|
|
|
|
croak("PDF::Make::Redaction::rewrite_stream: rewrite failed"); |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
1
|
|
|
|
|
|
RETVAL = newSVpvn((const char *)out.data, out.len); |
|
140
|
1
|
|
|
|
|
|
pdfmake_buf_free(&out); |
|
141
|
|
|
|
|
|
|
OUTPUT: |
|
142
|
|
|
|
|
|
|
RETVAL |