Protect PDF document in PHP using GroupDocs.Viewer REST API

Hi @tilal.ahmad
While using the GroupDocs.Viewer Cloud SDK for PHP. Can we select multiple PDFOption for setting up the permission as followes
$renderOptions = new Model\PdfOptions();
$renderOptions->setPermissions('DenyDataExtraction');
$renderOptionss->setPermissions('DenyModification');
$renderOptions->setPermissionsPassword("p123");
$viewOptions->setRenderOptions($renderOptions);
$request = new Requests\CreateViewRequest($viewOptions);
$response = $apiInstance->createView($request);

It doesn’t seem to work in my case.
Thank you so much for your response.
Gopal

@gopalsharma

I have tested the scenario using following code and it is working as expected for me.Revisions (2).pdf (48.6 KB)

    $renderOptions->setPermissions(GroupDocs\Viewer\Model\PdfOptions::PERMISSIONS_DENY_MODIFICATION);
	$renderOptions->setPermissions(GroupDocs\Viewer\Model\PdfOptions::PERMISSIONS_DENY_DATA_EXTRACTION);
	$renderOptions->setPermissionsPassword("p123");
1 Like

@tilal.ahmad

I don’t think this is working,
your file has only PERMISSIONS_DENY_DATA_EXTRACTION and not PERMISSIONS_DENY_MODIFICATION

here is the screen shot of permissiones Revisions(2).pdf file you have sahred.
tilal ahmad.PNG (19.4 KB)

@gopalsharma

We are sorry for the inconvenience. I have noticed the reported issue, the GroupDocs.Viewer REST API honors the last permission value only. So, we have logged an enhancement ticket VIEWERCLOUD-400 to accept an array of Permissions instead of a single value. We will notify you as soon as it is resolved.

1 Like

Thank you so much @tilal.ahmad :slightly_smiling_face:.
Really appreciate your response.

Regards,
Gopal

1 Like

Hi @tilal.ahmad

I see the issue status is still “In Progress”, when can we expect it to be resolved?

I’m getting another error now, which is
Error converting value "AllowAll" to type 'System.String[]'. Path 'Permissions', line 14, position 33. error Internal Server error

Please advise…

Thank you,
Gopal

@gopalsharma

We are looking into the issue and will update you shortly.

1 Like

@gopalsharma

Your above reported issue is resolved. Please download the latest PHP SDK version of GroupDocs.Viewer Cloud API and use the permissions array as following. It will help you to accomplish the task.

$renderOptions->setPermissions(["DenyModification", "DenyPrinting"]);
1 Like

Thank you so much! @tilal.ahmad. Much appreciated.

Regards,
Gopal

1 Like

This how I used the permission setting code and working well for me.
$permissions = array();
if (($denyprinting == “”) && ($denymodification == “”) && ($denydataextraction == “”)) {
array_push($permissions,“AllowAll”);
} else if (($denyprinting != “”) && ($denymodification != “”) && ($denydataextraction != “”)) {
array_push($permissions,“DenyAll”);
} else {
if ($denyprinting != “”) {
array_push($permissions,“DenyPrinting”);
}
if ($denymodification != “”) {
array_push($permissions,“DenyModification”);
}
if ($denydataextraction != “”) {
array_push($permissions,“DenyDataExtraction”);
}
}
$renderOptions->setPermissions($permissions);

1 Like

A post was split to a new topic: How to set Watermark Color in PHP using GroupDocs.Viewer REST API