我正在使用Wkhtmltopdf將某些文件轉換爲PDF在Symfony2應用程序。其實KnpSnappyBundle
呢。這個捆綁包效果很好,但我有一個奇怪的問題:Wkhtmltopdf不打印圖像的子域
該Web應用程序有兩個子域:test.domain
和prod.domain
。這兩個子域目前具有完全相同的內容。 由於某些原因,使用prod
子域名時不會打印圖像(轉換爲PDF)。但是,如果我直接訪問URL,則圖像存在。一個例子是:
<img src="prod.domain/img/theImage.jpg" /> <!-- This doesn't print the image but the URL is accessible -->
<img src="test.domain/img/theImage.jpg" /> <!-- This works right -->
我終於決定暫時使用test
子域圖像的URL,但它的怪異......你知道嗎?
編輯:
我忘了說,prod
域使用SSL,而test
沒有。這似乎是主要問題。
我已經從服務器上執行:
wkhtmltopdf https://prod.domain test.pdf
Loading pages (1/5)
QSslSocket: cannot resolve SSLv2_client_method ] 10%
QSslSocket: cannot resolve SSLv2_server_method
Error: Failed loading page https://prod.domain (sometimes it will work just to ignore this error with --ignore-load-errors)
所以我又試了一次:
wkhtmltopdf --ignore-load-errors https://prod.domain test.pdf
Loading pages (1/5)
QSslSocket: cannot resolve SSLv2_client_method ] 10%
QSslSocket: cannot resolve SSLv2_server_method
Warning: Failed loading page https://prod.domain (ignored)
Resolving links (2/5)
Counting pages (3/5)
Printing pages (5/5)
Done
但是,新的文件是銀行。
如果我使用test
域(無SSL):
wkhtmltopdf http://test.domain test.pdf
Loading pages (1/5)
QSslSocket: cannot resolve SSLv2_client_method ] 21%
QSslSocket: cannot resolve SSLv2_server_method
Resolving links (2/5)
Counting pages (3/5)
Printing pages (5/5)
Done
我得到了前兩個錯誤,但它的工作原理和文件是正確的。
由於採用SSL協議,我可以使用'wget --no-check-certificate prod.domain/img/theImage.jpg'來做到這一點。認爲該文件是可訪問的。這是錯誤的**圖像**不顯示。 – Manolo 2014-12-12 10:07:51
@Manolo「' - no-check-certificate'」檢查證書時工作嗎?我認爲服務器不會接受證書,因此wkhtmltopdf無法看到他們 – Waaghals 2014-12-12 14:05:32
我已更新我的問題。你可以在那裏看到它。 – Manolo 2014-12-12 14:06:41