Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable to change color of watermark text #1866

Closed
Ian-Robinson1 opened this issue May 2, 2023 · 3 comments
Closed

Variable to change color of watermark text #1866

Ian-Robinson1 opened this issue May 2, 2023 · 3 comments

Comments

@Ian-Robinson1
Copy link

Please describe the new functionality as best as you can.

The watermark text color cannot be changed with a variable when a pdf is created. Currently, the only way to change it is to directly edit src/Mpdf.php line 10598, such as:

$this->SetTColor($this->colorConverter->convert(0, $this->PDFAXwarnings));

To:

$this->SetTColor($this->colorConverter->convert('red', $this->PDFAXwarnings));

Being able to change the color with a variable would be very helpful

@v1har
Copy link

v1har commented May 2, 2023

Here is a possible solution, please add it to next patch/version. @finwe

1. Need to define the variable:

var $watermark_color;

2. Set default in _construct:

$this->watermark_color = 0;

3. Create setter function

function setWatermarkColor($watermark_color = 0){
$this->watermark_color = $watermark_color;
}

4. Use variable in line 10484

$this->SetTColor($this->colorConverter->convert($this->watermark_color, $this->PDFAXwarnings));

@finwe
Copy link
Member

finwe commented May 2, 2023

@v1har Why don't you propose a pull request directly?

But rather than stomping more and more public properties to the Mpdf class, why not introduce a method

public function setWatermark(Mpdf\Watermark $watermark): self

with the Watermark object containing all details of the watermark?

@v1har
Copy link

v1har commented May 2, 2023

@finwe I am not a pro user of github so I thought it's easier to tell you the idea so you can implement / add pull request. I just tried to help because I need this functionality too. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants