Saltar a contenido

Poster Engine — Convoca Enroll

Architecture: HTML → PDF → Image

En lugar de componer las imágenes píxel a píxel con Imagick, el motor v3 sigue un proceso de calidad editorial:

Activity Data → HTML/CSS Template → mPDF → PNG/WebP

Why This Approach

  • CSS3 native: Flexbox, Grid, gradients, shadows, border-radius — no manual coordinate calculations
  • Google Fonts: Load any font via @import url(...) without TTF files on the server
  • Maintainable: Edit posters by modifying HTML/CSS files, not PHP array logic
  • Clean rasterization: Imagick only handles mechanical PDF→PNG conversion (DPI, resize, export)

Pipeline Details

  1. Pass 1 — HTML Compilation (compile_html())
  2. Reads PHP template from templates/html/{slug}.php
  3. Injects activity data as extracted variables
  4. Returns full HTML document with <style> block

  5. Pass 2 — PDF Rendering (html_to_pdf())

  6. Uses mpdf/mpdf v8 with format set to exact pixel dimensions
  7. No margins, no page breaks
  8. Temporary PDF stored in uploads convoca-temp/

  9. Pass 3 — Rasterization (pdf_to_image())

  10. Opens PDF page 1 with Imagick at ~360 DPI
  11. Resizes to exact format dimensions (Lanczos filter)
  12. Strips metadata, sets quality (92% for JPEG/WebP)
  13. Deletes temporary PDF

Template Variables

All PHP templates in templates/html/ receive: