It band contracture causes etiology and mechanism deformity signs and symptoms investigation treatment explain in detail with appropriate illustrative diagrams and images

Reading File
Finding Sources
Finding Sources
Finding Sources
Searching the Web

IT band iliotibial band contracture causes mechanism deformity treatment orthopedics

Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Loading Image
Reading File
Loading Image
Loading Image
Reading File
Reading File
Loading Image
Loading Image
Reading File
Finding Sources
Reading File
Loading Image
I now have comprehensive content. Let me compile the complete, detailed answer:

Iliotibial (IT) Band Contracture - Complete Clinical Overview

Sources: Campbell's Operative Orthopaedics 15th Ed 2026, Miller's Review of Orthopaedics 9th Ed, Gray's Anatomy for Students, Firestein & Kelley's Textbook of Rheumatology

1. Anatomy of the Iliotibial Band

The iliotibial band (IT band) is a thick, dense condensation of the fascia lata on the lateral side of the thigh. Understanding its anatomy is fundamental to appreciating how its contracture produces widespread deformities:
  • Proximal origin: The fascia lata arises from the coccyx, sacrum, iliac crest, inguinal ligament, and pubic arch. It invests all muscles of the thigh and buttock.
  • Muscles contributing: Both the superficial and deep layers attach to the gluteus maximus and all of the tensor fasciae latae (TFL). All these fascial attachments converge to form the IT band on the lateral thigh.
  • Distal insertion: The IT band inserts onto Gerdy's tubercle on the lateral tibial condyle and the lateral femoral condyle.
  • Course: It runs lateral and anterior to the hip joint, then crosses the lateral knee.
Anatomy of the hip showing the IT band and associated muscles - Campbell's Operative Orthopaedics
The above illustration shows the iliotibial band relationship with the hip joint structures - note its lateral and anterior position relative to the joint.

2. Etiology and Causes

IT band contracture arises from several mechanisms:

A. Neurological / Paralytic Causes (Most Classic)

  • Poliomyelitis - the most historically important cause. During the acute and convalescent stages, spasm of the hamstrings, hip flexors, tensor fasciae latae, and hip abductors is common. The patient assumes the "frog position" - hips and knees flexed, extremities completely externally rotated. If this position is maintained for even a few weeks, secondary soft-tissue contractures develop. When gluteal muscles are weakened, the deformity puts them at a mechanical disadvantage and prevents recovery of normal strength.
  • Cerebral palsy - spasticity in the TFL and hip abductors
  • Myelomeningocele - muscle imbalance around the hip
  • Post-polio paralysis - when gluteal muscles are paralyzed, the IT band is not counterbalanced

B. Inflammatory / Fibrotic Causes

  • Injections into the lateral thigh - particularly in children receiving repeated intramuscular injections (e.g., quinine, antibiotics). This causes localized fibrosis and progressive contracture of the TFL and IT band.
  • Dermatomyositis / polymyositis - fibrotic replacement of lateral thigh muscles
  • Tropical myositis - infection causing fibrosis

C. Postural / Positional Causes

  • Prolonged bed rest in the frog position
  • Improper positioning during illness or surgery
  • If correct positioning is not maintained while muscle spasm is present, and joints are not carried through full passive range of motion regularly, contractures will develop

D. Congenital / Idiopathic

  • Rare cases without identifiable cause
  • Associated with developmental hip dysplasia in some series
Key pathophysiological concept: When the IT band contracts, secondary adaptive changes occur rapidly. The resulting deformity, regardless of its duration or the patient's age, cannot be corrected by non-operative measures. Traction only increases obliquity and hyperextension of the pelvis and cannot exert any helpful corrective force on the deformity. - Campbell's Operative Orthopaedics

3. Mechanism of Deformity

The IT band lies lateral and anterior to the hip joint. Its contracture causes a cascade of mechanical deformities:

Primary mechanism at the hip:

When the IT band shortens/contracts:
  1. The hip is pulled into flexion (band anterior to hip axis), abduction (lateral pull), and external rotation (patient rotates for comfort)
  2. If external rotation is not corrected, the external rotators of the hip themselves contract and contribute to fixed deformity

Progressive bowstring mechanism at the knee:

With skeletal growth in children, the contracted IT band acts as a taut bowstring across the lateral aspect of the knee joint. This gradually:
  1. Abducts and flexes the tibia → genu valgum + flexion contracture
  2. Externally rotates the tibia on the femur (due to the lateral distal attachment)
  3. In extreme cases, the lateral tibial condyle subluxates on the lateral femoral condyle, and the head of the fibula lies in the popliteal space
Supracondylar osteotomy for knee flexion contracture from IT band - the green wedge indicates the bony correction needed
This diagram shows the supracondylar osteotomy (green wedge) needed to correct the flexion deformity at the knee caused by IT band contracture, with the red arrow showing the corrective force direction.

4. Deformities Caused by IT Band Contracture

The following is the canonical classification from eBox 36.2 of Campbell's Operative Orthopaedics:
DeformityMechanism
Flexion, abduction, external rotation contracture of hipIT band lies lateral and anterior to the hip joint; contracture causes flexion and abduction deformity. Hip is externally rotated for comfort; if uncorrected, external rotators contract and create fixed deformity.
Genu valgum + flexion contracture of the kneeWith growth, contracted IT band acts as a taut bowstring across the knee joint and gradually abducts and flexes the tibia.
External tibial torsion ± knee joint subluxationDue to lateral distal attachment, IT band gradually rotates tibia and fibula externally on femur. Rotation is increased if short head of biceps femoris is strong. When extreme, lateral tibial condyle subluxates on lateral femoral condyle, and head of fibula lies in the popliteal space.
Limb-length discrepancyMechanism not clearly defined; may be related to loss of neurologic and muscle function. Contracted IT band on one side can be associated with considerable extremity shortening after years of growth.
Secondary ankle and foot deformitiesDownstream consequence of tibial torsion and limb shortening.
Pelvic obliquityDue to asymmetric hip deformity pulling the pelvis laterally.
Increased lumbar lordosisCompensatory response to fixed hip flexion deformity.

5. Signs and Symptoms

