-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
2,339 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ docs | |
vendor | ||
coverage | ||
/.idea | ||
/output.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
use Kduma\PdfImposition\LayoutGenerators\Markers\HeadersMarkings; | ||
use Kduma\PdfImposition\LayoutGenerators\Markers\PrinterBoxCutMarkings; | ||
use Kduma\PdfImposition\LayoutGenerators\AutoGridPageLayoutGenerator; | ||
use Kduma\PdfImposition\DTO\PageMargins; | ||
use Kduma\PdfImposition\DTO\PageSize; | ||
use Kduma\PdfImposition\PdfImposer; | ||
use Kduma\PdfImposition\PdfSource; | ||
use Kduma\PdfImposition\DTO\Size; | ||
|
||
require __DIR__.'/vendor/autoload.php'; | ||
|
||
$cardSize = Size::make(90, 50); | ||
$pageSize = PageSize::fromName('A4'); | ||
$pageMargins = PageMargins::make(); | ||
|
||
$layoutGenerator = new AutoGridPageLayoutGenerator($cardSize, 0, 0, $pageSize, $pageMargins); | ||
$layoutGenerator->center(); | ||
|
||
$layoutGenerator = new PrinterBoxCutMarkings($layoutGenerator); | ||
$layoutGenerator->setPrintEvery(5); | ||
|
||
$layoutGenerator = new HeadersMarkings($layoutGenerator, 'Page {PAGENO}, Sheet {SHEET}'); | ||
|
||
$PdfImposer = new PdfImposer($layoutGenerator); | ||
|
||
$cards = (new PdfSource)->read(__DIR__ . '/tests/test_input.pdf', true); | ||
$PdfImposer->export($cards, 'output.pdf'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
|
||
namespace Kduma\PdfImposition\DTO; | ||
|
||
|
||
class Box | ||
{ | ||
/** | ||
* @var Point | ||
*/ | ||
protected Point $point; | ||
|
||
/** | ||
* @var Size | ||
*/ | ||
protected Size $size; | ||
|
||
/** | ||
* Box constructor. | ||
* | ||
* @param Point $point | ||
* @param Size $size | ||
*/ | ||
public function __construct(Point $point, Size $size) | ||
{ | ||
$this->point = $point; | ||
$this->size = $size; | ||
} | ||
|
||
/** | ||
* @param Point $point | ||
* @param Size $size | ||
* | ||
* @return Box | ||
*/ | ||
public static function make(Point $point, Size $size): Box | ||
{ | ||
return new Box($point, $size); | ||
} | ||
|
||
/** | ||
* @return Point | ||
*/ | ||
public function getPoint(): Point | ||
{ | ||
return $this->point; | ||
} | ||
|
||
/** | ||
* @return Size | ||
*/ | ||
public function getSize(): Size | ||
{ | ||
return $this->size; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
|
||
namespace Kduma\PdfImposition\DTO; | ||
|
||
|
||
class DuplexPdfPage | ||
{ | ||
protected PdfPage $front; | ||
protected PdfPage $back; | ||
|
||
public function __construct(PdfPage $front, PdfPage $back) | ||
{ | ||
$this->front = $front; | ||
$this->back = $back; | ||
} | ||
|
||
public static function make(PdfPage $front, PdfPage $back): DuplexPdfPage | ||
{ | ||
return new DuplexPdfPage($front, $back); | ||
} | ||
|
||
/** | ||
* @return PdfPage | ||
*/ | ||
public function getFront(): PdfPage | ||
{ | ||
return $this->front; | ||
} | ||
|
||
/** | ||
* @return PdfPage | ||
*/ | ||
public function getBack(): PdfPage | ||
{ | ||
return $this->back; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?php | ||
|
||
|
||
namespace Kduma\PdfImposition\DTO; | ||
|
||
|
||
class Line | ||
{ | ||
/** | ||
* @var Point | ||
*/ | ||
protected Point $start; | ||
|
||
/** | ||
* @var Point | ||
*/ | ||
protected Point $end; | ||
|
||
/** | ||
* @var float | ||
*/ | ||
protected float $width; | ||
|
||
/** | ||
* Line constructor. | ||
* | ||
* @param Point $start | ||
* @param Point $end | ||
* @param float $width | ||
*/ | ||
public function __construct(Point $start, Point $end, float $width) | ||
{ | ||
$this->start = $start; | ||
$this->end = $end; | ||
$this->width = $width; | ||
} | ||
|
||
/** | ||
* @param Point $start | ||
* @param Point $end | ||
* @param float $width | ||
* | ||
* @return Line | ||
*/ | ||
public static function make(Point $start, Point $end, float $width): Line | ||
{ | ||
return new Line($start, $end, $width); | ||
} | ||
|
||
/** | ||
* @param Point $start | ||
* @param float $length | ||
* @param float $width | ||
* | ||
* @return Line | ||
*/ | ||
public static function horizontal(Point $start, float $length, float $width): Line | ||
{ | ||
return new Line($start, $start->add($length, 0), $width); | ||
} | ||
|
||
/** | ||
* @param Point $start | ||
* @param float $length | ||
* @param float $width | ||
* | ||
* @return Line | ||
*/ | ||
public static function vertical(Point $start, float $length, float $width): Line | ||
{ | ||
return new Line($start, $start->add(0, $length), $width); | ||
} | ||
|
||
/** | ||
* @param Point $point | ||
* @param float $width | ||
* | ||
* @return Line | ||
*/ | ||
public static function dot(Point $point, float $width): Line | ||
{ | ||
return new Line($point, $point, $width); | ||
} | ||
|
||
/** | ||
* @return Point | ||
*/ | ||
public function getStart(): Point | ||
{ | ||
return $this->start; | ||
} | ||
|
||
/** | ||
* @return Point | ||
*/ | ||
public function getEnd(): Point | ||
{ | ||
return $this->end; | ||
} | ||
|
||
/** | ||
* @return float | ||
*/ | ||
public function getWidth(): float | ||
{ | ||
return $this->width; | ||
} | ||
} |
Oops, something went wrong.