#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Generate Wesmart Electronics Company Introduction PDF"""

from fpdf import FPDF
import os

class PDF(FPDF):
    def header(self):
        # Company header
        self.set_font('helvetica', 'B', 20)
        self.set_text_color(30, 58, 138)
        self.cell(0, 20, 'Shenzhen Wesmart Electronics Co., Ltd.', new_x='LMARGIN', new_y='NEXT', align='C')
        self.set_font('helvetica', '', 12)
        self.set_text_color(100, 100, 100)
        self.cell(0, 10, 'Inventor of Bus-type Stair Lights | National High-Tech Enterprise', new_x='LMARGIN', new_y='NEXT', align='C')
        self.ln(5)
        self.line(10, self.get_y(), 200, self.get_y())
        self.ln(10)
    
    def footer(self):
        self.set_y(-15)
        self.set_font('helvetica', 'I', 8)
        self.set_text_color(128, 128, 128)
        self.cell(0, 10, f'Page {self.page_no()}', align='C')
    
    def chapter_title(self, title):
        self.set_font('helvetica', 'B', 14)
        self.set_text_color(30, 58, 138)
        self.cell(0, 15, title, new_x='LMARGIN', new_y='NEXT')
        self.ln(2)
    
    def chapter_subtitle(self, subtitle):
        self.set_font('helvetica', 'B', 11)
        self.set_text_color(50, 50, 50)
        self.cell(0, 10, subtitle, new_x='LMARGIN', new_y='NEXT')
        self.ln(1)
    
    def body_text(self, text):
        self.set_font('helvetica', '', 10)
        self.set_text_color(60, 60, 60)
        self.multi_cell(0, 6, text)
        self.ln(3)
    
    def bullet_point(self, text):
        self.set_font('helvetica', '', 10)
        self.set_text_color(60, 60, 60)
        self.cell(5)
        self.cell(5, 6, chr(149), new_x='RIGHT', new_y='TOP')
        self.multi_cell(0, 6, text)
        self.ln(1)
    
    def info_box(self, label, value):
        self.set_font('helvetica', 'B', 10)
        self.set_text_color(30, 58, 138)
        self.cell(50, 7, label + ':', new_x='RIGHT', new_y='TOP')
        self.set_font('helvetica', '', 10)
        self.set_text_color(60, 60, 60)
        self.cell(0, 7, value, new_x='LMARGIN', new_y='NEXT')

