Skip to main content

Export & Print Results

After generating an inspection report, you can export the data to JSON format for digital archiving or print a formatted report for physical records.

Overview

The system provides three main actions for handling inspection results:
  • Print: Generate a print-friendly version of the report
  • Export JSON: Download inspection data in JSON format
  • New Form: Reset and start a new inspection
These actions are available through buttons that appear after calculating results.

Printing Reports

The imprimirResultados() function (script.js:551-573) creates a print-optimized version of the inspection report.
1

Click Print Button

After viewing your results, click the “🖨️ Imprimir” button in the action buttons section.Button attributes:
  • Label: “🖨️ Imprimir”
  • Function: imprimirResultados()
  • Styling: .btn-secondary class
2

Print Preview Generation

The system automatically:
  1. Saves the current page content
  2. Creates a print-friendly layout
  3. Removes interactive elements
  4. Adds print header and footer
  5. Opens browser print dialog
3

Print or Save as PDF

Use your browser’s print dialog to:
  • Send to a physical printer
  • Save as PDF
  • Adjust print settings (orientation, margins, etc.)
4

Automatic Restoration

After printing:
  • Original page content is restored
  • Interactive buttons return
  • Event listeners are reinitialized
The printed report includes:
<div style="padding: 20px; font-family: Arial, sans-serif;">
    <h1 style="text-align: center; color: #2563eb;">
        Concesionario de Coches - Resultados ITV
    </h1>
    <hr style="margin: 20px 0;">
    
    <!-- Client Information -->
    [informacionCliente]
    
    <!-- Inspection Results -->
    [resultados]
    
    <!-- Print Timestamp -->
    <div style="margin-top: 30px; text-align: center; font-size: 12px; color: #666;">
        Impreso el [DD/MM/YYYY] a las [HH:MM:SS]
    </div>
</div>
Each printed report includes an automatic timestamp:
Impreso el ${new Date().toLocaleDateString('es-ES')} a las ${new Date().toLocaleTimeString('es-ES')}
Example: “Impreso el 07/03/2026 a las 14:30:45”
The timestamp uses Spanish locale formatting (DD/MM/YYYY and 24-hour time).

Exporting to JSON

Export Function Overview

The exportarResultados() function (script.js:529-548) creates a downloadable JSON file with complete inspection data.
1

Click Export Button

Click the ”📥 Exportar JSON” button in the action buttons section.Function: exportarResultados()
2

Data Collection

The system gathers all inspection data:
const datosExportacion = {
    cliente: obtenerDatosCliente(),
    vehiculos: vehiculosData,
    fecha: new Date().toLocaleDateString('es-ES'),
    hora: new Date().toLocaleTimeString('es-ES')
};
3

JSON Generation

Data is formatted as pretty-printed JSON:
const jsonStr = JSON.stringify(datosExportacion, null, 2);
The null, 2 parameters create readable, indented JSON.
4

File Download

A blob is created and automatically downloaded:Filename format: ITV_[Apellidos]_[Timestamp].jsonExample: ITV_Garcia_1709823045789.json

JSON Structure

The exported JSON file follows this structure:
{
  "cliente": {
    "nombre": "Juan",
    "apellidos": "García",
    "razonSocial": "Particular",
    "nAutos": 3
  },
  "vehiculos": [
    {
      "numero": 1,
      "motorizacion": "Diesel",
      "estadoITV": "Aprobo",
      "observaciones": "Neumáticos en buen estado"
    },
    {
      "numero": 2,
      "motorizacion": "Gasolina",
      "estadoITV": "NoAprobo",
      "observaciones": "Emisiones fuera de norma"
    },
    {
      "numero": 3,
      "motorizacion": "Electrico",
      "estadoITV": "Aprobo",
      "observaciones": ""
    }
  ],
  "fecha": "07/03/2026",
  "hora": "14:30:45"
}

JSON Data Fields

