mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
Bug fixes for setting Ff flag and alignment.
This commit is contained in:
parent
bf75b0881a
commit
6478048630
@ -19,14 +19,14 @@ doc.initAcroForm();
|
||||
let rootField = doc.field('rootField');
|
||||
let child1Field = doc.field('child1Field', { Parent: rootField });
|
||||
let child2Field = doc.field('child2Field', { Parent: rootField });
|
||||
doc.formText('leaf1', 10, 10, 200, 40, { Parent: child1Field })
|
||||
doc.formText('leaf2', 10, 60, 200, 40, { Parent: child1Field })
|
||||
doc.formText('leaf3', 10, 110, 200, 40, { Parent: child2Field })
|
||||
doc.formText('leaf1', 10, 10, 200, 40, { Parent: child1Field, multiline: true })
|
||||
doc.formText('leaf2', 10, 60, 200, 40, { Parent: child1Field, multiline: true })
|
||||
doc.formText('leaf3', 10, 110, 200, 80, { Parent: child2Field, multiline: true })
|
||||
|
||||
var opts = {
|
||||
backgroundColor: 'yellow',
|
||||
label: 'Test Button',
|
||||
};
|
||||
doc.formPushButton('btn1', 10, 160, 100, 30, opts);
|
||||
doc.formPushButton('btn1', 10, 200, 100, 30, opts);
|
||||
|
||||
doc.end();
|
||||
|
||||
@ -13,7 +13,8 @@ const FIELD_FLAGS = {
|
||||
pushButton: 0x10000,
|
||||
combo: 0x20000,
|
||||
edit: 0x40000,
|
||||
sort: 0x80000
|
||||
sort: 0x80000,
|
||||
noSpell: 0x400000,
|
||||
};
|
||||
const FIELD_JUSTIFY = {
|
||||
left: 0,
|
||||
@ -191,21 +192,31 @@ export default {
|
||||
},
|
||||
|
||||
_resolveFlags (options) {
|
||||
options.Ff = options.Ff ? options.Ff : 0;
|
||||
let result = 0;
|
||||
Object.keys(options).forEach(key => {
|
||||
if (FIELD_FLAGS[key]) {
|
||||
options.Ff |= FIELD_FLAGS[key]
|
||||
result |= FIELD_FLAGS[key]
|
||||
delete options[key]
|
||||
}
|
||||
});
|
||||
if (result !== 0) {
|
||||
options.Ff = options.Ff ? options.Ff : 0;
|
||||
options.Ff |= result;
|
||||
}
|
||||
return options;
|
||||
},
|
||||
|
||||
_resolveJustify (options) {
|
||||
if (options.align && FIELD_JUSTIFY[options.align]) {
|
||||
options.Q = FIELD_JUSTIFY[options.align];
|
||||
let result = 0;
|
||||
if (options.align !== undefined) {
|
||||
if (typeof FIELD_JUSTIFY[options.align] === 'number') {
|
||||
result = FIELD_JUSTIFY[options.align];
|
||||
}
|
||||
delete options.align;
|
||||
}
|
||||
if (result !== 0) {
|
||||
options.Q = result; // default
|
||||
}
|
||||
return options;
|
||||
},
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user