Overview
Mantis includes a comprehensive reporting system that generates professional PDF documents for clients, regulatory compliance, and internal operations. The system uses Playwright for HTML-to-PDF conversion and supports document merging for complete billing packages.PDF Generation Technology
Playwright-Based Rendering
The system uses Playwright (Chromium) to convert HTML templates to PDFs:Playwright provides superior rendering compared to WeasyPrint, with full CSS support, JavaScript execution, and modern browser features.
Report Categories
Project Reports
Work Sheet
Template:
WorkSheetTemplateViewPDF: PDFWorkSheetURL: /reports/worksheet/{id}/Itemized billing document with rental charges, maintenance services, and waste disposalFinal Disposition Certificate
Template:
FinalDispositionCertificateViewPDF: PDFFinalDispositionCertificateViewURL: /reports/final-disposition/{id}/Environmental compliance certificate for waste disposalCustody Chain
Template:
CustodyChainReportViewPDF: PDFCustodyChainURL: /reports/custody-chain/{id}/Waste collection documentation with signaturesShipping Guide
Template:
ShippingGuideReportViewPDF: PDFShippingGuideViewURL: /reports/shipping-guide/{id}/Transportation and logistics documentationMaintenance Reports
Maintenance Sheet
Template:
SheetMaintenanceReportViewPDF: PDFSheetMaintenanceURL: /reports/sheet-maintenance/{id}/Technical documentation of maintenance work performed, parts replaced, and recommendationsEquipment Reports
Equipment Checklists
Equipment Checklists
Generate inspection checklists for different equipment types:
| Equipment Type | Template | PDF URL |
|---|---|---|
| Bathrooms (Baterías) | EquipmentBateriesCheckList | /reports/equipment-bateries/{id}/ |
| Handwashing Stations | EquipmentWasherHandsCheck | /reports/equipment-washer-hands/{id}/ |
| Urinal Stations | EquipmentUrinalStationCheck | /reports/equipment-urinal-station/{id}/ |
| Bathroom Campers | EquipmentBathroomCamperChecker | /reports/equipment-bathroom-camper/{id}/ |
| Raw Water Tanks | EquipmentRawWaterStorageTanks | /reports/equipment-raw-water-tanks/{id}/ |
| Wastewater Tanks | EquipmentWastewaterStorageTanks | /reports/equipment-wastewater-tanks/{id}/ |
Equipment Information
Equipment Information
Template:
EquipmentInfoReportPDF: PDFEquipmentInfoReportURL: /reports/equipment-info/{id}/Complete technical specifications, dimensions, components, and status informationPersonnel Reports
Technical Information
URL:
/reports/technical/{id}/Personnel record with licenses and certificationsVaccination Record
URL:
/reports/technical-vaccine/{id}/COVID-19 and required vaccinations for field workVehicle Reports
Vehicle Status
Template:
VehicleStatusReportPDF: PDFVehicleStatusReportURL: /reports/vehicle-status/{pk}/Complete vehicle documentation including certifications, insurance, and technical review statusStatus Reports
Equipment by Status
URL:
/reports/equipment-status/All equipment grouped by availabilityVehicles by Status
URL:
/reports/vehicles-status/All vehicles with certification statusTechnicals by Status
URL:
/reports/technicals-status/Personnel availability and qualificationsBilling Reports
Liquidated Sheets
Liquidated Sheets
URL:
/reports/liquidated-sheets/All work orders ready for invoicing (status=‘LIQUIDATED’)Custody Chains Report
Custody Chains Report
URL:
/reports/custody-chains/All custody chains with filter optionsCustody Chains Filtered
Custody Chains Filtered
URL:
/reports/custody-chains-filtered/Custody chains filtered by date range and projectShipping Guides Report
Shipping Guides Report
URL:
/reports/shipping-guides/All shipping guides for logistics trackingMaintenance Sheets Report
Maintenance Sheets Report
URL:
/reports/maintenance-sheets/All maintenance operations with cost summaryDocument Merging
SheetMergeGenerated API
The system can merge multiple PDFs into a single billing package:Merge Implementation
Code Examples
Generating a Single PDF
Custom Page Orientation
Adding Watermarks or Headers
Report Template Guidelines
HTML Template Structure
CSS for Print
Performance Optimization
Concurrent Generation
Concurrent Generation
Use ThreadPoolExecutor for generating multiple PDFs:
Caching Templates
Caching Templates
Cache rendered HTML before PDF conversion:
Browser Reuse
Browser Reuse
Reuse browser context for multiple pages:
Best Practices
Template Design
Template Design
- Use semantic HTML for better PDF structure
- Keep file sizes small (compress images)
- Use web-safe fonts (Arial, Times New Roman)
- Test print CSS with browser print preview
- Avoid complex CSS animations or transitions
Authentication
Authentication
- Pass request cookies to Playwright context
- Use session authentication for template access
- Validate permissions before PDF generation
- Log all PDF generation requests for audit
Error Handling
Error Handling
- Wrap PDF generation in try-except blocks
- Return meaningful error messages
- Log Playwright errors with context
- Provide fallback for failed renders
File Management
File Management
- Generate PDFs to memory (BytesIO) when possible
- Clean up temporary files after merge
- Use descriptive filenames with dates
- Store generated PDFs in database FileFields
Related Features
Work Orders
Generate work sheet PDFs for client billing
Custody Chains
Create custody chain compliance PDFs
Maintenance
Generate maintenance sheet documentation
Equipment
Create equipment checklists and specs