FieldTypeDescription
nombrestringClient’s first name
apellidosstringClient’s surname(s)
razonSocialstringBusiness name or “Particular”
nAutosnumberTotal number of vehicles inspected
Array of vehicle objects, each containing:
FieldTypeValuesDescription
numeronumber1-50Vehicle sequence number
motorizacionstringDiesel, Gasolina, Hibrido, ElectricoEngine type
estadoITVstringAprobo, NoAproboInspection pass/fail status
observacionesstring0-250 charsVehicle condition notes
FieldTypeFormatDescription
fechastringDD/MM/YYYYExport date
horastringHH:MM:SSExport time (24-hour)

File Download Implementation

The export function uses Blob and URL APIs:
// Create Blob from JSON string
const blob = new Blob([jsonStr], { type: 'application/json' });

// Create temporary URL
const url = URL.createObjectURL(blob);

// Create and trigger download
const a = document.createElement('a');
a.href = url;
a.download = `ITV_${datosExportacion.cliente.apellidos}_${Date.now()}.json`;
document.body.appendChild(a);
a.click();

// Cleanup
document.body.removeChild(a);
URL.revokeObjectURL(url);
The URL is automatically revoked after download to free up memory.

Reset and New Form

Restart Function

The reiniciarFormulario() function (script.js:522-526) allows starting a new inspection.
1

Click New Form Button

Click the ”🔄 Nuevo Formulario” button in the action buttons section.
2

Confirmation Dialog

A browser confirmation dialog appears:
¿Está seguro que desea reiniciar el formulario?
Se perderán todos los datos ingresados.
Options:
  • OK: Proceed with reset
  • Cancel: Return to current report
3

Page Reload

If confirmed, the page reloads completely:
if (confirm("¿Está seguro...")) {
    location.reload();
}
This returns you to the initial client registration form.
Reloading the page will permanently delete all current inspection data unless you’ve already exported or printed the results. Make sure to save important data before resetting.

Action Buttons Styling

The action buttons section is added after report generation:
<div id="botones-accion" class="info-card full-width">
    <div style="padding: 1.5rem; text-align: center;">
        <h3>Acciones Disponibles</h3>
        <div style="display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem;">
            <button onclick="imprimirResultados()" class="btn-secondary">
                🖨️ Imprimir
            </button>
            <button onclick="exportarResultados()" class="btn-secondary">
                📥 Exportar JSON
            </button>
            <button onclick="reiniciarFormulario()" class="btn-secondary">
                🔄 Nuevo Formulario
            </button>
        </div>
    </div>
</div>

Button Styling

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: #2563eb;
    border: 2px solid #2563eb;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

Use Cases

Physical Records

Use Print Feature
  • Legal documentation
  • Customer receipts
  • Archive hard copies
  • Regulatory compliance

Digital Archive

Use Export Feature
  • Database integration
  • Long-term storage
  • Data analysis
  • Backup records

Quick Reference

View on Screen
  • Immediate results
  • Quick verification
  • No storage needed
  • Real-time decisions

Next Client

Use Reset Feature
  • Start fresh inspection
  • New client entry
  • Clean slate
  • Fast turnaround

Best Practices

1

Review Before Export/Print

Always review the generated report for accuracy before exporting or printing. Check:
  • Client information
  • Vehicle counts
  • ITV statuses
  • Observations
  • Total calculations
2

Save Digital Copies

Export JSON files for all inspections to maintain digital records:
  • Create a consistent naming convention
  • Store in organized folders by date
  • Keep backups of exported files
  • Consider database integration
3

Print for Customers

Provide printed reports to customers for:
  • Immediate proof of inspection
  • Personal records
  • Insurance documentation
  • Professional service

Technical Reference

Key functions for export and print:
FunctionPurposeLocation
exportarResultados()JSON exportscript.js:529-548
imprimirResultados()Print reportscript.js:551-573
reiniciarFormulario()Reset formscript.js:522-526
agregarBotonesAccion()Add action buttonsscript.js:578-605

Browser Compatibility

These features work in all modern browsers:
  • Print: Uses native window.print() API
  • Export: Uses Blob and URL APIs (supported in all modern browsers)
  • Download: Uses programmatic <a> element click
For best print results, use Chrome, Firefox, or Edge. Safari may require additional print settings adjustments.

Troubleshooting

Possible causes:
  • Browser download restrictions
  • Insufficient permissions
Solution: Check browser download settings and file permissions.

Build docs developers (and LLMs) love