filippotoso / pdf-watermarker

Simple PDF Watermarker with Laravel support
Other
6 stars 7 forks source link

Multi #3

Closed APTEMOH closed 1 year ago

APTEMOH commented 1 year ago

Hi!

Please help!

`use FilippoToso\PdfWatermarker\Support\Pdf; use FilippoToso\PdfWatermarker\Watermarks\ImageWatermark; use FilippoToso\PdfWatermarker\Watermarks\TextWatermark; use FilippoToso\PdfWatermarker\PdfWatermarker; use FilippoToso\PdfWatermarker\Support\Position;

// Specify path to the existing pdf $pdf = new Pdf('cashback.pdf');

for ($i=1; $i <= 3; $i++) {

if($i == 1){
    // Set the position of the watermark including optional X/Y offsets
    $position = new Position(Position::TOP_CENTER, -20, -20);
}elseif($i == 2){
    // Set the position of the watermark including optional X/Y offsets
    $position = new Position(Position::MIDDLE_CENTER, -20, -20);
}elseif($i == 3){
    // Set the position of the watermark including optional X/Y offsets
    $position = new Position(Position::BOTTOM_CENTER, -20, -20);
}

// Specify path to image. The image must have a 96 DPI resolution.
//$watermark = new ImageWatermark('watermark.png'); 
$watermark = new TextWatermark('watermark fuck', 'Verdana.ttf', 80, 10, '#c53c0aad'); 

// Create a new watermarker
$watermarker = new PDFWatermarker($pdf, $watermark); 

// All possible positions can be found in Position::options
$watermarker->setPosition($position);

// Save the new PDF to its specified location
$watermarker->save('output.pdf');

}`

Why don't work?

Thanks!

filippotoso commented 1 year ago

Please define "Why don't work?"

APTEMOH commented 1 year ago

Please define "Why don't work?"

On output.pdf - one watermark text

I want ten or 3 on my code example.

APTEMOH commented 1 year ago

Pls help!

filippotoso commented 1 year ago

You have to use temporary files if you want to watermark a file multiple times.

Copy the source into a temporary file. Use it as bot input and output in the loop and then copy it in the final destination.