tenta fix pdfservice.js
This commit is contained in:
1 parent
3406723bd4
commit
85977d7229
1 file changed
+2
-1
@@ -392,7 +392,6 @@ export class PdfService {
|
||||
}
|
||||
}
|
||||
|
||||
// Reformulação: sem recuo de parágrafo (nem blockquote, nem primeira linha)
|
||||
let lines: { tokens: { text: string, font: any, underline: boolean, bold: boolean, italic: boolean }[] }[] = [];
|
||||
let currentTokens: { text: string, font: any, underline: boolean, bold: boolean, italic: boolean }[] = [];
|
||||
let currentWidth = 0;
|
||||
@@ -423,6 +422,7 @@ export class PdfService {
|
||||
}
|
||||
let line = lines[i];
|
||||
let drawX = x;
|
||||
|
||||
// Remove espaços no início e fim da linha para não justificar esses espaços
|
||||
let trimmedTokens = [...line.tokens];
|
||||
while (trimmedTokens.length && /^\s+$/.test(trimmedTokens[0].text)) trimmedTokens.shift();
|
||||
@@ -430,6 +430,7 @@ export class PdfService {
|
||||
|
||||
let totalWidth = trimmedTokens.reduce((acc, t) => acc + t.font.widthOfTextAtSize(t.text, fontSize), 0);
|
||||
|
||||
// Corrige centralização: centraliza a linha inteira, inclusive se for a única linha do parágrafo
|
||||
if (align === 'center') {
|
||||
drawX = x + (maxWidth - totalWidth) / 2;
|
||||
for (const t of trimmedTokens) {
|
||||
|
||||
Reference in new issue
Block a user