def generate_catalogue(self, units, output_file="gami_catalogue.pdf"): self.add_cover() for unit in units: self.add_product_page(unit) self.output(output_file) print(f"Catalogue saved as {output_file}") def load_units_from_json(json_file): with open(json_file, "r") as f: data = json.load(f) return data["units"]
def add_product_page(self, unit): self.add_page() self.set_font("Arial", "B", 16) self.cell(0, 10, unit["model"], 0, 1) self.set_font("Arial", "", 10) self.cell(0, 6, f"Cooling Capacity: {unit['capacity_btu']} BTU/h ({unit['cooling_kw']} kW)", 0, 1) self.cell(0, 6, f"Heating: {unit['heating_type']}", 0, 1) self.cell(0, 6, f"SEER: {unit['efficiency_seer']}", 0, 1) self.cell(0, 6, f"Power: {unit['voltage']}", 0, 1) self.cell(0, 6, f"Weight: {unit['weight_lbs']} lbs", 0, 1) self.cell(0, 6, f"Dimensions (WxDxH): {unit['dimensions_in']} in", 0, 1) self.ln(4) self.set_font("Arial", "B", 12) self.cell(0, 8, "Key Features:", 0, 1) self.set_font("Arial", "", 10) for feat in unit["features"]: self.cell(5) self.cell(0, 6, f"• {feat}", 0, 1)
def footer(self): self.set_y(-15) self.set_font("Arial", "I", 8) self.cell(0, 10, f"Page {self.page_no()}", 0, 0, "C") gami package unit catalogue pdf
pip install fpdf2 pillow pandas Assume each package unit has:
if == " main ": # Sample data (replace with your DB/API) sample_units = [ { "model": "GAMI-PAC-18", "capacity_btu": 18000, "cooling_kw": 5.3, "heating_type": "Electric", "efficiency_seer": 15.0, "voltage": "208-230/1/60", "weight_lbs": 150, "dimensions_in": "30x22x34", "image_path": "images/pac18.jpg", "features": ["Compact size", "Low maintenance", "Corrosion coating"] }, { "model": "GAMI-PAC-36", "capacity_btu": 36000, "cooling_kw": 10.6, "heating_type": "Heat Pump", "efficiency_seer": 18.0, "voltage": "460/3/60", "weight_lbs": 220, "dimensions_in": "38x28x42", "image_path": "images/pac36.jpg", "features": ["Inverter compressor", "Wi-Fi ready", "Quiet operation"] } ] unit): self.add_page() self.set_font("Arial"
from fpdf import FPDF import json from PIL import Image import os class GAMICatalogue(FPDF): def header(self): if self.page_no() > 1: self.set_font("Arial", "B", 12) self.cell(0, 10, "GAMI Package Unit Catalogue", 0, 1, "C") self.ln(5)
Goal: Generate a professional PDF catalogue listing package units (model, specs, image, performance data). f"Weight: {unit['weight_lbs']} lbs"
# Add product image if exists if os.path.exists(unit["image_path"]): try: # Auto-fit image to max width 80, max height 60 self.image(unit["image_path"], x=130, y=30, w=60) except: pass
def add_cover(self): self.add_page() self.set_font("Arial", "B", 24) self.cell(0, 60, "", 0, 1) self.cell(0, 20, "GAMI", 0, 1, "C") self.set_font("Arial", "B", 18) self.cell(0, 15, "Package Unit Catalogue", 0, 1, "C") self.set_font("Arial", "", 12) self.cell(0, 10, "Commercial & Residential HVAC Solutions", 0, 1, "C") self.ln(20) self.set_font("Arial", "I", 10) self.cell(0, 10, f"Valid from {self.get_current_date()}", 0, 1, "C")
unit = { "model": "GAMI-PAC-24", "capacity_btu": 24000, "cooling_kw": 7.0, "heating_type": "Electric / Heat Pump", "efficiency_seer": 16.5, "voltage": "208-230/1/60", "weight_lbs": 185, "dimensions_in": "32x24x38", "image_path": "images/gami_pac_24.jpg", "features": ["Low noise", "R-410A", "Thermostat included"] } Create catalogue_generator.py :