def create_company_pdf():
    pdf = PDF()
    pdf.add_page()
    pdf.set_auto_page_break(auto=True, margin=15)
    
    # Company Profile
    pdf.chapter_title('Company Profile')
    pdf.body_text('Shenzhen Wesmart Electronics Co., Ltd. is a national high-tech enterprise specializing in the R&D and manufacturing of smart lighting. We are the INVENTOR of Bus-type Stair Light technology.')
    
    pdf.body_text('With two major brands under our portfolio:')
    pdf.bullet_point('Zhibu - Domestic market: "Smart Lighting, Every Step Matters"')
    pdf.bullet_point('Ameistor - International market: "Smart Lighting, Every Step Matters"')
    
    pdf.body_text('With 13 years of dedicated focus on smart lighting, we have served 10,000+ households and exported to 50+ countries worldwide.')
    
    # Core Competencies
    pdf.add_page()
    pdf.chapter_title('Core Competencies')
    
    pdf.chapter_subtitle('1. Technology Leadership')
    pdf.bullet_point('Inventor of Bus-type Stair Light technology (2-wire solution)')
    pdf.bullet_point('National High-Tech Enterprise (certified for consecutive years)')
    pdf.bullet_point('40+ patents and software copyrights')
    pdf.ln(3)
    
    pdf.chapter_subtitle('2. Complete Smart Ecosystem')
    pdf.bullet_point('Deep integration with Xiaomi Mi Home ecosystem')
    pdf.bullet_point('Multi-platform support: Mi Home APP, WeChat Mini Program, Tuya Smart')
    pdf.bullet_point('Global voice control: Xiao Ai, Tmall Genie, Amazon Alexa, Google Home')
    pdf.ln(3)
    
    pdf.chapter_subtitle('3. Integrated R&D, Manufacturing & Sales')
    pdf.bullet_point('Shenzhen R&D Center: Focused on product innovation')
    pdf.bullet_point('Zhongshan Manufacturing Base: SMT, assembly, and quality control')
    pdf.bullet_point('Guzhen Flagship Store: Brand showcase at Star Alliance Lighting Center')
    
    # Flagship Products
    pdf.add_page()
    pdf.chapter_title('Flagship Products')
    
    pdf.chapter_subtitle('Smart Stair Light Series (Flagship)')
    pdf.body_text('Zhibu ZM1 Stair Light - Pioneer of Bus-type Stair Lighting')
    pdf.bullet_point('Core Technology: 2-wire solution for power, communication, and sensing')
    pdf.bullet_point('Smart Control: Mi Home APP / WeChat Mini Program / Voice control')
    pdf.bullet_point('Market Performance: Douyin category bestseller with 20,000+ units sold')
    pdf.bullet_point('Applications: Villas, duplex apartments, loft stair lighting')
    pdf.ln(3)
    
    pdf.chapter_subtitle('Motion Sensor Ambient Light')
    pdf.bullet_point('Smart sensing: Auto-on when people approach, auto-off when leave')
    pdf.bullet_point('Perfect for: Bedroom night light, corridor lighting')
    pdf.bullet_point('Market performance: Douyin bestseller, highly rated by users')
    pdf.ln(3)
    
    pdf.chapter_subtitle('RGBW Ambient Light Pro')
    pdf.bullet_point('Full color control: RGBW four-channel dimming, 16 million colors')
    pdf.bullet_point('Smart linkage: Supports Tuya ecosystem whole-house automation')
    pdf.ln(3)
    
    pdf.chapter_subtitle('Outdoor Lighting Solutions')
    pdf.bullet_point('Professional waterproof: IP65 protection rating')
    pdf.bullet_point('Applications: Building facade lighting, landscape lighting, commercial spaces')
    
    # Market Coverage
    pdf.add_page()
    pdf.chapter_title('Market Coverage')
    
    pdf.chapter_subtitle('Domestic Channels')
    pdf.bullet_point('E-commerce: Official stores on Douyin, Tmall, JD.com, Pinduoduo')
    pdf.bullet_point('Offline: Brand store at Zhongshan Guzhen Star Alliance Lighting Center')
    pdf.bullet_point('B2B: Engineering projects and wholesale partnerships')
    pdf.ln(3)
    
    pdf.chapter_subtitle('International Markets')
    pdf.bullet_point('Amazon Global: US, Europe, Japan and other markets')
    pdf.bullet_point('Export Scale: Products sold to 50+ countries and regions')
    
    # Partnership
    pdf.chapter_title('Partnership Opportunities')
    
    pdf.chapter_subtitle('OEM/ODM Services')
    pdf.bullet_point('Customized product development support')
    pdf.bullet_point('Complete hardware + software + APP solutions')
    pdf.bullet_point('Full-process support from design to mass production')
    pdf.ln(3)
    
    pdf.chapter_subtitle('Technology Licensing')
    pdf.bullet_point('Bus-type stair light patent licensing')
    pdf.bullet_point('Complete smart lighting solution output')
    pdf.ln(3)
    
    pdf.chapter_subtitle('Channel Partnerships')
    pdf.bullet_point('Regional distributors and dealers welcome')
    pdf.bullet_point('E-commerce platform partnerships')
    pdf.bullet_point('Engineering project collaborations')
    
    # Contact
    pdf.add_page()
    pdf.chapter_title('Contact Us')
    
    pdf.info_box('Company', 'Shenzhen Wesmart Electronics Co., Ltd.')
    pdf.info_box('Headquarters', "Bao'an District, Shenzhen, China")
    pdf.info_box('Manufacturing Base', 'Xiaolan Town, Zhongshan City, Guangdong')
    pdf.info_box('Flagship Store', '10F C06, Star Alliance, Guzhen Town, Zhongshan')
    pdf.info_box('Certification', 'National High-Tech Enterprise')
    pdf.info_box('ICP License', 'Guangdong ICP No. 2020119126-1')
    pdf.ln(10)
    
    # Tagline
    pdf.set_font('helvetica', 'B', 14)
    pdf.set_text_color(30, 58, 138)
    pdf.cell(0, 20, 'Smart Lighting, Every Step Matters.', new_x='LMARGIN', new_y='NEXT', align='C')
    pdf.ln(5)
    pdf.set_font('helvetica', 'I', 10)
    pdf.set_text_color(100, 100, 100)
    pdf.cell(0, 10, 'Inventor of Bus-type Stair Lights | National High-Tech Enterprise | 40+ Patents', new_x='LMARGIN', new_y='NEXT', align='C')
    
    # Save PDF
    output_path = '/root/.openclaw/workspace/微智电子_公司介绍.pdf'
    pdf.output(output_path)
    print(f'PDF generated: {output_path}')
    return output_path

if __name__ == '__main__':
    create_company_pdf()
