Advertisement
Guest User

python html creation

a guest
Oct 7th, 2024
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.21 KB | None | 0 0
  1. from airium import Airium
  2.  
  3. def generate_invoice_html():
  4. a = Airium()
  5.  
  6. a('<!DOCTYPE html>')
  7. with a.html(lang="en"):
  8. with a.head():
  9. a.meta(charset="UTF-8")
  10. a.meta(name="viewport", content="width=device-width, initial-scale=1.0")
  11. a.title(_t="Invoice")
  12. a.style(_t="""
  13. body { font-family: Arial, sans-serif; margin: 0; padding: 0; }
  14. .invoice-box { width: 210mm; height: auto; max-width: 800px; margin: auto; padding: 20px; border: 1px solid #eee; box-shadow: 0 0 10px rgba(0, 0, 0, 0.15); }
  15. .invoice-box table { width: 100%; line-height: inherit; text-align: left; border-collapse: collapse; margin-top: 20px; }
  16. .invoice-box table td, .invoice-box table th { padding: 10px; vertical-align: middle; border: 1px solid #ddd; }
  17. .invoice-box table th { background-color: #f2f2f2; }
  18. .logo { width: 100px; height: 100px; background-color: #eee; display: inline-block; margin-right: 20px; }
  19. .header { display: flex; justify-content: space-between; align-items: center; }
  20. .company-info { text-align: left; }
  21. .invoice-details { text-align: right; }
  22. .customer-info { margin-top: 20px; display: inline-block; width: 50%; vertical-align: top; }
  23. .billing-info { margin-top: 20px; display: inline-block; width: 45%; text-align: right; vertical-align: top; }
  24. .heading { background: #eee; border-bottom: 1px solid #ddd; font-weight: bold; }
  25. .footer { text-align: center; margin-top: 30px; font-size: 12px; color: #888; border-top: 1px solid #ddd; padding-top: 10px; }
  26. .delimiter { border-bottom: 2px solid #000; margin: 10px 0; } /* Reduced margins */
  27. """)
  28.  
  29. with a.body():
  30. with a.div(klass="invoice-box"):
  31. # Header with Company Information
  32. with a.div(klass="header"):
  33. with a.div(klass="company-info"):
  34. a.div(klass="logo") # Placeholder for logo
  35. a.h3(_t="Your Company Name")
  36. a.p(_t="123 Your Street, City, Country")
  37. a.p(_t="Phone: +123 456 789")
  38. a.p(_t="Email: [email protected]")
  39.  
  40. # Invoice Details
  41. with a.div(klass="invoice-details"):
  42. a.h2(_t="Invoice #123")
  43. a.p(_t="Date: October 1, 2024")
  44.  
  45. # Horizontal separator
  46. with a.div(klass="delimiter"):
  47. a("")
  48.  
  49. # Customer Information
  50. with a.div(klass="customer-info"):
  51. a.h4(_t="Customer Details:")
  52. a.p(_t="Client's Name")
  53. a.p(_t="456 Client Address, City, Country")
  54. a.p(_t="Customer ID: 001234")
  55. a.p(_t="Email: [email protected]")
  56. a.p(_t="Phone: +987 654 321")
  57.  
  58. # Billing Information
  59. with a.div(klass="billing-info"):
  60. a.h4(_t="Billing Details:")
  61. a.p(_t="Billing Address")
  62. a.p(_t="789 Billing Street, City, Country")
  63. a.p(_t="Billing ID: 987654")
  64. a.p(_t="Email: [email protected]")
  65. a.p(_t="Phone: +321 654 987")
  66.  
  67. # Items Table
  68. with a.table(cellpadding="0", cellspacing="0"):
  69. with a.tr(klass="heading"):
  70. a.th(_t="Item Description")
  71. a.th(_t="Quantity")
  72. a.th(_t="Unit Price")
  73. a.th(_t="Tax")
  74. a.th(_t="Final Price")
  75.  
  76. with a.tr():
  77. a.td(_t="Web Development Service")
  78. a.td(_t="1")
  79. a.td(_t="$1500.00")
  80. a.td(_t="15%")
  81. a.td(_t="$1725.00")
  82.  
  83. with a.tr():
  84. a.td(_t="Design Service")
  85. a.td(_t="2")
  86. a.td(_t="$250.00")
  87. a.td(_t="10%")
  88. a.td(_t="$550.00")
  89.  
  90. with a.tr():
  91. a.td(_t="Hosting Service (1 year)")
  92. a.td(_t="1")
  93. a.td(_t="$100.00")
  94. a.td(_t="5%")
  95. a.td(_t="$105.00")
  96.  
  97. with a.tr():
  98. with a.td(colspan="4", style="text-align: right; font-weight: bold;"):
  99. a("Total:")
  100. a.td(_t="$2380.00")
  101.  
  102. with a.div(klass="footer"):
  103. a.p(_t="This is a placeholder footer. Company Name - Address - Contact: [email protected]")
  104.  
  105. return str(a)
  106.  
  107. invoice_html = generate_invoice_html()
  108.  
  109. with open("invoice.html", "w") as f:
  110. f.write(invoice_html)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement