我有一个现有的 php:8-fpm-alpine Dockerfile,我需要添加 WKHTMLTOPDF 包。这可能吗?我尝试使用以下 dockerfile,但收到以下错误日志:
Docker 文件...
FROM php:8-fpm-alpine
...
RUN apk add xvfb libfontconfig wkhtmltopdf
Run Code Online (Sandbox Code Playgroud)
错误:
ERROR [ 8/13] RUN apk add --no-cache wkhtmltopdf 2.1s
[ 8/13] RUN apk add --no-cache wkhtmltopdf:
#12 0.567 fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
#12 1.097 fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
#12 2.001 ERROR: unable to select packages:
#12 2.034 wkhtmltopdf (no such package):
#12 2.034 required by: world[wkhtmltopdf]
executor failed running [/bin/sh -c apk add --no-cache wkhtmltopdf]: exit code: 1
ERROR: Service 'php' failed to build : Build …Run Code Online (Sandbox Code Playgroud) 我使用laravel-snappy 作为wkhtmltopdf 的包装器,用于从 HTML 创建 PDF。
当使用相同的配置运行相同的代码时,我得到不同的输出:
macOS 输出:
(右边部分被裁剪了,而且底部还有很大的边距)
两种环境都使用wkhtmltopdf 0.12.4 (with patched qt),对于这种差异有什么想法吗?
使用:
WKpdftohml版本0.12.3.2
PHPwkhtmltopdf版本2.2.0
Chart.JS版本2.5.0
我正在尝试使用上面的库打印折线图.我可以使用shell命令重现pdf:wkhtmltopdf --javascript-delay 5000 " http://netdna.webdesignerdepot.com/uploads7/easily-create-stunning-animated-charts-with-chart-js/chartjs-demo.html" test2.pdf
所以WKhtmltopdf没有问题.
问题是当我在我的应用程序中使用PHPwkhtmltopdf库时.我得到一个空白页面.
根据我的研究,这些是我尝试过的东西:
'javascript-delay' => 500到Chart.JS选项;animation:{onComplete: function () {window.JSREPORT_READY_TO_START =true}到Chart.JS选项;<div style="width:800px;height:200;font-size:10px;">到canvas html标记的父divctx.canvas.width = 800;ctx.canvas.height = 200;到图表的javascript初始化.没有什么工作.我喜欢Chart.JS和WKhtmltopdf,但如果我不能打印,我将不得不放弃其中一个.有什么解决方案吗?
这是PHPwkhtmltopdf的PHP代码:
public function imprimir ($request, $response)
{
// include_once 'config/constants.php';
// include_once 'resources/auxiliar/helpers.php';
$folha = $_POST['printit'];
$variaveis = explode(',', $folha);
$nomeFicheiro = $variaveis[0];
$printName = substr($nomeFicheiro, 5);
if (isset($variaveis[2])) {
$_SESSION['mesNumero'] = $variaveis[2];
$_SESSION['mes'] = $variaveis[1];
} else {
$mesNumero …Run Code Online (Sandbox Code Playgroud) 我正在使用这个wkhtmltopdf 0.12.3 (with patched qt)版本的 wkhtmltopdf。使用蒙特塞拉特字体系列。
HTML是这样的,
<strong>
This Agreement for home staging and rental of furniture and accessories
</strong>
(“Agreement”) is entered this
Run Code Online (Sandbox Code Playgroud)
其中输出为,
同意家居装饰和家具及配件的租赁(???同意??)
和,
<u>Services</u>
Subject to the terms and conditions of this </span>
Run Code Online (Sandbox Code Playgroud)
其中输出为,
 服务 受本条款和条件的约束
为什么这些Â介于两者之间?
我试图替换这样的引号和空格,
$formData = str_replace(' ', ' ', $formData);
$formData = str_replace('"', '"', $formData);
$formData = str_replace('“', '"', $formData);
$formData = str_replace('”', '"', $formData);
Run Code Online (Sandbox Code Playgroud)
但没有帮助。难道我做错了什么?已搜索,但找不到解决方案。
'phpwkhtmltopdf'的某些东西停止了工作.
使用以下代码在Web浏览器上运行:
$string = "http://www.google.com";
// You can add parameter for the constructor call
$binary = '/usr/bin/wkhtmltopdf';
$pdf = new Pdf(array(
// Explicitly tell wkhtmltopdf that we're using an X environment
// 'use-xserver',
// Enable built in Xvfb support in the command
'commandOptions' => array(
'enableXvfb' => true,
// Optional: Set your path to xvfb-run. Default is just 'xvfb-run'.
'xvfbRunBinary' => '/usr/bin/xvfb-run',
// Optional: Set options for xfvb-run. The following defaults are used.
//'xvfbRunOptions' => '--server-args="-screen 0, 1024x768x24"',
),
)); …Run Code Online (Sandbox Code Playgroud)