如何在PHP中上传带有水印和密码的pdf文件? 那个上传pdf文件的时候可以吗?

    $fileName = basename($_FILES["file"]["name"]);

    $targetFilePath = $targetDir . $fileName;


    $fileType = pathinfo($targetFilePath,PATHINFO_EXTENSION);


    if(isset($_POST["submit"]) && !empty($_FILES["file"]["name"])){
        // Allow certain file formats
        $allowTypes = array('jpg','png','jpeg','gif','pdf');
        if(in_array($fileType, $allowTypes)){

            // Upload file to server
            if(move_uploaded_file($_FILES["file"]["tmp_name"], $targetFilePath)){
                // Insert image file name into database

                $data = file_get_contents($targetFilePath);

      // Escape the binary data
      $escaped = pg_escape_bytea($data);


                $sql = "INSERT into gallery (file_name,file_data) VALUES ('".$fileName."','".$escaped."')";
                //echo $sql;

                 $insert=$db->query($sql);

                if($insert){
                    $statusMsg = "The file ".$fileName. " has been 
    uploaded successfully.";
                }else{
                    $statusMsg = "File upload failed, please try again.";
                } 
            }else{
                $statusMsg = "Sorry, there was an error uploading your file.";
            }
        }else{
            $statusMsg = 'Sorry, only JPG, JPEG, PNG, GIF, & PDF files are allowed to upload.';
        }
    }else{
        $statusMsg = 'Please select a file to upload.';
    }

    // Display status message
    echo $statusMsg;
    ?>

How to insert watermark text using mpdf . Is it possible to use that function
at the time of uploading or downloading pdf file . i am storing pdf file as bytea datatype. how to solve this issue