tenta fix pdfservice.js

This commit is contained in:
rodrigo committed 2025-04-22 16:18:53 -03:00
1 parent 494ad6ef9e
commit 46f538332e
1 file changed
+5 -1
+5 -1
View File
@@ -57,6 +57,10 @@ export class PdfService {
// Gera HTML com timbrado e margens // Gera HTML com timbrado e margens
private gerarHTML(content: string, config: any) { private gerarHTML(content: string, config: any) {
// Limpa espaços, quebras de linha e tags vazias do final do conteúdo
let cleanContent = content
.replace(/(\s|<br\s*\/?>|<p>\s*<\/p>)+$/gi, '')
.replace(/(<p>\s*<\/p>)+/gi, '');
const timbradoUrl = config.timbradoUrl const timbradoUrl = config.timbradoUrl
? `${process.env.FRONTEND_URL || 'http://localhost:5000'}${config.timbradoUrl}` ? `${process.env.FRONTEND_URL || 'http://localhost:5000'}${config.timbradoUrl}`
: ''; : '';
@@ -133,7 +137,7 @@ export class PdfService {
<body> <body>
${timbradoUrl ? '<div class="timbrado-bg"></div>' : ''} ${timbradoUrl ? '<div class="timbrado-bg"></div>' : ''}
<div class="content"> <div class="content">
${content} ${cleanContent}
</div> </div>
</body> </body>
</html> </html>