Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for acroforms #2373

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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'];
var names = ['basics', 'styles1', 'styles2', 'styles3', 'columns', 'tables', 'lists', 'margin', 'images', 'svgs', 'acroforms'];

var i = 0;
['basics', 'named-styles', 'inline-styling', 'style-overrides', 'columns', 'tables', 'lists', 'margins', 'images', 'svgs'].forEach(function (example) {
['basics', 'named-styles', 'inline-styling', 'style-overrides', 'columns', 'tables', 'lists', 'margins', 'images', 'svgs', 'acroforms'].forEach(function (example) {
$scope.examples.push({
name: names[i++],
activate: function () {
Expand Down
338 changes: 338 additions & 0 deletions dev-playground/public/samples/acroforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,338 @@
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: '\nRadio form', style: 'formHeader'},
{
acroform: {
type: 'radio',
id: 'radioChild1',
options: {
parentId: 'radioForm1',
selected: true,
},
},
width: 50,
height: 30,

},
{
acroform: {
type: 'radio',
id: 'radioChild2',
options: {
parentId: 'radioForm1',
},
},
width: 40,
height: 25,

},
{
acroform: {
type: 'radio',
id: 'radioChild3',
options: {
parentId: 'radioForm1',
},
},
width: 30,
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
}
},
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: {
margin: [0, 0, 5, 5]
}
}
1 change: 1 addition & 0 deletions dev-playground/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"build:fonts": "shx mkdir -p build/fonts && shx mkdir -p build/fonts/Roboto && shx cp -r fonts/Roboto/*.* build/fonts/Roboto && brfs \"./src/browser-extensions/fonts/Roboto.js\" > build/fonts/Roboto.js",
"lint": "eslint \"./src/**/*.js\" \"./tests/**/*.js\" \"./examples/**/*.js\" \"./standard-fonts/**/*.js\" \"./fonts/**/*.js\"",
"mocha": "mocha --reporter spec \"./tests/**/*.spec.js\"",
"playground": "node dev-playground/server.js"
"playground": "node dev-playground/server.js",
"playground:watch": "nodemon dev-playground/server.js"
},
"repository": {
"type": "git",
Expand Down
Loading