How ramdhanrs/codeigniter-pdf-generator-library works
Project type and purpose
• This is an “open-source tool” / CodeIgniter library whose sole responsibility is to take a CI view, hand the rendered HTML to the domPDF engine, and stream back a PDF to the client.
• It is not a full-stack app—it plugs into an existing CodeIgniter MVC app.
High-level components
a. CodeIgniter Application
• Controllers (your app controllers invoking the PDF library)
• Views (HTML templates to be converted)
b. PDF Generator Library (pdf.php)
• A CI library wrapper that provides a simple API: load_view(), render(), stream()
c. domPDF Engine
• External PHP library that transforms HTML+CSS into PDF bytes
d. Web Server / PHP Runtime
• Apache/Nginx + PHP executing CI + pdf.php + dompdf
e. Client Browser
• Receives the PDF stream as an HTTP response
Component interactions and data flow
1. Client issues HTTP request → Web Server
2. CodeIgniter Router dispatches to Controller
3. Controller loads PDF library ($this->load->library('pdf'))
4. Controller calls pdf->load_view('some_view', $data)
– CI View parser generates HTML output
5. PDF library passes HTML string into domPDF API
6. domPDF processes HTML/CSS → internal layout → PDF binary
7. PDF library calls dompdf->stream("filename.pdf")
8. PDF bytes sent as HTTP response with PDF headers → Client
Architectural patterns / principles
• Single-Responsibility: pdf.php only handles PDF orchestration, not view logic.
• Adapter/Wrapper: pdf.php adapts domPDF’s API to a CodeIgniter-friendly interface.
• Modular & Pluggable: the library lives in CI’s libraries directory and can be replaced/updated independently.