Clinical Presentation

  • Gait abnormality - the patient walks with hip flexed, abducted, and externally rotated; knee may be in valgus
  • Hip pain - lateral hip pain aggravated by activity
  • Lateral knee pain - particularly common in ambulatory cases; burning or aching at the lateral femoral condyle
  • Snapping hip - audible/palpable snapping as the thickened IT band flicks over the greater trochanter (external snapping hip syndrome)
  • Difficulty with adduction - patient cannot bring the affected limb across the midline
  • Trendelenburg gait - when gluteal weakness coexists
  • Progressive knee deformity - valgus + external tibial rotation
  • Limping - due to leg length discrepancy and/or pain

Key Clinical Signs

1. Ober Test (diagnostic cornerstone):
  • Patient lies on the unaffected side
  • Examiner abducts the hip with the knee flexed (to ~90°)
  • Hip is slightly extended to allow the IT band to pass over the greater trochanter
  • Examiner slowly lowers the patient's limb with muscles relaxed
  • Positive test: The limb remains abducted and does not fall to the table due to gravity - indicates IT band contracture
  • A positive test with the hip extended past neutral = tightness of the IT band
  • A positive test with the hip in neutral flexion/extension = gluteus medius contracture or tendinopathy
FADIR test positioning - patient lies lateral for hip examination
Patient positioning for lateral hip examination - the Ober test is performed in this lateral decubitus position.
2. Snapping Iliotibial Band Test:
  • Similar position to Ober test
  • Hip is flexed and extended while tensioning the IT band
  • In thin patients, visible snapping of the thickened IT band can be seen
3. Hip ROM Assessment:
  • Restriction of adduction
  • Fixed flexion deformity (measured by Thomas test)
  • External rotation often greater than internal rotation
  • Abduction may appear preserved or even increased early, but late-stage has fixed abduction
4. Knee Examination:
  • Valgus alignment
  • Flexion contracture (inability to fully extend)
  • External tibial torsion (foot points laterally)
  • In severe cases: lateral tibial condyle subluxation
5. Gait analysis:
  • Stiff-legged gait
  • Lateral trunk sway
  • Characteristic "frog" posture in poliomyelitis cases

6. Investigations

Clinical / Bedside

  • Ober test (as above)
  • Thomas test - reveals hip flexion contracture
  • Straight-leg raise - often limited due to hamstring spasm
  • Goniometric measurement - quantify ROM limitations

Radiological

Plain X-rays (AP pelvis, hip, knee):
  • Hip: shows degree of joint space and alignment; pelvic obliquity measurable
  • Knee: assesses degree of valgus (tibiofemoral angle), joint line orientation, tibial torsion
  • Lateral tibial condyle subluxation visible in advanced cases
MRI:
  • Definitive assessment of IT band thickness and signal
  • Assesses associated bursitis (iliotibial band bursitis over lateral femoral condyle)
  • Rules out other causes of lateral knee pain (lateral meniscus, LCL pathology)
  • In contracture cases: demonstrates fibrotic/thickened band
Ultrasound:
  • Dynamic assessment of IT band snapping over greater trochanter
  • Measures IT band thickness at the level of the lateral femoral condyle (normal ~2-3 mm)
  • Guided injections
CT scan:
  • Best for assessing tibial torsion quantitatively
  • Useful when surgical planning for osteotomy

Special Tests

  • EMG/NCS - if neuromuscular etiology (poliomyelitis, myelomeningocele)
  • Scanogram - for precise limb-length discrepancy measurement

7. Treatment

Treatment is stratified by severity. Critically, non-operative measures cannot correct established contracture - they can only prevent progression or treat early/mild cases.

A. Non-Operative / Preventive

1. Positioning and prophylaxis:
  • In poliomyelitis: patient should be placed in bed with hips in neutral rotation, slight abduction, and no flexion
  • All joints must be carried through full passive range of motion several times daily
  • Hips must be stretched in extension, adduction, and internal rotation
  • A Denis Browne-type bar to hold feet in slight internal rotation prevents rotational deformity
  • If contracture is found, it must be corrected before ambulation is allowed
2. Physiotherapy (early/mild contracture):
  • Ober stretches - longitudinal IT band stretching
  • Hip abductor strengthening (gluteus medius)
  • Core and hip flexor strengthening to improve biomechanics
  • Foam rolling / soft tissue mobilization
3. NSAIDs: Reduce inflammation associated with IT band friction syndrome
4. Corticosteroid injection:
  • Into the IT band/bursa at the lateral femoral condyle
  • Guided by ultrasound for precision
  • Helpful for pain relief but does not address underlying contracture

B. Operative Treatment

Minor Contractures: Fasciotomy

  • Simple fasciotomies around the hip and knee may correct a minor contracture
  • Recurrence is common; does not correct severe contracture

Moderate Contractures: Ober-Yount Procedure (eTechnique 36.18)

For abduction and external rotation contractures:
  1. Patient in lateral position; transverse incision medial and distal to ASIS, extending laterally above greater trochanter
  2. Divide the iliopsoas tendon distally and excise 1 cm
  3. Detach sartorius from ASIS; detach rectus femoris from AIIS; divide tensor fasciae latae from anterior border completely posteriorly
  4. Detach gluteus medius and minimus and short external rotators from trochanter
  5. Retract sciatic nerve posteriorly; open hip capsule from anterior to posterior parallel to acetabular labrum
  6. Close wound; apply hip spica cast with hip in full extension, 10° abduction, internal rotation if possible
Yount procedure at the knee (distal component):
  1. Expose fascia lata through a lateral longitudinal incision just proximal to the femoral condyle
  2. Divide the IT band and fascia lata posteriorly to the biceps tendon and anteriorly to the midline of the thigh, at a level 2.5 cm proximal to the patella
  3. Excise a segment of the IT band and lateral intermuscular septum 5-8 cm long
  4. Confirm by palpation that all tight bands have been divided
Postoperative care: Cast removed at 2 weeks; long-leg brace with pelvic band fitted with hip in corrected position.
Surgical exposure during Ober-Yount procedure - tensor fasciae latae is being divided
Intraoperative view during IT band release - the white sheet-like IT band/fascia lata is being exposed and incised.
Staged release with incision line marked in blue showing extent of IT band division
This operative illustration shows the staged fascial release with the planned incision line (blue) for IT band segment excision during the Yount procedure.

Severe Deformities: Campbell Technique (eTechnique 36.19)

