mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-18 11:14:02 +02:00
Merge pull request #21069 from calixteman/issue21068
Take into account the alignment when printing/saving a comb field
This commit is contained in:
commit
7cfcafbb4b
@ -2546,6 +2546,7 @@ class WidgetAnnotation extends Annotation {
|
||||
defaultVPadding,
|
||||
descent,
|
||||
lineHeight,
|
||||
alignment,
|
||||
annotationStorage
|
||||
);
|
||||
}
|
||||
@ -2909,6 +2910,7 @@ class TextWidgetAnnotation extends WidgetAnnotation {
|
||||
vPadding,
|
||||
descent,
|
||||
lineHeight,
|
||||
alignment,
|
||||
annotationStorage
|
||||
) {
|
||||
const combWidth = width / this.data.maxLen;
|
||||
@ -2921,11 +2923,19 @@ class TextWidgetAnnotation extends WidgetAnnotation {
|
||||
buf.push(`(${escapeString(text.substring(start, end))}) Tj`);
|
||||
}
|
||||
|
||||
const textWidth = combWidth * positions.length;
|
||||
let hShift = hPadding;
|
||||
if (alignment === 1) {
|
||||
hShift += Math.floor((width - textWidth) / (2 * combWidth)) * combWidth;
|
||||
} else if (alignment === 2) {
|
||||
hShift += width - textWidth;
|
||||
}
|
||||
|
||||
const renderedComb = buf.join(` ${numberToString(combWidth)} 0 Td `);
|
||||
return (
|
||||
`/Tx BMC q ${colors}BT ` +
|
||||
defaultAppearance +
|
||||
` 1 0 0 1 ${numberToString(hPadding)} ${numberToString(
|
||||
` 1 0 0 1 ${numberToString(hShift)} ${numberToString(
|
||||
vPadding + descent
|
||||
)} Tm ${renderedComb}` +
|
||||
" ET Q EMC"
|
||||
|
||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -898,3 +898,4 @@
|
||||
!function_based_shading.pdf
|
||||
!issue16091.pdf
|
||||
!issue7821.pdf
|
||||
!issue21068.pdf
|
||||
|
||||
BIN
test/pdfs/issue21068.pdf
Normal file
BIN
test/pdfs/issue21068.pdf
Normal file
Binary file not shown.
@ -14075,5 +14075,27 @@
|
||||
"md5": "7f0f390a70228fffe95835518ec266c5",
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{
|
||||
"id": "issue21068",
|
||||
"file": "pdfs/issue21068.pdf",
|
||||
"md5": "69558d166186923ad9d639d91884dbd6",
|
||||
"rounds": 1,
|
||||
"type": "eq",
|
||||
"print": true,
|
||||
"annotationStorage": {
|
||||
"27R": {
|
||||
"value": "123"
|
||||
},
|
||||
"28R": {
|
||||
"value": "123"
|
||||
},
|
||||
"29R": {
|
||||
"value": "1234"
|
||||
},
|
||||
"30R": {
|
||||
"value": "123"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user