180 lines
3.2 KiB
Markdown
180 lines
3.2 KiB
Markdown
# pdfCreator
|
|
|
|
Projekt na generovanie PDF suborov pomocou `tecnickcom/tc-lib-pdf`.
|
|
|
|
## Slovensky
|
|
|
|
### Inicializacia po cistom clone
|
|
|
|
Po novom clone repozitara alebo po zmazani adresara `vendor` najprv nainstaluj hlavne Composer zavislosti:
|
|
|
|
```powershell
|
|
composer install
|
|
```
|
|
|
|
Samotny `composer install` nevygeneruje PDF font definicie, ktore `tc-lib-pdf-font` nacitava pri renderovani. Bez nich moze aplikacia spadnut napr. s chybou:
|
|
|
|
```text
|
|
unable to read file: helvetica.json
|
|
```
|
|
|
|
Fonty vygeneruj cez utilitny balicek v `vendor/tecnickcom/tc-lib-pdf-font`:
|
|
|
|
```powershell
|
|
cd vendor\tecnickcom\tc-lib-pdf-font\util
|
|
composer install
|
|
|
|
cd ..
|
|
composer install
|
|
|
|
cd util
|
|
php bulk_convert.php
|
|
```
|
|
|
|
Po uspesnom behu by mal existovat napr. subor:
|
|
|
|
```text
|
|
vendor\tecnickcom\tc-lib-pdf-font\target\fonts\core\helvetica.json
|
|
```
|
|
|
|
### Skripty
|
|
|
|
Hello world PDF:
|
|
|
|
```powershell
|
|
php src\hello-world.php
|
|
```
|
|
|
|
Bodkovany papier pre technicke nacrtky:
|
|
|
|
```powershell
|
|
php src\dotted.php
|
|
```
|
|
|
|
Volitelne parametre bodkovaneho papiera:
|
|
|
|
```powershell
|
|
php src\dotted.php --dot-size=0.4 --space=5
|
|
```
|
|
|
|
Vystup z CLI sa ulozi do:
|
|
|
|
```text
|
|
output\dotted.pdf
|
|
```
|
|
|
|
### Web spustenie
|
|
|
|
Hello world PDF:
|
|
|
|
```text
|
|
http://localhost/pdfcreator/src/hello-world.php
|
|
```
|
|
|
|
Bodkovany papier inline v prehliadaci:
|
|
|
|
```text
|
|
http://localhost/pdfcreator/src/dotted.php?dot-size=0.4&space=5
|
|
```
|
|
|
|
### Overenie
|
|
|
|
Syntax PHP skriptov:
|
|
|
|
```powershell
|
|
php -l src\hello-world.php
|
|
php -l src\dotted.php
|
|
```
|
|
|
|
### Poznamka k `vendor` a `output`
|
|
|
|
Adresare `vendor` a `output` su ignorovane v Gite. Ak sa `vendor` zmaze alebo sa projekt inicializuje na inom stroji, treba instalaciu zavislosti a generovanie fontov zopakovat.
|
|
|
|
## English
|
|
|
|
### Fresh Repository Setup
|
|
|
|
After cloning the repository, or after deleting the `vendor` directory, install the main Composer dependencies first:
|
|
|
|
```powershell
|
|
composer install
|
|
```
|
|
|
|
The root `composer install` does not generate the PDF font definition files used by `tc-lib-pdf-font` at runtime. Without them, the application may fail with an error such as:
|
|
|
|
```text
|
|
unable to read file: helvetica.json
|
|
```
|
|
|
|
Generate the fonts through the utility package inside `vendor/tecnickcom/tc-lib-pdf-font`:
|
|
|
|
```powershell
|
|
cd vendor\tecnickcom\tc-lib-pdf-font\util
|
|
composer install
|
|
|
|
cd ..
|
|
composer install
|
|
|
|
cd util
|
|
php bulk_convert.php
|
|
```
|
|
|
|
After a successful run, this file should exist:
|
|
|
|
```text
|
|
vendor\tecnickcom\tc-lib-pdf-font\target\fonts\core\helvetica.json
|
|
```
|
|
|
|
### Scripts
|
|
|
|
Hello world PDF:
|
|
|
|
```powershell
|
|
php src\hello-world.php
|
|
```
|
|
|
|
Dotted paper for technical sketches:
|
|
|
|
```powershell
|
|
php src\dotted.php
|
|
```
|
|
|
|
Optional dotted paper parameters:
|
|
|
|
```powershell
|
|
php src\dotted.php --dot-size=0.4 --space=5
|
|
```
|
|
|
|
CLI output is saved to:
|
|
|
|
```text
|
|
output\dotted.pdf
|
|
```
|
|
|
|
### Web Usage
|
|
|
|
Hello world PDF:
|
|
|
|
```text
|
|
http://localhost/pdfcreator/src/hello-world.php
|
|
```
|
|
|
|
Dotted paper rendered inline in the browser:
|
|
|
|
```text
|
|
http://localhost/pdfcreator/src/dotted.php?dot-size=0.4&space=5
|
|
```
|
|
|
|
### Verification
|
|
|
|
Check PHP syntax:
|
|
|
|
```powershell
|
|
php -l src\hello-world.php
|
|
php -l src\dotted.php
|
|
```
|
|
|
|
### Notes About `vendor` and `output`
|
|
|
|
The `vendor` and `output` directories are ignored by Git. If `vendor` is deleted or the project is initialized on another machine, repeat the dependency installation and font generation steps.
|