For severe cases requiring complete muscle release from the iliac wing:
  1. Incise along the anterior half of the iliac crest to ASIS and distally 5-10 cm on anterior thigh
  2. Divide superficial and deep fasciae to the iliac crest
  3. Strip origins of TFL, gluteus medius and minimus subperiosteally from the wing of the ilium down to the acetabulum
  4. Free proximal sartorius from TFL
  5. With osteotome, resect ASIS along with origin of sartorius muscle; allow to retract distally and posteriorly
  6. If hip cannot be hyperextended, divide the hip capsule obliquely; as a last resort, release the iliopsoas from the lesser trochanter by tenotomy
  7. After complete deformity correction, resect the redundant part of the denuded ilium with an osteotome
In young children: to preserve the iliac physis, free muscles subperiosteally from the lateral surface only; remove a wedge of bone from the crest distal to the physis, then displace crest distally and fix with soft-tissue sutures.
Postoperative care: Hip in hyperextension and 10° abduction; spica cast for 3-4 weeks, then mobilize with crutches. Night splinting or brace required for several months.

For Knee Flexion Contractures

  • 15-20° in young children: Posterior hamstring lengthening + capsulotomy
  • More severe (>20°): Supracondylar extension osteotomy of the femur
  • >70° in growing children: Division of IT band + hamstring tendons + posterior capsulotomy; skeletal traction via two tibial pins post-operatively; long-leg brace for joint remodeling; supracondylar osteotomy may be needed as a second stage
The Miller's Review summary for abduction contracture management is:
"Hip abduction contracture can cause pelvic obliquity and scoliosis; it is treated with proximal division of the tensor fasciae latae and distal iliotibial band release (Ober-Yount procedure)."

Summary Table

AspectKey Points
AnatomyFascia lata condensation; arises from coccyx/sacrum/iliac crest; formed by TFL and gluteus maximus; inserts at Gerdy's tubercle
Position relative to hipLateral AND anterior to hip joint - explains flexion + abduction deformity
Primary etiologyPoliomyelitis (frog position); injection fibrosis; prolonged malposition
Key deformitiesHip flexion-abduction-ER; genu valgum; knee flexion contracture; external tibial torsion; subluxation; LLD; pelvic obliquity
Mechanism at kneeActs as taut bowstring, gradually abducts and flexes tibia; external rotation from lateral distal attachment
Diagnostic testOber test (lateral position; hip abducted then allowed to adduct; positive = limb remains abducted)
Non-operativeOnly effective in prevention/early stage; traction is CONTRAINDICATED (worsens deformity)
Minor surgerySimple fasciotomy (high recurrence)
Moderate surgeryOber-Yount procedure (proximal hip release + distal IT band segment excision)
Severe surgeryCampbell technique (complete iliac wing muscle release ± iliac crest osteotomy)
Knee surgeryHamstring lengthening; supracondylar osteotomy; IT band division + capsulotomy for severe cases

