2016-04-22 41 views
1

在我的生成PDF樹枝模板,我有:Symfony2的 - 同時產生與TCPDF捆綁PDF文件錯誤

<img src="{{ asset('bundles/myBundle/images/no_avatar.jpg') }}"> 

當我試圖生成PDF,我得到錯誤:

[Symfony\Component\Debug\Exception\ContextErrorException] 
Warning: getimagesize(/bundles/wrbmcisintranetsite/images/no_avatar.jpg): f 
ailed to open stream: No such file or directory 


Exception trace: 
() at /var/www/site/vendor/tecnickcom/tcpdf/include/tcpdf_images.php:171 
Symfony\Component\Debug\ErrorHandler->handleError() at n/a:n/a 
getimagesize() at /var/www/site/vendor/tecnickcom/tcpdf/include/tcpdf_images.php:171 

而且當我更改存儲該圖像的路徑時,例如:

<img src="{{ asset('var/storage/images/no_avatar.jpg') }}"> 

並複製該文件而不使用assets:install web它的工作原理和圖像在輸出PDF文件中可見。我想把文件在MyBundle/Resources/public/images安裝與assets:install

+0

<img src="{{ absolute_url(asset('images/logo.png')) }}" alt="Symfony!" /> 

更多信息按錯誤的和getimagesize功能沒有得到圖像計算圖像尺寸。檢查路徑是否正確?檢查命令資產:安裝Web正在您的所有資產安裝在Web目錄下? –

回答

1

你需要爲所有資產(包括css)傳遞絕對url。

在你的情況可以用absolute_url的嘗試爲例子:在doc here