# pdfcalendarbuilder **Repository Path**: mirrors_a-schild/pdfcalendarbuilder ## Basic Information - **Project Name**: pdfcalendarbuilder - **Description**: PHP library to generate pdf with monthly calendars and autosizing - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2026-03-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # PDFCalendarBuilder Generate pdf month calendars with autoscaling/sizing With the addMonth() introduced in 1.0.8 you can generate a PDF containing multiple months. Each month will be on it's own page then. ## Unique features - The class can try to put everything on one page - In an normal calendar, all rows have the same height - This library can shrink/expand rows, so everything fits on one page. See setResizeRowHeightsIfNeeded(true/false); - If this is not enough, it can reduce the font size until everything fits on one page. See setShrinkFontSizeIfNeeded(true/false); ## Additional options - **Full time display**: Show times as `9:00` instead of `9h` with `setShowFullTime(true)` - **Custom grid height**: Override the auto-calculated grid height with `overrideGridHeight($height)`, useful when embedding the calendar in a larger PDF layout - **End time display**: Show entry end times with `setPrintEndTime(true)` - **Categories**: Define categories with `addCategory($id, $name, $textColor, $bgColor)` and assign entries via `addEntryCategory()`. Call `printCategories()` before `buildCalendar()` to render a color legend at the bottom of the page. - **Week start**: Set Monday as the first day of the week with `setWeekStarts(1)` (default is 0 for Sunday) - **Font sizes**: Customize with `setTitleFontSize()`, `setHeaderFontSize()`, `setNumberFontSize()`, `setEventFontSize()`, `setCategoryFontSize()` ## Usage: In your composer.json add the dependency: ``` "require": { "php": "^8.2", "a-schild/pdfcalendarbuilder": ">=1.0.16", } ``` ### Creating the class and generate calendar ``` $cal = new aschild\PDFCalendarBuilder\CalendarBuilder(1, 2019, "Calendar title", true, 'mm', 'A4'); $cal->startPDF(); $cal->addEntry($startDate, $endDate, "Entry 1", "#000000", "#fffff"); $cal->buildCalendar(); $cal->Output("calendar.pdf", "I"); ``` ### Creating the class and generate calendar for 3 months (Required version 1.0.7 or higher) ``` $cal = new aschild\PDFCalendarBuilder\CalendarBuilder(1, 2019, "Calendar title Jan", true, 'mm', 'A4'); $cal->startPDF(); $cal->addEntry($startDate1, $endDate1, "Entry 1", "#000000", "#ffffff"); $cal->buildCalendar(); $cal->addMonth(2, 2019, "Title for Feb"); $cal->addEntry($startDate2, $endDate2, "Entry 1", "#000000", "#ffffff"); $cal->buildCalendar(); $cal->addMonth(3, 2019, "Title for March"); $cal->addEntry($startDate3, $endDate3, "Entry 1", "#000000", "#ffffff"); $cal->buildCalendar(); $cal->Output("calendar.pdf", "I"); ``` ## Examples - Empty calendar, no entries, just a month grid ![Empty calendar ](doc/img/calendar-empty.png) - Overflowing boxes in normal libraries ![Box overflow in normal calendars](doc/img/calendar-overflow.png) - Resize row heights to adapt space usage ![Resize rows height](doc/img/calendar-resize-row2.png) - Resize row heights and shrink font size if needed ![Resize rows and shrink font](doc/img/calendar-resize-rows-shrink-fontsize.png) - Day spanning events ![Events which span days](doc/img/calendar-day-spanning.png) (C) 2019 - 2026 A.Schild