diff --git a/samples/watermark_basic_image.php b/samples/watermark_basic_image.php new file mode 100644 index 0000000..2c5353b --- /dev/null +++ b/samples/watermark_basic_image.php @@ -0,0 +1,29 @@ +addFile('/path/to/file/document.pdf'); + +$watermakImage = $myTask->addElementFile('/path/to/image/image.png'); + +// set mode to image +$myTask->setMode("image"); + +// set the image +$myTask->setImageFile($watermakImage); + +// process files +$myTask->execute(); + +// and finally download the unlocked file. If no path is set, it will be downloaded on current folder +$myTask->download(); \ No newline at end of file diff --git a/src/Element.php b/src/Element.php index 0e7da7a..1f3fab7 100644 --- a/src/Element.php +++ b/src/Element.php @@ -119,6 +119,7 @@ class Element public $bold = false; + /** * string * @var @@ -260,4 +261,24 @@ public function setHorizontalPositionAdjustment($horizontal_position_adjustment) $this->horizontal_position_adjustment = $horizontal_position_adjustment; return $this; } + + /** + * @param mixed $server_filename + * @return Element + */ + public function setServerFilename($server_filename) + { + $this->server_filename = $server_filename; + return $this; + } + + /** + * @param File $file + * @return Element + */ + public function setFile($file) + { + $this->server_filename = $file->getServerFilename(); + return $this; + } } \ No newline at end of file diff --git a/src/Task.php b/src/Task.php index 281cb04..9e94af3 100644 --- a/src/Task.php +++ b/src/Task.php @@ -198,6 +198,24 @@ public function uploadFile($task, $filepath) return new File($response->body->server_filename, basename($filepath)); } + /** + * @param string $filePath + * @return File + */ + public function addElementFile($filePath) + { + return $this->uploadFile($this->task, $filePath); + } + + /** + * @param string $url + * @return File + */ + public function addElementFileFromUrl($url) + { + return $this->uploadUrl($this->task, $url); + } + /** * @return Task */ diff --git a/src/WatermarkTask.php b/src/WatermarkTask.php index 1a1fffe..484a792 100644 --- a/src/WatermarkTask.php +++ b/src/WatermarkTask.php @@ -20,7 +20,7 @@ class WatermarkTask extends Task /** * @var string */ - public $text; + public $text; /** * @var strig @@ -147,6 +147,15 @@ public function setImage($image) return $this; } + /** + * @param File $image + */ + public function setImageFile(File $imageFile) + { + $this->image = $imageFile->getServerFilename(); + return $this; + } + /** * @param string $pages */