References:
  • [Campbell's Operative Orthopaedics 15th Ed 2026](eBox 36.2; eTechniques 36.18, 36.19), pp. 1640-1643
  • Miller's Review of Orthopaedics 9th Edition - Flexion contractures section
  • Firestein & Kelley's Textbook of Rheumatology - Ober test description
  • Gray's Anatomy for Students - IT band anatomy

Convert to a pdf

Reading File
Running Command

ls /home/daytona/workspace/ 2>/dev/null || mkdir -p /home/daytona/workspace && l…

Running Command

python3 -c "import weasyprint; print('weasyprint ok')" 2>&1; python3 -c "from re…

Writing File

~/it_band_pdf/create_pdf.py

import os
import urllib.request
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Image, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import cm, mm
from reportlab.lib import colors
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus.flowables import HRFlowable

OUTPUT_DIR = "/home/daytona/workspace/it_band_pdf"
IMG_DIR = os.path.join(OUTPUT_DIR, "images")
os.makedirs(IMG_DIR, exist_ok=True)

# Download images
images = {
    "anatomy_hip": "https://cdn.orris.care/cdss_images/87bebd5f74c03d1a33011950fcbba1768cca1b228a23e208afd95eb81a79174f.png",
    "knee_osteotomy": "https://cdn.orris.care/cdss_images/72ee2556f5f728cfcf170c0a5282f5f9cd96e7fe69c1a119898234592eebcd4b.png",
    "surgery1": "https://cdn.orris.care/cdss_images/f328f1de58a96f16df9e3b2fba8cb92fd96ea0b3c398cc81ad6e9da5afa38ab5.png",
    "surgery2": "https://cdn.orris.care/cdss_images/b2687c071fc98f6ac27dfc66e2638f4453ec5919282466484f9a501a319cc199.png",
    "ober_test": "https://cdn.orris.care/cdss_images/20f8e7bfb844262b54cd352cbe5ad8c59e18b3dfd83e23e4ae13bd6794d92f3d.png",
}

img_paths = {}
for name, url in images.items():
    path = os.path.join(IMG_DIR, f"{name}.png")
    if not os.path.exists(path):
        print(f"Downloading {name}...")
        try:
            urllib.request.urlretrieve(url, path)
            print(f"  OK: {path}")
        except Exception as e:
            print(f"  FAILED: {e}")
    img_paths[name] = path

# ── Styles ──────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()
PAGE_W, PAGE_H = A4

def make_style(name, parent="Normal", **kwargs):
    base = styles[parent]
    return ParagraphStyle(name, parent=base, **kwargs)

title_style = make_style("DocTitle", "Title",
    fontSize=22, textColor=colors.HexColor("#1a3a5c"),
    spaceAfter=6, spaceBefore=0, alignment=TA_CENTER,
    fontName="Helvetica-Bold")

subtitle_style = make_style("DocSubtitle", "Normal",
    fontSize=11, textColor=colors.HexColor("#4a6fa5"),
    spaceAfter=4, alignment=TA_CENTER, fontName="Helvetica-Oblique")

h1_style = make_style("H1", "Heading1",
    fontSize=15, textColor=colors.HexColor("#1a3a5c"),
    spaceBefore=14, spaceAfter=4, fontName="Helvetica-Bold",
    borderPad=4)

h2_style = make_style("H2", "Heading2",
    fontSize=12, textColor=colors.HexColor("#2e6da4"),
    spaceBefore=10, spaceAfter=3, fontName="Helvetica-Bold")

h3_style = make_style("H3", "Heading3",
    fontSize=11, textColor=colors.HexColor("#3a7abf"),
    spaceBefore=7, spaceAfter=2, fontName="Helvetica-BoldOblique")

body_style = make_style("Body", "Normal",
    fontSize=10, leading=15, spaceAfter=5, spaceBefore=2,
    alignment=TA_JUSTIFY)

bullet_style = make_style("Bullet", "Normal",
    fontSize=10, leading=14, spaceAfter=3, spaceBefore=1,
    leftIndent=16, bulletIndent=6)

caption_style = make_style("Caption", "Normal",
    fontSize=8.5, leading=12, textColor=colors.HexColor("#555555"),
    alignment=TA_CENTER, spaceAfter=6, fontName="Helvetica-Oblique")

callout_style = make_style("Callout", "Normal",
    fontSize=9.5, leading=14, textColor=colors.HexColor("#1a3a5c"),
    backColor=colors.HexColor("#e8f0fa"), borderPad=6,
    leftIndent=12, rightIndent=12, spaceAfter=6, spaceBefore=4,
    fontName="Helvetica-Oblique")

source_style = make_style("Source", "Normal",
    fontSize=8, textColor=colors.HexColor("#888888"),
    alignment=TA_CENTER, spaceAfter=2)

# ── Helper functions ─────────────────────────────────────────────────────────
def H1(text): return Paragraph(text, h1_style)
def H2(text): return Paragraph(text, h2_style)
def H3(text): return Paragraph(text, h3_style)
def P(text):  return Paragraph(text, body_style)
def B(text):  return Paragraph(f"• {text}", bullet_style)
def CAP(text): return Paragraph(text, caption_style)
def CALL(text): return Paragraph(text, callout_style)
def SP(n=6): return Spacer(1, n)
def HR(): return HRFlowable(width="100%", thickness=0.5,
                             color=colors.HexColor("#2e6da4"), spaceAfter=4)

def img_flowable(key, width_cm=12, caption_text=None):
    path = img_paths.get(key)
    elems = []
    if path and os.path.exists(path):
        w = width_cm * cm
        try:
            from PIL import Image as PILImage
            with PILImage.open(path) as im:
                iw, ih = im.size
            ratio = ih / iw
            h = w * ratio
            # cap height
            max_h = 9 * cm
            if h > max_h:
                h = max_h
                w = h / ratio
        except Exception:
            h = width_cm * 0.75 * cm
        elems.append(Image(path, width=w, height=h, hAlign="CENTER"))
        if caption_text:
            elems.append(CAP(caption_text))
    return elems

def section_divider(title):
    return [SP(4), HR(), H1(title), HR(), SP(4)]

# ── Table helper ─────────────────────────────────────────────────────────────
def make_table(headers, rows, col_widths=None):
    data = [headers] + rows
    if col_widths is None:
        col_widths = [((A4[0] - 4*cm) / len(headers))] * len(headers)
    
    header_style = ParagraphStyle("TH", fontName="Helvetica-Bold",
                                   fontSize=9, textColor=colors.white,
                                   leading=12, alignment=TA_CENTER)
    cell_style  = ParagraphStyle("TD", fontName="Helvetica",
                                  fontSize=9, leading=12, alignment=TA_LEFT)

    styled = []
    for i, row in enumerate(data):
        styled.append([
            Paragraph(str(cell), header_style if i == 0 else cell_style)
            for cell in row
        ])

    t = Table(styled, colWidths=col_widths, repeatRows=1)
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#1a3a5c")),
        ("ROWBACKGROUNDS", (0,1), (-1,-1),
         [colors.HexColor("#f0f5fb"), colors.white]),
        ("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#b0c4de")),
        ("VALIGN", (0,0), (-1,-1), "TOP"),
        ("TOPPADDING", (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING", (0,0), (-1,-1), 6),
        ("RIGHTPADDING", (0,0), (-1,-1), 6),
    ]))
    return t

# ═══════════════════════════════════════════════════════════════════════════
# BUILD CONTENT
# ═══════════════════════════════════════════════════════════════════════════
story = []

# ── Cover / Title ────────────────────────────────────────────────────────────
story += [
    SP(30),
    Paragraph("IT Band (Iliotibial Band) Contracture", title_style),
    SP(6),
    Paragraph("Causes · Etiology · Mechanism · Deformity · Signs & Symptoms · Investigation · Treatment",
              subtitle_style),
    SP(8),
    HRFlowable(width="80%", thickness=2, color=colors.HexColor("#2e6da4"),
               hAlign="CENTER", spaceAfter=6),
    SP(4),
    Paragraph("Source: Campbell's Operative Orthopaedics 15th Ed 2026 · Miller's Review of Orthopaedics 9th Ed\n"
              "Gray's Anatomy for Students · Firestein & Kelley's Textbook of Rheumatology",
              source_style),
    PageBreak(),
]

# ── 1. Anatomy ───────────────────────────────────────────────────────────────
story += section_divider("1. Anatomy of the Iliotibial Band")

story += [
    P("The <b>iliotibial band (IT band)</b> is a dense, thick condensation of the fascia lata "
      "running along the lateral aspect of the thigh. It is formed by the convergence of multiple "
      "fascial layers and two key muscles."),
    SP(4),
]

story += [
    H2("Proximal Origin"),
    B("Fascia lata arises from: coccyx, sacrum, iliac crest, inguinal ligament, and pubic arch"),
    B("Invests all muscles of the thigh and buttock"),
    B("Both superficial and deep layers attach to the <b>gluteus maximus</b>"),
    B("All of the <b>tensor fasciae latae (TFL)</b> contributes to the IT band"),
    B("All fascial attachments converge to form the IT band on the lateral thigh"),
    SP(4),
    H2("Distal Insertion"),
    B("Gerdy's tubercle on the <b>lateral tibial condyle</b>"),
    B("Also attaches to the <b>lateral femoral condyle</b>"),
    SP(4),
    H2("Key Positional Relationship"),
    CALL("The IT band lies LATERAL and ANTERIOR to the hip joint — this is the anatomical basis "
         "for flexion + abduction deformity when it contracts."),
    SP(6),
]

story += img_flowable("anatomy_hip", width_cm=11,
    caption_text="Fig. 1 — Anatomy of the hip showing the iliotibial band and its relationship "
                 "with the hip joint, tensor fasciae latae, and gluteus maximus. "
                 "(Campbell's Operative Orthopaedics 15th Ed)")

# ── 2. Etiology ──────────────────────────────────────────────────────────────
story += section_divider("2. Etiology and Causes")

