2017-08-24 28 views
5

wkhtmltopdf phpwrapperで基本的なpdfを生成しようとしています。私はyiiフレームワークも使用しています。wkhtmltopdf ContentNotFoundError、code 1

これが私のHTMLです:問題が何であるか任意のアイデア

Exception 'Exception' with message 'Could not create PDF: Loading pages (1/6) 
[>               ] 0% 
[======>              ] 10% 
[==============================>        ] 50% 
[============================================================] 100% 
Counting pages (2/6)            
[============================================================] Object 1 of 1 
Resolving links (4/6)              
[============================================================] Object 1 of 1 
Loading headers and footers (5/6)           
[===>              ] 5% 
[======>              ] 10% 
[======>              ] 10% 
[=======>             ] 13% 
[==========>             ] 17% 
[==================================>       ] 57% 
[====================================>      ] 61% 
Warning: Failed to load https://work.mydomain.com/devs/florian/web//devs/florian/web/themes/css/report-footer.css (ignore) 
[============================================================] 100% 
Printing pages (6/6)            
[>               ] Preparing 
[============================================================] Page 1 of 1 
Done                  
Exit with code 1 due to network error: ContentNotFoundError' 

:wktmltopdfで

<!doctype html> 
<html> 
    <head> 
    </head> 

    <body> 
      <p>test</p> 
    </body> 
</html> 

マイセッティング:

$pdfParams = array(

      'header-html' => $this->tmpHeaderFile->getFileName(), 
      'footer-html' => $this->tmpFooterFile->getFileName(), 

      'username' => 'myUser', 
      'password' => 'myPass', 
     ); 
$this->pdf = new Pdf($pdfParams); 

エラーイムなって?

答えて

0

私は前に同様の問題に直面しています。 wkhtmltopdfを使用する場合は、すべての静的資産がHTMLファイルに確実に追加されるようにする必要があります。

例えば

:だけでなくHTMLファイルに直接スクリプトを追加、JavaScriptファイルについては

<!doctype html> 
<html> 
    <head> 
     <style> 
      html { 
       margin: 0; 
      } 
     </style> 
    </head> 

    <body> 
      <p>test</p> 
    </body> 
</html> 

: CSSファイルは、内部スタイルシートを使用します。

<!doctype html> 
<html> 
    <head> 
     <script type="text/javascript"> 
      var body = document.querySelector('body'); 
     </script> 
    </head> 

    <body> 
      <p>test</p> 
    </body> 
</html> 

私は、これは

+0

がたくさん感謝私を助けたのに役立ちます願っています –

関連する問題