diff --git a/README.md b/README.md index 0a89806..1e25bb0 100644 --- a/README.md +++ b/README.md @@ -13,15 +13,82 @@ This is a simple [FPDF](www.fpdf.org) and [Avery](www.avery.com/templates) templ - Avery 8160 ## To-Do Code -- Fix label centering (Avery 5162) -- Match label sizing (Avery 5162) +N/A # Usage See the documentation below or `index.php` or actual implementations. -TBD -# Notes -N/A +## Setup +```PHP +// Import required files +require("FPDF.class.php"); +require("AveryTemplates.class.php"); + +// Instantiate class (See supported Avery templates above) +$pdf = new amattu\Avery_5160(); + +// Set default properties +$pdf->SetTitle("FPDF Template Example"); +$pdf->AddPage("P", "Letter"); +$pdf->SetFont('Helvetica', '', 11); // Font optional +$pdf->SetTextColor(25, 25, 25); // Color optional + +// Build PDF +$pdf->build(); + +// Output PDF +$pdf->Output("I", "Labels.pdf"); +``` +## add(array $lines, int $row = 0, int $col = 0) +This function adds a new label to the list of labels to be produced. There is currently no way to revoke a label once it has added. +```PHP +/** + * Add a single label to the PDF + * + * @param array $lines an array of label liens + * @param integer $row optional desired insert row + * @param integer $col optional diesired intert column + * @throws TypeError + * @throws BadValueException + * @author Alec M. + * @date 2021-09-05T13:49:28-040 + */ +public function add(array $lines, int $row = 0, int $col = 0) : void; +``` + +Usage +```PHP +$lines = Array( + "Line 1", + "Line 2", + "Line 3", + "Line 4" +); + +$pdf->add($lines); +``` + +## build() +```PHP +/** + * Build the completed PDF with labels + * + * NOTE: + * (1) To save resources, no PDF is built until + * this function is called. + * + * @return void + * @throws InvalidStateException + * @author Alec M. + * @date 2021-09-05T13:50:58-040 + */ +public function build() : void; +``` + +Usage +```PHP +$pdf->build(); +``` # Requirements & Dependencies - FPDF 1.81 Minimum [http://www.fpdf.org/] diff --git a/index.php b/index.php index 9aa3a92..596dce4 100644 --- a/index.php +++ b/index.php @@ -7,21 +7,17 @@ */ // Files -require(dirname(__FILE__) . "/classes/fpdf.class.php"); +require("FPDF.class.php"); require("AveryTemplates.class.php"); // Variables $pdf = new amattu\Avery_5160(); // PDF Properties -$pdf->SetAutoPageBreak(false); -$pdf->AliasNbPages(); -$pdf->SetTopMargin(13); -$pdf->SetTitle("FPDF Avery Templates"); +$pdf->SetTitle("FPDF Template Example"); $pdf->AddPage("P", "Letter"); $pdf->SetFont('Helvetica', '', 11); $pdf->SetTextColor(25, 25, 25); -$pdf->SetLineWidth(0.1); // Build addTestUsers($pdf, ($_GET && isset($_GET['count']) && is_numeric($_GET['count']) && $_GET['count'] < 1001 ? $_GET['count'] : 35));