story += [
    H2("A. Neurological / Paralytic Causes (Most Classic)"),
    P("<b>Poliomyelitis</b> — the historically most important cause:"),
    B("Spasm of hamstrings, hip flexors, TFL, and hip abductors during acute and convalescent stages"),
    B("Patient assumes the 'frog position' — hips and knees flexed, extremities completely externally rotated"),
    B("If this position is maintained even a few weeks, secondary soft-tissue contractures develop"),
    B("When gluteal muscles are weakened, the deformity puts them at mechanical disadvantage, "
      "preventing recovery of normal strength"),
    B("Growth of contracted soft tissues fails to keep pace with bone growth → progressive deformity"),
    SP(4),
    B("<b>Cerebral palsy</b> — spasticity in TFL and hip abductors"),
    B("<b>Myelomeningocele</b> — muscle imbalance around the hip"),
    B("<b>Post-polio sequelae</b> — paralyzed gluteal muscles leave IT band unopposed"),
    SP(6),

    H2("B. Inflammatory / Fibrotic Causes"),
    B("<b>Repeated intramuscular injections</b> into the lateral thigh (especially in children — "
      "quinine, antibiotics) → local fibrosis → progressive contracture of TFL and IT band"),
    B("<b>Dermatomyositis / polymyositis</b> — fibrotic replacement of lateral thigh muscles"),
    B("<b>Tropical myositis</b> — infection causing fibrosis"),
    SP(6),

    H2("C. Postural / Positional Causes"),
    B("Prolonged bed rest in frog position"),
    B("Improper positioning during illness, surgery, or casting"),
    B("Failure to carry joints through full passive ROM during muscle spasm phase"),
    SP(6),

    H2("D. Congenital / Idiopathic"),
    B("Rare cases without identifiable cause"),
    B("Associated with developmental hip dysplasia in some series"),
    SP(4),

    CALL("Key point: If correct positioning is not maintained while muscle spasm is present, and if joints "
         "are not carried through a full range of passive motion at regular intervals after spasm disappears, "
         "contractures cannot be prevented. — Campbell's Operative Orthopaedics"),
]

# ── 3. Mechanism ─────────────────────────────────────────────────────────────
story += section_divider("3. Mechanism of Deformity")

story += [
    H2("Primary Mechanism at the Hip"),
    P("Because the IT band lies <b>lateral AND anterior</b> to the hip joint, when it shortens/contracts:"),
    B("Hip is pulled into <b>flexion</b> (band anterior to hip flexion/extension axis)"),
    B("Hip is pulled into <b>abduction</b> (lateral pull of the band)"),
    B("Hip is <b>externally rotated</b> for comfort to relieve tension on the band"),
    B("If external rotation is not corrected, the external rotators themselves contract → <b>fixed deformity</b>"),
    SP(6),

    H2("Progressive Bowstring Mechanism at the Knee"),
    P("With skeletal growth in children, the contracted IT band acts as a <b>taut bowstring</b> "
      "across the lateral knee:"),
    B("Gradually <b>abducts and flexes the tibia</b> → genu valgum + flexion contracture"),
    B("<b>Externally rotates</b> the tibia on the femur (due to lateral distal attachment)"),
    B("Rotation increased if short head of biceps femoris is strong"),
    B("In extreme cases: <b>lateral tibial condyle subluxates</b> on lateral femoral condyle"),
    B("Head of fibula may lie in the <b>popliteal space</b>"),
    SP(6),

    CALL("Secondary adaptive changes occur soon after the IT band contracts. The resulting deformity, "
         "regardless of its duration or the patient's age, CANNOT be corrected by non-operative measures. "
         "Traction only increases pelvic obliquity/hyperextension and cannot exert any corrective force. "
         "— Campbell's Operative Orthopaedics"),
    SP(6),
]

story += img_flowable("knee_osteotomy", width_cm=9,
    caption_text="Fig. 2 — Supracondylar osteotomy (green wedge) for knee flexion contracture caused by "
                 "IT band contracture. The red arrow shows the corrective force direction. "
                 "(Campbell's Operative Orthopaedics 15th Ed)")

# ── 4. Deformities ───────────────────────────────────────────────────────────
story += section_divider("4. Deformities Caused by IT Band Contracture")

story += [
    P("The following canonical classification is from <b>eBox 36.2, Campbell's Operative Orthopaedics 15th Ed</b>:"),
    SP(6),
]

deformity_headers = [
    Paragraph("<b>Deformity</b>", make_style("TH2", fontName="Helvetica-Bold",
              fontSize=9, textColor=colors.white, leading=12)),
    Paragraph("<b>Mechanism</b>", make_style("TH2", fontName="Helvetica-Bold",
              fontSize=9, textColor=colors.white, leading=12)),
]

cell_s = ParagraphStyle("TD2", fontName="Helvetica", fontSize=9, leading=12)

deformity_rows_raw = [
    ("Flexion, abduction, external rotation contracture of the hip",
     "IT band lies lateral and anterior to hip joint; contracture causes flexion and abduction deformity. Hip externally rotated for comfort; if not corrected, external rotators contract and contribute to fixed deformity."),
    ("Genu valgum + flexion contracture of the knee",
     "With growth, contracted IT band acts as a taut bowstring across the knee joint and gradually abducts and flexes the tibia."),
    ("External tibial torsion ± knee joint subluxation",
     "Due to lateral distal attachment, IT band gradually rotates tibia and fibula externally on femur. Rotation increased if short head of biceps is strong. When extreme, lateral tibial condyle subluxates on lateral femoral condyle; head of fibula lies in popliteal space."),
    ("Limb-length discrepancy",
     "Mechanism not clearly defined; may relate to loss of neurologic and muscle function. Contracted IT band on one side can be associated with considerable extremity shortening after years of growth."),
    ("Secondary ankle and foot deformities",
     "Downstream consequence of tibial torsion and limb shortening."),
    ("Pelvic obliquity",
     "Due to asymmetric hip deformity pulling the pelvis laterally."),
    ("Increased lumbar lordosis",
     "Compensatory response to fixed hip flexion deformity."),
]

tbl_data = [[Paragraph("<b>Deformity</b>", make_style("TH3", fontName="Helvetica-Bold",
                        fontSize=9, textColor=colors.white, leading=12, alignment=TA_CENTER)),
             Paragraph("<b>Mechanism</b>", make_style("TH3", fontName="Helvetica-Bold",
                        fontSize=9, textColor=colors.white, leading=12, alignment=TA_CENTER))]]
