Changes
Co-authored-by: Reifonas <211114984+Reifonas@users.noreply.github.com>
This commit is contained in:
@@ -227,10 +227,14 @@ export async function generateInspectionReport(data: ReportData) {
|
||||
|
||||
for (let i = 0; i < data.screenshots.length; i++) {
|
||||
checkSpace(100);
|
||||
const src = data.screenshots[i];
|
||||
try {
|
||||
if (typeof src !== 'string' || !src.startsWith('data:image/')) {
|
||||
throw new Error('formato de imagem inválido (esperado data URL)');
|
||||
}
|
||||
const imgW = contentW;
|
||||
const imgH = imgW * 0.56; // ~16:9
|
||||
pdf.addImage(data.screenshots[i], 'PNG', margin, y, imgW, imgH);
|
||||
pdf.addImage(src, 'PNG', margin, y, imgW, imgH);
|
||||
y += imgH + 3;
|
||||
|
||||
pdf.setFontSize(7);
|
||||
@@ -238,10 +242,12 @@ export async function generateInspectionReport(data: ReportData) {
|
||||
pdf.setTextColor(148, 163, 184);
|
||||
pdf.text(`Captura ${i + 1} de ${data.screenshots.length}`, margin, y);
|
||||
y += 8;
|
||||
} catch {
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err);
|
||||
console.warn(`[generateReport] screenshot ${i + 1} falhou:`, msg);
|
||||
pdf.setFontSize(8);
|
||||
pdf.setTextColor(200, 50, 50);
|
||||
pdf.text(`[Erro ao inserir screenshot ${i + 1}]`, margin, y);
|
||||
pdf.text(`[Erro ao inserir screenshot ${i + 1}: ${msg}]`, margin, y);
|
||||
y += 8;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user