Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
amattu2 committed Sep 6, 2021
1 parent a933cac commit 6ed213e
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 11 deletions.
77 changes: 72 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. <https://amattu.com>
* @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. <https://amattu.com>
* @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/]
Expand Down
8 changes: 2 additions & 6 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 6ed213e

Please sign in to comment.