Untitled

 avatar
unknown
plain_text
a year ago
2.5 kB
10
Indexable
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors

# File path
cheatsheet_pdf = "/mnt/data/Milling_Machine_Maintenance_CheatSheet.pdf"

# Styles
styles = getSampleStyleSheet()
title_style = styles["Title"]
heading_style = styles["Heading3"]
normal_style = styles["BodyText"]

# Document setup
doc = SimpleDocTemplate(cheatsheet_pdf, pagesize=A4)
elements = []

# Title
elements.append(Paragraph("Milling Machine Maintenance - Cheat Sheet", title_style))
elements.append(Spacer(1, 12))

# Content sections
sections = {
    "Importance": [
        "Accuracy & reliability",
        "Longer lifespan",
        "Prevent breakdowns",
        "Improved safety"
    ],
    "Safety Precautions": [
        "Power OFF & lock switch",
        "Wear PPE (goggles, gloves)",
        "Wait until spindle stops",
        "Use proper tools"
    ],
    "Daily": [
        "Clean chips & coolant",
        "Check lubrication",
        "Inspect cutters",
        "Refill coolant",
        "Oil coat surfaces"
    ],
    "Weekly": [
        "Check alignment",
        "Inspect belts & drives",
        "Clean/refill lube system",
        "Tighten bolts",
        "Inspect electrical parts"
    ],
    "Monthly": [
        "Inspect spindle bearings",
        "Adjust gibs/slides",
        "Test feed mechanisms",
        "Check coolant pump",
        "Clean motor vents"
    ],
    "Annual": [
        "Full calibration",
        "Flush & replace oil",
        "Replace worn parts",
        "Inspect wiring",
        "Professional service"
    ],
    "PRO TIPS": [
        "Use brush/vacuum (not compressed air)",
        "Never skip lubrication",
        "Keep checklist & logbook",
        "Report unusual sounds/vibration"
    ]
}

# Convert sections into a table format for compact one-page layout
table_data = []
for section, items in sections.items():
    text = f"<b>{section}</b><br/>" + "<br/>".join([f"- {item}" for item in items])
    table_data.append([Paragraph(text, normal_style)])

table = Table(table_data, colWidths=[500])
table.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), colors.lightgrey),
    ("BOX", (0,0), (-1,-1), 1, colors.black),
    ("INNERGRID", (0,0), (-1,-1), 0.5, colors.grey),
    ("VALIGN", (0,0), (-1,-1), "TOP"),
    ("FONTSIZE", (0,0), (-1,-1), 9)
]))

elements.append(table)

# Build PDF
doc.build(elements)

cheatsheet_pdf
Editor is loading...
Leave a Comment