-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Watermark objects. Color for watermark text (Closes #1866)
- Loading branch information
Showing
5 changed files
with
197 additions
and
1 deletion.
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
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,66 @@ | ||
<?php | ||
|
||
namespace Mpdf; | ||
|
||
class Watermark | ||
{ | ||
|
||
/** @var string */ | ||
private $text; | ||
|
||
/** @var int */ | ||
private $size; | ||
|
||
/** @var int */ | ||
private $angle; | ||
|
||
/** @var mixed */ | ||
private $color; | ||
|
||
/** @var float */ | ||
private $alpha; | ||
|
||
/** @var string */ | ||
private $font; | ||
|
||
public function __construct($text, $size = 96, $angle = 45, $color = 0, $alpha = 0.2, $font = null) | ||
{ | ||
$this->text = $text; | ||
$this->size = $size; | ||
$this->angle = $angle; | ||
$this->color = $color; | ||
$this->alpha = $alpha; | ||
$this->font = $font; | ||
} | ||
|
||
public function getText() | ||
{ | ||
return $this->text; | ||
} | ||
|
||
public function getSize() | ||
{ | ||
return $this->size; | ||
} | ||
|
||
public function getAngle() | ||
{ | ||
return $this->angle; | ||
} | ||
|
||
public function getColor() | ||
{ | ||
return $this->color; | ||
} | ||
|
||
public function getAlpha() | ||
{ | ||
return $this->alpha; | ||
} | ||
|
||
public function getFont() | ||
{ | ||
return $this->font; | ||
} | ||
|
||
} |
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,72 @@ | ||
<?php | ||
|
||
namespace Mpdf; | ||
|
||
class WatermarkImage | ||
{ | ||
|
||
const SIZE_DEFAULT = 'D'; | ||
const SIZE_FIT_PAGE = 'P'; | ||
const SIZE_FIT_FRAME = 'F'; | ||
const POSITION_CENTER_PAGE = 'P'; | ||
const POSITION_CENTER_FRAME = 'F'; | ||
|
||
/** @var string */ | ||
private $path; | ||
|
||
/** @var mixed */ | ||
private $size; | ||
|
||
/** @var mixed */ | ||
private $position; | ||
|
||
/** @var float */ | ||
private $alpha; | ||
|
||
/** @var bool */ | ||
private $behindContent; | ||
|
||
/** @var string */ | ||
private $alphaBlend; | ||
|
||
public function __construct($path, $size = self::SIZE_DEFAULT, $position = self::POSITION_CENTER_PAGE, $alpha = -1, $behindContent = false, $alphaBlend = 'Normal') | ||
{ | ||
$this->path = $path; | ||
$this->size = $size; | ||
$this->position = $position; | ||
$this->alpha = $alpha; | ||
$this->behindContent = $behindContent; | ||
$this->alphaBlend = $alphaBlend; | ||
} | ||
|
||
public function getPath() | ||
{ | ||
return $this->path; | ||
} | ||
|
||
public function getSize() | ||
{ | ||
return $this->size; | ||
} | ||
|
||
public function getPosition() | ||
{ | ||
return $this->position; | ||
} | ||
|
||
public function getAlpha() | ||
{ | ||
return $this->alpha; | ||
} | ||
|
||
public function isBehindContent() | ||
{ | ||
return $this->behindContent; | ||
} | ||
|
||
public function getAlphaBlend() | ||
{ | ||
return $this->alphaBlend; | ||
} | ||
|
||
} |
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,26 @@ | ||
<?php | ||
|
||
namespace Issues; | ||
|
||
class Issue1866Test extends \Mpdf\BaseMpdfTest | ||
{ | ||
|
||
public function testWatermark() | ||
{ | ||
$this->mpdf->SetWatermarkText(new \Mpdf\Watermark('Watermark text', 100, 90, '#996633', 0.4)); | ||
|
||
$this->mpdf->WriteHtml('Example text'); | ||
|
||
$this->assertStringStartsWith('%PDF-', $this->mpdf->OutputBinaryData()); | ||
} | ||
|
||
public function testWatermarkImage() | ||
{ | ||
$this->mpdf->SetWatermarkImage(new \Mpdf\WatermarkImage('../data/img/issue1609.png', 100, 90, '#996633', 0.4)); | ||
|
||
$this->mpdf->WriteHtml('Example text'); | ||
|
||
$this->assertStringStartsWith('%PDF-', $this->mpdf->OutputBinaryData()); | ||
} | ||
|
||
} |