- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用 barryvdh\laravel-snappy 创建 PDF 文件。我遵循了 github 页面上的所有步骤,但每当我使用像
这样的函数时$pdf->output();
$pdf->download("test.pdf");
我收到服务器错误。
我尝试使用安装程序以及 Composer 依赖项在 Windows 上安装 wkthmltopdf。我清除了缓存,使用了 composer update、dump-autoload 等。
这是我 Controller 中的函数:
public function createInvoice($id)
{
$data = ["data" => "data"];
$pdf = PDF::loadView("invoice.default", $data);
dd($pdf);
return response()->json([
"pdf" => base64_encode($pdf->output())
]);
}
我的 snappy.php 配置:
'pdf' => [
'enabled' => true,
'binary' => base_path('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'),
'timeout' => false,
'options' => [],
'env' => [],
],
'image' => [
'enabled' => true,
'binary' => base_path('vendor/h4cc/wkhtmltoimage-amd64/bin/wkhtmltoimage-amd64'),
'timeout' => false,
'options' => [],
'env' => [],
],
我的 app.php 配置:
'providers' => [
.
.
Barryvdh\Snappy\ServiceProvider::class,
.
.
.
'aliases'=> [
.
.
'PDF' => Barryvdh\Snappy\Facades\SnappyPdf::class,
'SnappyImage' => Barryvdh\Snappy\Facades\SnappyImage::class,
当我在 $pdf 上使用 dd 时,在调用输出、下载、内联等函数之前,我得到以下响应:
PdfWrapper {#347
#snappy: IlluminateSnappyPdf {#346
#optionsWithContentCheck: array:4 [
"header-html" => "html"
"footer-html" => "html"
"cover" => "html"
"xsl-style-sheet" => "xsl"
]
-binary: "C:\xampp\htdocs\invoicing\vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64"
-options: array:125 [
"ignore-load-errors" => null
"lowquality" => true
"collate" => null
"no-collate" => null
"cookie-jar" => null
"copies" => null
"dpi" => null
"extended-help" => null
"grayscale" => null
"help" => null
"htmldoc" => null
"image-dpi" => null
"image-quality" => null
"manpage" => null
"margin-bottom" => null
"margin-left" => null
"margin-right" => null
"margin-top" => null
"orientation" => null
"output-format" => null
"page-height" => null
"page-size" => null
"page-width" => null
"no-pdf-compression" => null
"quiet" => null
"read-args-from-stdin" => null
"title" => null
"use-xserver" => null
"version" => null
"dump-default-toc-xsl" => null
"dump-outline" => null
"outline" => null
"no-outline" => null
"outline-depth" => null
"allow" => null
"background" => null
"no-background" => null
"checkbox-checked-svg" => null
"checkbox-svg" => null
"cookie" => null
"custom-header" => null
"custom-header-propagation" => null
"no-custom-header-propagation" => null
"debug-javascript" => null
"no-debug-javascript" => null
"default-header" => null
"encoding" => null
"disable-external-links" => null
"enable-external-links" => null
"disable-forms" => null
"enable-forms" => null
"images" => null
"no-images" => null
"disable-internal-links" => null
"enable-internal-links" => null
"disable-javascript" => null
"enable-javascript" => null
"javascript-delay" => null
"load-error-handling" => null
"load-media-error-handling" => null
"disable-local-file-access" => null
"enable-local-file-access" => null
"minimum-font-size" => null
"exclude-from-outline" => null
"include-in-outline" => null
"page-offset" => null
"password" => null
"disable-plugins" => null
"enable-plugins" => null
"post" => null
"post-file" => null
"print-media-type" => null
"no-print-media-type" => null
"bypass-proxy-for" => null
"proxy" => null
"radiobutton-checked-svg" => null
"radiobutton-svg" => null
"run-script" => null
"disable-smart-shrinking" => null
"enable-smart-shrinking" => null
"stop-slow-scripts" => null
"no-stop-slow-scripts" => null
"disable-toc-back-links" => null
"enable-toc-back-links" => null
"user-style-sheet" => null
"username" => null
"window-status" => null
"zoom" => null
"footer-center" => null
"footer-font-name" => null
"footer-font-size" => null
"footer-html" => null
"footer-left" => null
"footer-line" => null
"no-footer-line" => null
"footer-right" => null
"footer-spacing" => null
"header-center" => null
"header-font-name" => null
"header-font-size" => null
"header-html" => null
"header-left" => null
"header-line" => null
"no-header-line" => null
"header-right" => null
"header-spacing" => null
"replace" => null
"disable-dotted-lines" => null
"cover" => null
"toc" => null
"toc-depth" => null
"toc-font-name" => null
"toc-l1-font-size" => null
"toc-header-text" => null
"toc-header-font-name" => null
"toc-header-font-size" => null
"toc-level-indentation" => null
"disable-toc-links" => null
"toc-text-size-shrink" => null
"xsl-style-sheet" => null
"viewport-size" => null
"redirect-delay" => null
"cache-dir" => null
"keep-relative-links" => null
"resolve-relative-links" => null
]
-env: null
-timeout: false
-defaultExtension: "pdf"
#temporaryFolder: null
+temporaryFiles: []
-logger: NullLogger {#345}
+"fs": Filesystem {#109}
}
#options: []
+"html": """
<!DOCTYPE html>
<html>
<head>
\t<title>Invoice<title>
</head>
<body>
<div class="container">
\t<table class="table table-bordered">
\t\t<thead>
\t\t\t<th>Name</th>
\t\t\t<th>Email</th>
\t\t</thead>
\t\t<tbody>
\t\t\t<tr>
\t\t\t\t<td>TEST</td>
\t\t\t\t<td>BEST</td>
\t\t\t</tr>
\t\t</tbody>
\t</table>
</div>
</body>
</html>
"""
+"file": null
}
当我调用其中一个函数时,然后:
{
"message": "Server Error"
}
最佳答案
将二进制路径改为
'pdf' => array(
'enabled' => true,
'binary' => '/usr/local/bin/wkhtmltopdf', //for ubuntu
// 'binary' => '"C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe"', //for windows
'timeout' => false,
'options' => array(),
'env' => array(),
),
'image' => array(
'enabled' => true,
'binary' => '/usr/local/bin/wkhtmltoimage', //for ubuntu
// 'binary' => '"C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe"', //for windows
'timeout' => false,
'options' => array(),
'env' => array(),
),
你已经为 ubuntu 设置好了。
关于php - Laravel-Snappy 抛出错误 500 没有更多信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58096326/
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 4 个月前关闭。 Improve
我有一个大小为 500 mb 的大文件,需要在一分钟内以最佳压缩比进行压缩。我发现这些算法适合我的使用。 lz4 lz4_hc snappy quicklz blosc 有人可以比较一下这些算法之间的
我使用 sqoop 1.4.6 将数据从 RDBMS 导入到 hdfs,使用 snappyCodec 作为压缩和 avro 作为文件格式。我安装了以下组件 Hadoop 2.8.0 Spark 2.1
当我们在一些处理后使用 Spark 时,我将结果存储到文件中,并使用简单代码使用 snappy 编解码器: data.saveAsTextFile("/data/2014-11-29",classO
无论我做什么,我都无法摆脱这个错误。我知道 snappy 是一个快速的压缩/解压缩库,因此比其他选项更可取。我想使用这个库进行处理。据我所知,Google 在内部将其用于他们的 BigTables、M
我正在使用亚马逊 ec2 ubuntu 11.04 服务器 sudo pip install python-snappy 我也尝试下载包并输入“sudo python setup.py instal
我在使用 MLUtils saveAsLibSVMFile 时遇到了上述错误。尝试了如下各种方法,但没有任何效果。 /* conf.set("spark.io.compression.codec",
我正在尝试从 DSE 5.0.11 运行 spark-shell。我可以成功创建和 RDD,但尝试查询它会产生: Caused by: java.io.IOException: java.lang.
当我尝试编译、测试和运行 junit 测试时出现错误。 我想使用 DataFrames 加载本地 Avro 文件,但出现异常: org.xerial.snappy.SnappyError: [FAIL
我正尝试在 Google Compute 引擎上针对我们位于 Google Cloud Storage 上的压缩数据运行 Hadoop Job。尝试通过 SequenceFileInputFormat
我已经搜索了每个文档,但仍然没有找到为什么有前缀以及以下文件命名约定中的 c000 是什么: 文件:/Users/stephen/p/spark/f1/part-00000-445036f9-7a40
java.lang.RuntimeException: native snappy 库不可用:此版本的 libhadoop 是在没有 snappy 支持的情况下构建的。 在 org.apache.ha
我要安装 parquet for python在 Windows 10 上的 Anaconda 2 安装中使用 pip。 安装时我遇到了描述的错误 here ,安装程序找不到 snappy-c.h。
我无法安装 python-snappy 模块。我首先成功安装了 snappy 模块,但出现以下 python-snappy 错误。 (new-env) C:\Automation\test-autom
我想知道是否有办法增加股票 android 画廊的“活泼”。换句话说,我希望 throw 速度比默认情况下下降得更快。给定的 throw 应该导致更少的滚动并且应该更快地停止。 查看源代码,它看起来就
我在HDFS中有一堆json快照压缩文件。 它们是HADOOP快速压缩的(不是python,请参阅其他SO问题) 并具有嵌套结构。 找不到将它们加载到的方法 进入HIVE(使用json_tuple)?
在我的 Java 代码中,我有 java.nio.ByteBuffer 类型的数据。我必须快速压缩它。通过导入 org.xerial.snappy.Snappy; 来使用 Snappy.compres
根据这个Cloudera post , Snappy 是可拆分的。 For MapReduce, if you need your compressed data to be splittable,
我正在将 KnpSnappyBundle 用于我的 Symfony 项目,并且我正在尝试在我的配置文件中定义一些选项。但是,如果我设置,例如: knp_snappy: pdf:
我正在尝试在 scala 中使用 spark 对一些数据帧进行大量连接。当我尝试获取此处生成的最终数据帧的计数时,出现以下异常。我正在使用 spark-shell 运行代码。 我在启动 spark-s
我是一名优秀的程序员,十分优秀!