for d, m in deformity_rows_raw:
    tbl_data.append([Paragraph(d, cell_s), Paragraph(m, cell_s)])

col_w = A4[0] - 4*cm
t = Table(tbl_data, colWidths=[col_w*0.35, col_w*0.65], repeatRows=1)
t.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#1a3a5c")),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#f0f5fb"), colors.white]),
    ("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#b0c4de")),
    ("VALIGN", (0,0), (-1,-1), "TOP"),
    ("TOPPADDING", (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING", (0,0), (-1,-1), 6),
    ("RIGHTPADDING", (0,0), (-1,-1), 6),
]))
story += [t, SP(6)]

# ── 5. Signs & Symptoms ──────────────────────────────────────────────────────
story += section_divider("5. Signs and Symptoms")

story += [
    H2("Clinical Presentation"),
    B("<b>Gait abnormality</b> — hip flexed, abducted, externally rotated; knee in valgus"),
    B("<b>Lateral hip pain</b> — aggravated by activity"),
    B("<b>Lateral knee pain</b> — burning/aching at the lateral femoral condyle"),
    B("<b>Snapping hip</b> — audible/palpable as IT band flicks over greater trochanter (external snapping hip)"),
    B("<b>Difficulty with adduction</b> — cannot bring limb across midline"),
    B("<b>Trendelenburg gait</b> — when gluteal weakness coexists"),
    B("<b>Progressive knee deformity</b> — valgus + external tibial rotation"),
    B("<b>Limping</b> — due to LLD and/or pain"),
    B("<b>'Frog position'</b> — hips and knees flexed, extremities externally rotated (in paralytic cases)"),
    SP(6),

    H2("Key Clinical Signs"),
    H3("1. Ober Test (Diagnostic Cornerstone)"),
    P("The Ober test is the primary clinical test for IT band contracture:"),
    B("Patient lies on the <b>unaffected side</b>"),
    B("Examiner <b>abducts</b> the hip with knee flexed (~90°)"),
    B("Hips slightly <b>extended</b> to allow IT band to pass over the greater trochanter"),
    B("Examiner slowly <b>lowers</b> the patient's limb with muscles relaxed"),
    B("<b>Positive test:</b> Limb remains abducted and does not fall to table under gravity → IT band contracture"),
    B("Positive with hip <b>extended past neutral</b> = IT band tightness"),
    B("Positive with hip in <b>neutral</b> flexion/extension = gluteus medius contracture or tendinopathy"),
    SP(6),
]

story += img_flowable("ober_test", width_cm=10,
    caption_text="Fig. 3 — Patient positioned for the Ober test (lateral decubitus). "
                 "The examiner abducts and extends the hip, then releases; the limb remaining "
                 "abducted indicates a positive test for IT band contracture. "
                 "(Campbell's Operative Orthopaedics 15th Ed)")

story += [
    SP(4),
    H3("2. Snapping Iliotibial Band Test"),
    B("Similar position to Ober test"),
    B("Hip flexed and extended while tensioning the IT band"),
    B("In thin patients, visible snapping of the thickened IT band may be seen"),
    SP(4),

    H3("3. Hip ROM Assessment"),
    B("Restriction of adduction"),
    B("Fixed flexion deformity (measured by Thomas test)"),
    B("External rotation often > internal rotation"),
    B("Abduction may appear preserved early but fixed abduction develops late"),
    SP(4),

    H3("4. Knee Examination"),
    B("Valgus alignment (genu valgum)"),
    B("Flexion contracture — inability to fully extend"),
    B("External tibial torsion — foot points laterally"),
    B("In severe cases: lateral tibial condyle subluxation"),
    SP(4),

    H3("5. Gait Analysis"),
    B("Stiff-legged gait with lateral trunk sway"),
    B("Characteristic 'frog' posture in poliomyelitis-related cases"),
    B("Trendelenburg sign when gluteals are weak"),
]

# ── 6. Investigations ────────────────────────────────────────────────────────
story += section_divider("6. Investigations")

story += [
    H2("A. Clinical / Bedside Tests"),
    B("<b>Ober test</b> — primary test for IT band contracture (described above)"),
    B("<b>Thomas test</b> — reveals degree of fixed hip flexion contracture"),
    B("<b>Straight-leg raise</b> — often limited due to hamstring spasm"),
    B("<b>Goniometric measurement</b> — quantify ROM limitations at hip and knee"),
    SP(6),

    H2("B. Radiological Investigations"),
    H3("Plain X-rays (AP Pelvis, Hip, Knee)"),
    B("Hip: assess joint space, alignment; quantify pelvic obliquity"),
    B("Knee: assess tibiofemoral angle for valgus degree; joint line orientation; tibial torsion"),
    B("Lateral tibial condyle subluxation visible in advanced cases"),
    SP(4),

    H3("MRI"),
    B("Definitive assessment of IT band thickness and signal intensity"),
    B("Assesses associated bursitis (at lateral femoral condyle)"),
    B("Rules out other causes (lateral meniscus, LCL pathology)"),
    B("Demonstrates fibrotic/thickened band in contracture"),
    SP(4),

    H3("Ultrasound"),
    B("Dynamic assessment of IT band snapping over greater trochanter"),
    B("Measures IT band thickness (normal ~2–3 mm at lateral femoral condyle)"),
    B("Guides corticosteroid injections"),
    SP(4),

    H3("CT Scan"),
    B("Best for quantitative assessment of tibial torsion"),
    B("Useful for surgical planning before osteotomy"),
    SP(4),

    H2("C. Special Tests"),
    B("<b>EMG/NCS</b> — if neuromuscular etiology suspected (poliomyelitis, myelomeningocele)"),
    B("<b>Scanogram (orthoroentgenogram)</b> — for precise limb-length discrepancy measurement"),
]

# ── 7. Treatment ─────────────────────────────────────────────────────────────
story += section_divider("7. Treatment")

