Set opacity is not working
divsbhalala opened this issue · 9 comments
divsbhalala commented
Set opacity is not working while adding image into watermark task
Please test here https://www.tweak.com/add-watermark-pdf/
divsbhalala commented
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;
}
maztch commented
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?
divsbhalala commented
divsbhalala commented
Product List Instruction.pdf
And Using this PDF
divsbhalala commented
Product-List-Instruction_9475640_05-12-2017_watermark_image.pdf
Ia m getting this PDF as output
maztch commented
Ok, it's a cmyk image. Your code is correct. We are solving it on our api servers.
divsbhalala commented
Ok thanks
maztch commented
Done, try it now.
divsbhalala commented
ok let me check