tenta fix pdfservice.js
This commit is contained in:
1 parent
db0c011b8b
commit
3529bffbbb
1 file changed
+28
-26
@@ -378,51 +378,53 @@ export class PdfService {
|
|||||||
let currentLineWidth = 0;
|
let currentLineWidth = 0;
|
||||||
let textParts = [];
|
let textParts = [];
|
||||||
|
|
||||||
// Detectar formatação inline
|
// Processa texto com formatação - remover tags HTML e aplicar estilos
|
||||||
let remainingText = text;
|
let processedText = '';
|
||||||
let currentFont = normalFont;
|
let currentFont = normalFont;
|
||||||
let boldActive = false;
|
let boldActive = false;
|
||||||
let italicActive = false;
|
let italicActive = false;
|
||||||
|
|
||||||
// Processa texto com formatação
|
// Primeiro, extrair partes do texto com suas formatações
|
||||||
while (remainingText.length > 0) {
|
let i = 0;
|
||||||
if (remainingText.startsWith('<b>')) {
|
while (i < text.length) {
|
||||||
// Começa negrito
|
if (text.substring(i, i+3) === '<b>') {
|
||||||
boldActive = true;
|
boldActive = true;
|
||||||
remainingText = remainingText.substring(3);
|
|
||||||
currentFont = italicActive ? boldItalicFont : boldFont;
|
currentFont = italicActive ? boldItalicFont : boldFont;
|
||||||
} else if (remainingText.startsWith('</b>')) {
|
i += 3;
|
||||||
// Termina negrito
|
}
|
||||||
|
else if (text.substring(i, i+4) === '</b>') {
|
||||||
boldActive = false;
|
boldActive = false;
|
||||||
remainingText = remainingText.substring(4);
|
|
||||||
currentFont = italicActive ? italicFont : normalFont;
|
currentFont = italicActive ? italicFont : normalFont;
|
||||||
} else if (remainingText.startsWith('<i>')) {
|
i += 4;
|
||||||
// Começa itálico
|
}
|
||||||
|
else if (text.substring(i, i+3) === '<i>') {
|
||||||
italicActive = true;
|
italicActive = true;
|
||||||
remainingText = remainingText.substring(3);
|
|
||||||
currentFont = boldActive ? boldItalicFont : italicFont;
|
currentFont = boldActive ? boldItalicFont : italicFont;
|
||||||
} else if (remainingText.startsWith('</i>')) {
|
i += 3;
|
||||||
// Termina itálico
|
}
|
||||||
|
else if (text.substring(i, i+4) === '</i>') {
|
||||||
italicActive = false;
|
italicActive = false;
|
||||||
remainingText = remainingText.substring(4);
|
|
||||||
currentFont = boldActive ? boldFont : normalFont;
|
currentFont = boldActive ? boldFont : normalFont;
|
||||||
} else {
|
i += 4;
|
||||||
// Texto normal - procura pela próxima tag de formatação
|
}
|
||||||
let nextTag = remainingText.search(/<\/?[bi]>/);
|
else {
|
||||||
if (nextTag === -1) {
|
// Encontrar o próximo início de tag
|
||||||
// Não há mais tags, adiciona todo o texto restante
|
let nextTagPos = text.indexOf('<', i);
|
||||||
|
|
||||||
|
if (nextTagPos === -1) {
|
||||||
|
// Não há mais tags, pegar o restante do texto
|
||||||
textParts.push({
|
textParts.push({
|
||||||
text: remainingText,
|
text: text.substring(i),
|
||||||
font: currentFont
|
font: currentFont
|
||||||
});
|
});
|
||||||
remainingText = '';
|
break;
|
||||||
} else {
|
} else {
|
||||||
// Adiciona texto até a próxima tag
|
// Pegar texto até a próxima tag
|
||||||
textParts.push({
|
textParts.push({
|
||||||
text: remainingText.substring(0, nextTag),
|
text: text.substring(i, nextTagPos),
|
||||||
font: currentFont
|
font: currentFont
|
||||||
});
|
});
|
||||||
remainingText = remainingText.substring(nextTag);
|
i = nextTagPos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user