story += [
    CALL("CRITICAL PRINCIPLE: Non-operative measures cannot correct established IT band contracture. "
         "Traction is CONTRAINDICATED — it only worsens pelvic obliquity without correcting the deformity. "
         "Surgery is the only effective treatment for established contracture."),
    SP(6),

    H2("A. Non-Operative / Preventive (Early Stage Only)"),
    H3("Positioning and Prophylaxis (Poliomyelitis)"),
    B("Patient placed in bed with hips in <b>neutral rotation, slight abduction, and NO flexion</b>"),
    B("All joints carried through <b>full passive ROM several times daily</b>"),
    B("Hips stretched in extension, adduction, and internal rotation"),
    B("Denis Browne-type bar to hold feet in slight internal rotation"),
    B("<b>Contracture must be corrected before ambulation is allowed</b>"),
    SP(4),

    H3("Physiotherapy (Early/Mild Contracture)"),
    B("Ober stretches — sustained IT band stretching"),
    B("Hip abductor strengthening (gluteus medius)"),
    B("Core and hip flexor strengthening to improve biomechanics"),
    B("Foam rolling / soft tissue mobilization"),
    SP(4),

    H3("Pharmacological"),
    B("NSAIDs — reduce inflammation in IT band friction syndrome"),
    B("Corticosteroid injection — into IT band/bursa at lateral femoral condyle; ultrasound-guided"),
    SP(8),

    H2("B. Operative Treatment"),
    H3("1. Simple Fasciotomy (Minor Contracture)"),
    B("Fasciotomies around the hip and knee"),
    B("<b>High recurrence rate</b> — does not address severe contracture"),
    B("Only appropriate for minor, early contractures"),
    SP(6),

    H3("2. Ober-Yount Procedure (Moderate Contracture) — eTechnique 36.18"),
    P("Indicated for abduction and external rotation contractures:"),
    SP(3),
]

procedure_data = [
    ["Step", "Action"],
    ["1", "Patient lateral position; transverse incision medial and distal to ASIS, extending laterally above greater trochanter"],
    ["2", "Divide the iliopsoas tendon distally; excise 1 cm of it"],
    ["3", "Detach sartorius from ASIS; detach rectus femoris from AIIS; divide TFL from anterior border completely posteriorly"],
    ["4", "Detach gluteus medius, gluteus minimus, and short external rotators from the greater trochanter"],
    ["5", "Retract sciatic nerve posteriorly; open hip capsule from anterior to posterior, parallel to acetabular labrum"],
    ["6 (Yount)", "Lateral longitudinal incision just proximal to the femoral condyle"],
    ["7 (Yount)", "Divide IT band and fascia lata: posteriorly to biceps tendon, anteriorly to midline of thigh at 2.5 cm proximal to patella"],
    ["8 (Yount)", "Excise a segment of IT band and lateral intermuscular septum 5–8 cm long"],
    ["9", "By palpation confirm all tight bands have been divided"],
    ["Post-op", "Cast at 2 weeks; long-leg brace with pelvic band fitted with hip in corrected position"],
]

proc_s_bold = ParagraphStyle("PS_B", fontName="Helvetica-Bold", fontSize=9, leading=12)
proc_s_norm = ParagraphStyle("PS_N", fontName="Helvetica", fontSize=9, leading=12)
proc_styled = []
for i, row in enumerate(procedure_data):
    if i == 0:
        proc_styled.append([Paragraph(c, proc_s_bold) for c in row])
    else:
        proc_styled.append([Paragraph(row[0], proc_s_bold), Paragraph(row[1], proc_s_norm)])

cw = A4[0] - 4*cm
pt = Table(proc_styled, colWidths=[cw*0.15, cw*0.85], repeatRows=1)
pt.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#2e6da4")),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#f0f5fb"), colors.white]),
    ("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#b0c4de")),
    ("VALIGN", (0,0), (-1,-1), "TOP"),
    ("TOPPADDING", (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING", (0,0), (-1,-1), 6),
    ("RIGHTPADDING", (0,0), (-1,-1), 6),
    ("FONTCOLOR", (0,0), (-1,0), colors.white),
]))
story += [pt, SP(8)]

story += img_flowable("surgery1", width_cm=10,
    caption_text="Fig. 4 — Intraoperative view of IT band / fascia lata exposure during the Ober-Yount procedure. "
                 "The dense white fascial band is being released. (Campbell's Operative Orthopaedics 15th Ed)")

story += [SP(4)]
story += img_flowable("surgery2", width_cm=10,
    caption_text="Fig. 5 — Staged fascial release with planned incision line (blue) marking the "
                 "segment of IT band to be excised during the Yount procedure. "
                 "(Campbell's Operative Orthopaedics 15th Ed)")

story += [
    SP(8),
    H3("3. Campbell Technique (Severe Deformity) — eTechnique 36.19"),
    P("For severe cases requiring complete muscle release from the iliac wing:"),
    B("Incise along anterior half of iliac crest to ASIS and distally 5–10 cm on anterior thigh"),
    B("Divide superficial and deep fasciae to the iliac crest"),
    B("Strip origins of TFL, gluteus medius and minimus <b>subperiosteally</b> from iliac wing down to acetabulum"),
    B("Resect ASIS with origin of sartorius; allow to retract distally and posteriorly"),
    B("If hip cannot be hyperextended: divide hip capsule obliquely; last resort: iliopsoas tenotomy from lesser trochanter"),
    B("After complete correction: resect redundant portion of denuded ilium with osteotome"),
    B("<b>In young children:</b> preserve iliac physis — remove wedge of bone from iliac crest distal to physis; displace crest distally; fix with soft-tissue sutures"),
    B("<b>Post-op:</b> Hip spica in hyperextension + 10° abduction for 3–4 weeks; then mobilize on crutches; night splinting for months"),
    SP(8),

    H2("C. Surgical Management of Knee Deformities"),
]

knee_data = [
    ["Severity", "Procedure"],
    ["15–20° flexion contracture (young children)", "Posterior hamstring lengthening + capsulotomy"],
    [">20° or more severe", "Supracondylar extension osteotomy of the femur"],
    [">70° in growing children", "Division of IT band + hamstring tendons + posterior capsulotomy; skeletal traction via two tibial pins post-operatively; long-leg brace; supracondylar osteotomy as second stage if needed"],
    ["External tibial torsion", "Derotation osteotomy of tibia; correction of valgus as part of overall plan"],
]
kw = A4[0] - 4*cm
knee_styled = []
for i, row in enumerate(knee_data):
    if i == 0:
        knee_styled.append([Paragraph(c, proc_s_bold) for c in row])
    else:
        knee_styled.append([Paragraph(c, proc_s_norm) for c in row])
