0

我有一个带有“另存为 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, 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 in Drupal\entity_print\Plugin\EntityPrint\PrintEngine\DomPdf->send() (line 192 of modules/contrib/entity_print/src/Plugin/EntityPrint/PrintEngine/DomPdf.php).
4

0 回答 0