tenta fix pdfservice.js
This commit is contained in:
1 parent
7f3313f3f3
commit
942222df6a
1 file changed
+8
-5
@@ -639,11 +639,14 @@ export class PdfService {
|
||||
timbradoPageCount = timbradoPdf.getPageCount();
|
||||
console.log(`Timbrado carregado com ${timbradoPageCount} páginas`);
|
||||
|
||||
timbradoPages = [];
|
||||
for (let i = 0; i < timbradoPageCount; i++) {
|
||||
console.log(`Incorporando página ${i+1} do timbrado`);
|
||||
const [embedded] = await pdfDoc.embedPages([timbradoPdf.getPage(i)]);
|
||||
timbradoPages.push(embedded);
|
||||
// CORREÇÃO: Limitar números de páginas do timbrado para evitar loops infinitos
|
||||
if (timbradoPageCount > 0) {
|
||||
timbradoPages = [];
|
||||
for (let i = 0; i < Math.min(timbradoPageCount, 10); i++) { // Limitar a 10 páginas max
|
||||
console.log(`Incorporando página ${i+1} do timbrado`);
|
||||
const [embedded] = await pdfDoc.embedPages([timbradoPdf.getPage(i)]);
|
||||
timbradoPages.push(embedded);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erro ao carregar timbrado:', error);
|
||||
|
||||
Reference in new issue
Block a user