如何解决添加图像时,Drupal 渲染器无法生成 SSL 操作失败并显示代码
我有一个带有“另存为 PDF”按钮的自定义表单控制器,一切正常,直到我想将徽标图像添加到 PDF 的标题。我收到上下文 Open SSL 错误消息,但不确定如何向渲染添加适当的上下文。
public function printForm($build,$fileName){
// Load array of elements used when generating the form
$html = $this->renderHtmlWrapper($build);
// Load print engine
$print_engine = \Drupal::service('plugin.manager.entity_print.print_engine')->createSelectedInstance('pdf');
// Long generator and render response from form elements
$response = \Drupal::service('renderer')->render($html);
// Add content to PDF engine
$print_engine->addPage($response);
// Download PDF
return (new \Symfony\Component\HttpFoundation\StreamedResponse(function () use ($print_engine,$fileName) {
$print_engine->send($fileName . ".pdf");
}))->send();
}
我尝试添加徽标后立即失败:
$html['body']['tag_header']['content'] = [
'logo' => [
'#theme' => 'image','#uri' => '/themes/THEME/images/logo.png','#alt' => 'THEME','#width' => '40px','#height' => '154.42px'
]
];
错误信息:
Drupal\entity_print\PrintEngineException: Failed to generate PDF: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed,file_get_contents(): Failed to enable crypto,file_get_contents(https://WEBSITE:8890/themes/THEME/images/logo.png): failed to open stream: operation failed,Image not found /themes/THEME/images/logo.png,file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed,Image not found /themes/THEME/images/logo.png in Drupal\entity_print\Plugin\EntityPrint\PrintEngine\DomPdf->send() (line 192 of modules/contrib/entity_print/src/Plugin/EntityPrint/PrintEngine/DomPdf.php).
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。