-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
32 lines (28 loc) · 994 Bytes
/
index.js
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
// Generated by CoffeeScript 1.7.1
(function() {
var fs, md5;
md5 = require("MD5");
fs = require("fs");
module.exports.generate = function(form, file) {
var data, field, header, opt, val, _i, _len;
header = (String.fromCharCode(226)) + (String.fromCharCode(227)) + (String.fromCharCode(207)) + (String.fromCharCode(211));
data = "%FDF-1.2\n%" + header + "\n1 0 obj \n<<\n/FDF \n<<\n/Fields [";
for (field in form) {
val = form[field];
if (form.hasOwnProperty(field)) {
if (typeof val === "object" && Array.isArray(val)) {
data += "<<\n/V(" + val + ")\n/T[";
for (_i = 0, _len = val.length; _i < _len; _i++) {
opt = val[_i];
data += "(" + opt + ")";
}
data += "]>>";
} else {
data += "<<\n/V(" + val + ")\n/T(" + field + ")\n>>";
}
}
}
data += "] \n>>\n>>\nendobj \ntrailer\n\n<<\n/Root 1 0 R\n>>\n%%EOF";
return data;
};
}).call(this);