Closed divsbhalala closed 6 years ago
Here is my code
public function addWatermarkToPdf($files, $watermark_type='text', $watermark_text='', $watermark_image='', $fontSize=18, $fontColor='#000',
$fontFamily='courier', $range='all', $horizontalPosition='left', $verticalPosition='bottom', $opacity=50, $page_layer_pos='bottom', $watermark_rotation=35, $rotation=[], $name, $pkjFileName){
$watermark = new WatermarkTask( $this->publicKey, $this->secretKey );
foreach ($files as $key => $file) {
$fileA = $watermark->addFile($file);
$fileA->setRotation($rotation[$key] ? $rotation[$key] : 0);
}
// $fileA = $watermark->addFile($pdfFilePath);
if($watermark_type=='text'){
$watermark->setText($watermark_text);
$watermark->setFontFamily($fontFamily);
$watermark->setFontSize($fontSize);
$watermark->setFontColor($fontColor);
}
else if(!empty($watermark_image)){
$watermark->setMode('image');
//$watermark->setImage($img);
$image = $watermark->addFile($watermark_image);
$watermark->setImage($image->server_filename);
}
// $watermark->setMosaic(true);
$watermark->setPages($range);
$watermark->setHorizontalPosition($horizontalPosition);
$watermark->setVerticalPosition($verticalPosition);
$watermark->setTransparency($opacity);
// $watermark->setOpacity($opacity);
$watermark->setLayer($page_layer_pos);
$watermark->setRotation($watermark_rotation);
$watermark->setOutputFilename($name);
$watermark->setPackagedFilename($pkjFileName);
// print_r($watermark);
$watermark->execute();
//print_r($watermark);
return $watermark;
}
Sorry, but I checked it right now and it's working...in our api and in your implementation.
What image are you using? Can you add it here?
I am using this image
Product List Instruction.pdf And Using this PDF
Product-List-Instruction_9475640_05-12-2017_watermark_image.pdf Ia m getting this PDF as output
Ok, it's a cmyk image. Your code is correct. We are solving it on our api servers.
Ok thanks
Done, try it now.
ok let me check
Set opacity is not working while adding image into watermark task Please test here https://www.tweak.com/add-watermark-pdf/