kt = Table(knee_styled, colWidths=[kw*0.4, kw*0.6], repeatRows=1)
kt.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#2e6da4")),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#f0f5fb"), colors.white]),
    ("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#b0c4de")),
    ("VALIGN", (0,0), (-1,-1), "TOP"),
    ("TOPPADDING", (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING", (0,0), (-1,-1), 6),
    ("RIGHTPADDING", (0,0), (-1,-1), 6),
    ("FONTCOLOR", (0,0), (-1,0), colors.white),
]))
story += [kt, SP(8)]

# ── 8. Summary Table ─────────────────────────────────────────────────────────
story += section_divider("8. Summary Table")

sum_headers = ["Aspect", "Key Points"]
sum_rows = [
    ("Anatomy", "Fascia lata condensation; arises from coccyx/sacrum/iliac crest; formed by TFL and gluteus maximus; inserts at Gerdy's tubercle"),
    ("Position re: hip", "LATERAL and ANTERIOR to hip joint — explains flexion + abduction deformity"),
    ("Primary etiology", "Poliomyelitis (frog position); injection fibrosis; prolonged malposition"),
    ("Key deformities", "Hip flexion-abduction-ER; genu valgum; knee flexion contracture; external tibial torsion; knee subluxation; LLD; pelvic obliquity; lumbar lordosis"),
    ("Mechanism at knee", "Acts as taut bowstring; gradually abducts and flexes tibia; external rotation from lateral distal attachment"),
    ("Diagnostic test", "Ober test — patient lateral; hip abducted then released; positive = limb remains abducted"),
    ("Non-operative", "Prevention only; traction is CONTRAINDICATED"),
    ("Minor surgery", "Simple fasciotomy (high recurrence)"),
    ("Moderate surgery", "Ober-Yount procedure (proximal hip release + distal IT band segment excision)"),
    ("Severe surgery", "Campbell technique (complete iliac wing muscle release ± iliac crest osteotomy)"),
    ("Knee surgery", "Hamstring lengthening; supracondylar osteotomy; IT band division + capsulotomy for severe cases"),
]

sum_cell_s = ParagraphStyle("SC", fontName="Helvetica", fontSize=9, leading=12)
sum_bold_s = ParagraphStyle("SB", fontName="Helvetica-Bold", fontSize=9, leading=12)
sw = A4[0] - 4*cm
sum_styled = [[Paragraph("<b>Aspect</b>", proc_s_bold), Paragraph("<b>Key Points</b>", proc_s_bold)]]
for a, k in sum_rows:
    sum_styled.append([Paragraph(a, sum_bold_s), Paragraph(k, sum_cell_s)])

st = Table(sum_styled, colWidths=[sw*0.28, sw*0.72], repeatRows=1)
st.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,0), colors.HexColor("#1a3a5c")),
    ("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#f0f5fb"), colors.white]),
    ("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#b0c4de")),
    ("VALIGN", (0,0), (-1,-1), "TOP"),
    ("TOPPADDING", (0,0), (-1,-1), 5),
    ("BOTTOMPADDING", (0,0), (-1,-1), 5),
    ("LEFTPADDING", (0,0), (-1,-1), 6),
    ("RIGHTPADDING", (0,0), (-1,-1), 6),
    ("FONTCOLOR", (0,0), (-1,0), colors.white),
]))
story += [st, SP(8)]

# ── References ───────────────────────────────────────────────────────────────
story += [
    HR(),
    H2("References"),
    B("Campbell's Operative Orthopaedics, 15th Edition (2026) — eBox 36.2; eTechniques 36.18, 36.19; pp. 1636–1643"),
    B("Miller's Review of Orthopaedics, 9th Edition — Flexion Contractures section"),
    B("Firestein & Kelley's Textbook of Rheumatology — Ober test; Physical Examination chapter"),
    B("Gray's Anatomy for Students — Iliotibial Band anatomy"),
    SP(4),
    Paragraph("Generated by Orris Medical AI · July 2026", source_style),
]

# ═══════════════════════════════════════════════════════════════════════════
# BUILD PDF
# ═══════════════════════════════════════════════════════════════════════════
def add_page_number(canvas, doc):
    canvas.saveState()
    canvas.setFont("Helvetica", 8)
    canvas.setFillColor(colors.HexColor("#888888"))
    canvas.drawRightString(A4[0] - 2*cm, 1.2*cm, f"Page {doc.page}")
    canvas.drawString(2*cm, 1.2*cm, "IT Band Contracture — Orris Medical AI")
    canvas.restoreState()

output_path = os.path.join(OUTPUT_DIR, "IT_Band_Contracture.pdf")
doc = SimpleDocTemplate(
    output_path,
    pagesize=A4,
    rightMargin=2*cm,
    leftMargin=2*cm,
    topMargin=2.5*cm,
    bottomMargin=2*cm,
    title="IT Band Contracture",
    author="Orris Medical AI",
    subject="Iliotibial Band Contracture — Orthopedics",
)
doc.build(story, onFirstPage=add_page_number, onLaterPages=add_page_number)
print(f"PDF created: {output_path}")
Running Command

cd /home/daytona/workspace/it_band_pdf && python3 create_pdf.py 2>&1

Running Command

ls -lh /home/daytona/workspace/it_band_pdf/IT_Band_Contracture.pdf

Your PDF is ready — 11 MB, fully formatted with all content and images:

IT Band Contracture

PDF Document · PDF

What's included in the PDF:
  • Title page with full topic header and source citations
  • 8 numbered sections with color-coded headings (navy/blue theme):
    1. Anatomy of the IT Band
    2. Etiology and Causes (paralytic, fibrotic, postural, congenital)
    3. Mechanism of Deformity (hip bowstring + knee bowstring)
    4. Deformities table (eBox 36.2 from Campbell's)
    5. Signs and Symptoms with Ober test details
    6. Investigations (clinical, X-ray, MRI, US, CT)
    7. Treatment (non-operative → fasciotomy → Ober-Yount → Campbell technique → knee surgery tables)
    8. Summary table
  • 5 medical illustrations from Campbell's Operative Orthopaedics (hip anatomy, knee osteotomy, Ober test, two surgical procedure images)
  • Page numbers and header/footer on every page
  • Sourced from Campbell's Orthopaedics 15th Ed 2026, Miller's Review, Firestein & Kelley's Rheumatology, and Gray's Anatomy
This is a shared conversation. Sign in to Orris to start your own chat.