Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ doc
nbproject
package-lock.json
yarn.lock
*pnpm-lock.yaml
.vscode
.idea
/js
4 changes: 2 additions & 2 deletions dev-playground/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ <h1>Playground does not make too much sense when horizontal resolution is below

var editor = ace.edit('editor');
setupEditor(editor);
var names = ['basics', 'styles1', 'styles2', 'styles3', 'columns', 'tables', 'lists', 'margin', 'images', 'svgs', 'attachments'];
var names = ['basics', 'styles1', 'styles2', 'styles3', 'columns', 'tables', 'lists', 'margin', 'images', 'svgs', 'attachments', 'acroforms'];

var i = 0;
['basics', 'named-styles', 'inline-styling', 'style-overrides', 'columns', 'tables', 'lists', 'margins', 'images', 'svgs', 'attachments'].forEach(function (example) {
['basics', 'named-styles', 'inline-styling', 'style-overrides', 'columns', 'tables', 'lists', 'margins', 'images', 'svgs', 'attachments', 'acroforms'].forEach(function (example) {
$scope.examples.push({
name: names[i++],
activate: function () {
Expand Down
347 changes: 347 additions & 0 deletions dev-playground/public/samples/acroforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,347 @@
{
"subsetFonts": false,
"content": [
{
"text": "Acroforms",
"style": "header"
},
{
"text": [
"It is recommended that you test your PDF form ",
"documents across all platforms and viewers that you wish to ",
"support. Refer to ",
"https://pdfkit.org/docs/forms or the PDF ",
"reference for form options and advanced form field use.\n\n"
],
"style": "description"
},
{
"text": "Components\n",
"style": "subHeader"
},
{
"text": [
"Make sure you set the subsetFonts flag to false when using ",
"form fields with text.\n\n"
],
"style": {
"bold": true
}
},
{
"text": "Text field",
"style": "formHeader"
},
{
"columns": [
[
{
"acroform": {
"type": "text",
"id": "text_placeholder",
"options": {
"value": "Placeholder ..."
}
},
"style": "textFieldStyle",
"height": 15,
"italics": true
},
{
"acroform": {
"type": "text",
"id": "text_date",
"options": {
"format": {
"type": "date"
},
"align": "center",
"value": "10/12"
}
},
"style": "textFieldStyle",
"height": 15
},
{
"acroform": {
"type": "text",
"id": "text_multi",
"options": {
"multiline": true,
"value": "multiline text form "
}
},
"style": "textFieldStyle",
"height": 50
}
],
[
{
"acroform": {
"type": "text",
"id": "text_alignment",
"options": {
"align": "right",
"value": "right alignment"
}
},
"style": "textFieldStyle",
"height": 15
},
{
"acroform": {
"type": "text",
"id": "text_color",
"options": {
"align": "center",
"required": true,
"value": "Ω©®℅¥123"
}
},
"style": "textFieldStyle",
"height": 15
}
],
[
{
"acroform": {
"type": "text",
"id": "text_currency",
"options": {
"align": "right",
"format": {
"type": "number",
"nDec": 2,
"sepComma": true,
"negStyle": "ParensRed",
"currency": "$",
"currencyPrepend": true
},
"value": "$123,346.99"
}
},
"style": "textFieldStyle",
"height": 15
},
{
"acroform": {
"type": "text",
"id": "text_backgroundcolor",
"options": {
"backgroundColor": "yellow",
"borderColor": "green",
"align": "center",
"value": "background color"
}
},
"style": "textFieldStyle",
"height": 15
}
]
]
},
{
"columns": [
[
{
"text": "\nList",
"style": "formHeader"
},
{
"acroform": {
"type": "list",
"id": "list1",
"options": {
"select": [
"",
"A",
"B",
"C"
]
}
},
"width": 100,
"height": 60
}
],
[
{
"text": "\nCombobox",
"style": "formHeader"
},
{
"acroform": {
"type": "combo",
"id": "combo1",
"options": {
"select": [
"",
"A",
"B",
"C"
],
"defaultValue": ""
}
},
"width": 100,
"height": 20
}
],
[
{
"text": "\nCheckbox form",
"style": "formHeader"
},
{
"acroform": {
"type": "checkbox",
"id": "checkbox1",
"options": {
"selected": false
}
},
"width": 20,
"height": 20
}
]
]
},
{
"text": "\nYou can also use forms inline with text\n\n",
"style": "subHeader"
},
{
"text": [
"Check this box! ",
{
"acroform": {
"type": "checkbox",
"id": "checkbox2",
"options": {
"selected": false
}
},
"width": 15,
"height": 15
},
"\n\n"
],
"alignment": "center"
},
{
"text": [
"The weather was very ",
{
"acroform": {
"type": "combo",
"id": "combo_story1",
"options": {
"select": [
"",
"nice",
"bad"
],
"defaultValue": ""
}
},
"width": 50,
"height": 9.5
},
" and the skies were ",
{
"acroform": {
"type": "combo",
"id": "combo_story2",
"options": {
"select": [
"",
"clear",
"cloudy"
],
"defaultValue": ""
}
},
"width": 50,
"height": 9.5
},
". A fox named ",
{
"acroform": {
"type": "text",
"id": "text_story1"
},
"width": 50,
"height": 9.5
},
" and friends were playing a game at the park, when suddenly",
"... ",
{
"text": "finish the story",
"style": {
"italics": true,
"bold": true
}
}
]
},
{
"acroform": {
"type": "text",
"id": "text_story2",
"options": {
"multiline": true
}
},
"style": "textFieldStyle",
"width": "*",
"height": 100
}
],
"styles": {
"header": {
"fontSize": 18,
"bold": true,
"margin": [
0,
0,
0,
10
],
"lineHeight": 0.3
},
"description": {
"fontSize": 13,
"margin": [
0,
10,
0,
5
]
},
"subHeader": {
"bold": true,
"fontSize": 13
},
"formHeader": {
"fontSize": 12,
"color": "black"
},
"tableCell": {
"margin": [
0,
5,
0,
5
]
},
"textFieldStyle": {
"font": "Helvetica",
"margin": [
0,
0,
5,
5
]
}
}
}
9 changes: 8 additions & 1 deletion dev-playground/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ function createPdfBinary(docDefinition) {
bold: path.join(__dirname, '..', 'examples', '/fonts/Roboto-Medium.ttf'),
italics: path.join(__dirname, '..', 'examples', '/fonts/Roboto-Italic.ttf'),
bolditalics: path.join(__dirname, '..', 'examples', '/fonts/Roboto-MediumItalic.ttf')
}
},
Helvetica: {
normal: 'Helvetica',
bold: 'Helvetica-Bold',
italics: 'Helvetica-Oblique',
bolditalics: 'Helvetica-BoldOblique'
},
};

pdfmake.setFonts(fonts);
Expand All @@ -35,6 +41,7 @@ app.post('/pdf', function (req, res) {
res.contentType('application/pdf');
res.send(binary);
}, function (error) {
console.log(error); //print in console
res.send('ERROR:' + error);
});

Expand Down
Loading