试图执行安全策略“PDF”不允许的操作@error/constitute.c/IsCoderAuthorized/408
Attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408
我是 运行 我本地 ubuntu 20.04 机器上的一个 laravel 项目,在另一台机器上运行良好。该项目使用 Image Magic 将 PDF 转换为 PNG。当我调用将 PDF 转换为 PNG 的功能时,出现以下错误:
ImagickException
attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408
函数看起来:
public function show($id)
{
$book = Book::all()->first();
$file = public_path('' . $book->pdf);
$count = 0;
$im = new \Imagick($file);
$blobList=[];
do {
$page = new \Imagick();
$page->setResolution(300,300);
$page->readImage($file . '['.$count.']');
$page->setImageFormat("jpeg");
header("Content-Type: image/jpeg");
$image = $page->getImageBlob();
array_push($blobList,$image);
$count++;
} while (5> $count);
// $im->resizeImage(200,200,1,0);
return view('notice/showbook', compact('book', 'blobList'));
}
到目前为止,我已经安装了 image magic 和 gs,并参考
已接受的答案对 policymap.xml
进行了更改
然而,错误仍然存在。请帮忙!
谢谢,
当我尝试使用 pyocr
解析 pdf 时,我也遇到了同样的问题
wand.exceptions.PolicyError: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408
为了解决这个问题,我编辑了 ImageMagick-6 的 policy.xml。在该文件中,将策略权限更改为 read/write
<policy domain="coder" rights="none" pattern="PDF" />
改为
<policy domain="coder" rights="read|write" pattern="PDF" />
如果它不能解决您的问题,您还可以在同一文件中启用以下行。
<!-- <policy domain="module" rights="none" pattern="{PS,PDF,XPS}" /> -->
改为
<policy domain="module" rights="read|write" pattern="{PS,PDF,XPS}" />
我是 运行 我本地 ubuntu 20.04 机器上的一个 laravel 项目,在另一台机器上运行良好。该项目使用 Image Magic 将 PDF 转换为 PNG。当我调用将 PDF 转换为 PNG 的功能时,出现以下错误:
ImagickException attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408
函数看起来:
public function show($id)
{
$book = Book::all()->first();
$file = public_path('' . $book->pdf);
$count = 0;
$im = new \Imagick($file);
$blobList=[];
do {
$page = new \Imagick();
$page->setResolution(300,300);
$page->readImage($file . '['.$count.']');
$page->setImageFormat("jpeg");
header("Content-Type: image/jpeg");
$image = $page->getImageBlob();
array_push($blobList,$image);
$count++;
} while (5> $count);
// $im->resizeImage(200,200,1,0);
return view('notice/showbook', compact('book', 'blobList'));
}
到目前为止,我已经安装了 image magic 和 gs,并参考
policymap.xml
进行了更改
然而,错误仍然存在。请帮忙!
谢谢,
当我尝试使用 pyocr
解析 pdf 时,我也遇到了同样的问题wand.exceptions.PolicyError: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/408
为了解决这个问题,我编辑了 ImageMagick-6 的 policy.xml。在该文件中,将策略权限更改为 read/write
<policy domain="coder" rights="none" pattern="PDF" />
改为
<policy domain="coder" rights="read|write" pattern="PDF" />
如果它不能解决您的问题,您还可以在同一文件中启用以下行。
<!-- <policy domain="module" rights="none" pattern="{PS,PDF,XPS}" /> -->
改为
<policy domain="module" rights="read|write" pattern="{PS,PDF,XPS}" />