AI Skill Report Card
Creating PDF Service Reports
Quick Start15 / 15
Pythonfrom reportlab.lib.pagesizes import letter from reportlab.pdfgen import canvas from reportlab.lib import colors c = canvas.Canvas("service_report.pdf", pagesize=letter) c.setTitle("HVAC Service Report") # Header with company branding c.setFillColor(colors.HexColor("#1B3A6B")) c.rect(50, 750, 500, 40, fill=1) c.setFillColor(colors.white) c.setFont("Helvetica-Bold", 14) c.drawCentredString(300, 765, "HVAC MAINTENANCE REPORT") # Form field c.acroForm.textfield(name="customer_name", x=100, y=700, width=200, height=20) c.setFont("Helvetica", 10) c.drawString(100, 715, "Customer Name:") c.save()
Recommendation▾
Add a complete end-to-end example showing how all sections integrate into one report
Workflow15 / 15
Step 1: Plan Report Structure
- Identify required sections (customer info, work performed, signatures)
- Calculate page layout (letter = 612×792 pts, margins typically 50pt)
- Define brand colors and fonts
- List all form fields needed
Step 2: Set Up Canvas and Branding
- Initialize canvas with page size
- Create header with company logo area and title
- Set up footer with page numbers
- Define color scheme constants
Step 3: Build Form Fields
- Add text fields for customer data
- Create checkbox grids for options
- Add signature boxes
- Include notes/comments areas
Step 4: Generate Sections
- Draw section headers with numbering
- Position form elements using coordinate system
- Add borders and visual separators
- Test field positioning and sizing
Recommendation▾
Include specific measurements/calculations for common page layouts beyond just letter size
Examples18 / 20
Example 1: Customer Information Section
Python# Input: Basic customer data collection def create_customer_section(c, y_start): # Section header c.setFillColor(colors.HexColor("#1B3A6B")) c.rect(50, y_start-25, 500, 25, fill=1) c.setFillColor(colors.white) c.setFont("Helvetica-Bold", 12) c.drawString(60, y_start-18, "1. CUSTOMER INFORMATION") # Form fields fields = [ ("Customer Name:", "customer_name", 250), ("Phone Number:", "phone", 150), ("Service Address:", "address", 300) ] y = y_start - 50 for label, field_name, width in fields: c.setFillColor(colors.black) c.setFont("Helvetica", 10) c.drawString(60, y+15, label) c.acroForm.textfield(name=field_name, x=60, y=y, width=width, height=18) y -= 35 return y # Return position for next section # Output: Professional form section with labeled fields
Example 2: Checkbox Grid for Services
Python# Input: List of services to track services = ["Filter Change", "Coil Cleaning", "Belt Inspection", "Thermostat Check", "Ductwork Review", "System Test"] def create_service_checkboxes(c, x, y, services): c.setFont("Helvetica-Bold", 10) c.drawString(x, y+15, "Services Performed:") cols = 2 col_width = 200 for i, service in enumerate(services): row = i // cols col = i % cols cb_x = x + (col * col_width) cb_y = y - (row * 25) # Checkbox c.acroForm.checkbox(name=f"service_{i}", x=cb_x, y=cb_y, size=12) # Label c.setFont("Helvetica", 9) c.drawString(cb_x + 20, cb_y + 3, service) return y - ((len(services) // cols + 1) * 25) # Output: Grid layout with 2 columns of checkboxes
Example 3: Signature Box
Python# Input: Signature area requirements def create_signature_box(c, x, y, width, title): height = 80 # Box border c.setStrokeColor(colors.HexColor("#B0BAC8")) c.rect(x, y-height, width, height, fill=0, stroke=1) # Title bar c.setFillColor(colors.HexColor("#1B3A6B")) c.rect(x+1, y-20, width-2, 18, fill=1) c.setFillColor(colors.white) c.setFont("Helvetica-Bold", 8) c.drawString(x+8, y-14, title) # Signature fields fields = [("Name:", 150), ("Signature:", 150), ("Date:", 100)] field_y = y - 35 for label, field_width in fields: c.setFillColor(colors.black) c.setFont("Helvetica", 8) c.drawString(x+8, field_y+10, label) c.acroForm.textfield( name=f"{title.lower()}_{label.replace(':', '')}", x=x+8, y=field_y-5, width=field_width, height=15 ) field_y -= 25 # Output: Professional signature box with name/signature/date fields
Recommendation▾
Provide template code for handling multi-page reports with consistent headers/footers
Best Practices
Layout Consistency:
- Use consistent margins (50-75pt from edges)
- Align elements to grid system (every 25pt vertically)
- Set standard field heights (18-25pt) for uniform appearance
- Leave 10pt padding inside bordered sections
Form Field Design:
- Use descriptive field names for PDF export compatibility
- Set appropriate field widths for expected content
- Add borders and background colors for visibility
- Group related fields visually
Brand Integration:
- Define color constants at file top
- Use company fonts (Helvetica family always available)
- Create consistent header/footer templates
- Add logo placeholder areas with proper sizing
Multi-page Handling:
- Track y-coordinates to detect page breaks
- Create page header/footer functions
- Number pages consistently
- Maintain section flow across pages
Common Pitfalls
Coordinate System Confusion:
- ReportLab uses bottom-left origin (0,0 at bottom-left)
- Y-coordinates decrease as you move down the page
- Always subtract from starting Y position for next element
- Test positioning with small adjustments
Form Field Overlaps:
- Calculate exact field positions before placing
- Account for font height when positioning labels
- Use helper functions to manage spacing calculations
- Test with longest expected text content
Missing AcroForm Setup:
- Canvas automatically creates acroForm object
- Field names must be unique across entire document
- Some PDF viewers require specific field properties
- Test forms in multiple PDF readers
Page Overflow:
- Check remaining space before adding sections
- Plan section heights during layout phase
- Use
if y < bottom_margin: c.showPage()for page breaks - Reset Y position after page breaks
Color and Font Issues:
- Always set fill color before drawing text
- Reset colors between different elements
- Stick to standard PDF fonts for compatibility
- Test color contrast for readability