如何解决启用字体子设置时,laravel-dompdf得到错误“未定义索引:glyf”
我正在尝试使用pdf
库生成laravel-dompdf
文件。
这是我使用的字体样式:
@font-face {
font-family: 'Hiragino Sans';
src: url('fonts/Hiragino Sans GB W3.ttf') format('truetype');
font-weight: normal;
}
@font-face {
font-family: 'Hiragino Sans';
src: url('fonts/Hiragino Sans GB W6.ttf') format('truetype');
font-weight: bold;
}
这是控制器中的代码:
return PDF::loadView('pdf.presaleorder')->save('test.pdf');
一切正常,但是生成的pdf
文件太大,大于20MB
。我发现可以通过将enable_font_subsetting
中的config/dompdf.php
字段更改为true
来减小它的大小。
但是当我生成pdf
文件时,它引发了错误:
ErrorException : Undefined index: glyf
at G:\Project\Laravel\EventPayment\vendor\phenx\php-font-lib\src\FontLib\TrueType\File.php:329
325| *
326| * @return Table
327| */
328| public function getTableObject($name) {
> 329| return $this->data[$name];
330| }
331|
332| public function setTableObject($name,Table $data) {
1 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Undefined index: glyf","G::\Project\Laravel\EventPayment\vendor\phenx\php-font-lib\src\FontLib\TrueType\File.php",["glyf]"])
G:\Project\Laravel\EventPayment\vendor\phenx\php-font-lib\src\FontLib\TrueType\File.php:32\Project\29
9
2 FontLib\TrueType\File::getTableObject("glyf")
G:\Project\Laravel\EventPayment\vendor\phenx\php-font-lib\src\FontLib\TrueType\File.php:2001 1
Please use the argument -v to see more details.
当我添加参数-v
时,显示了更多的跟踪错误
2 FontLib\TrueType\File::getTableObject("glyf")
G:\Project\Laravel\EventPayment\vendor\phenx\php-font-lib\src\FontLib\TrueType\File.php:201
3 FontLib\TrueType\File::setSubset()
G:\Project\Laravel\EventPayment\vendor\dompdf\dompdf\lib\Cpdf.php:1171
4 Dompdf\Cpdf::processFont()
G:\Project\Laravel\EventPayment\vendor\dompdf\dompdf\lib\Cpdf.php:931
5 Dompdf\Cpdf::o_font("add")
G:\Project\Laravel\EventPayment\vendor\dompdf\dompdf\lib\Cpdf.php:3196
6 Dompdf\Cpdf::output()
G:\Project\Laravel\EventPayment\vendor\dompdf\dompdf\src\Adapter\CPDF.php:1213
7 Dompdf\Adapter\CPDF::output([])
G:\Project\Laravel\EventPayment\vendor\dompdf\dompdf\src\Dompdf.php:932
8 Dompdf\Dompdf::output()
G:\Project\Laravel\EventPayment\vendor\barryvdh\laravel-dompdf\src\PDF.php:157
9 Barryvdh\DomPDF\PDF::output()
G:\Project\Laravel\EventPayment\vendor\barryvdh\laravel-dompdf\src\PDF.php:167
10 Barryvdh\DomPDF\PDF::save("test.pdf")
G:\Project\Laravel\EventPayment\app\Services\OrderService.php:2170
11 App\Services\OrderService::createOrderPdf()
G:\Project\Laravel\EventPayment\app\Console\Commands\CreateOrderPdf.php:41
12 App\Console\Commands\CreateOrderPdf::handle(Object(App\Services\OrderService))
G:\Project\Laravel\EventPayment\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32
13 call_user_func_array()
G:\Project\Laravel\EventPayment\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:32
14 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
G:\Project\Laravel\EventPayment\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:90
15 Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application),Object(Closure))
G:\Project\Laravel\EventPayment\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:34
16 Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application),[])
G:\Project\Laravel\EventPayment\vendor\laravel\framework\src\Illuminate\Container\Container.php:576
17 Illuminate\Container\Container::call()
G:\Project\Laravel\EventPayment\vendor\laravel\framework\src\Illuminate\Console\Command.php:183
18 Illuminate\Console\Command::execute(Object(Symfony\Component\Console\Input\ArgvInput),Object(Illuminate\Console\OutputStyle))
G:\Project\Laravel\EventPayment\vendor\symfony\console\Command\Command.php:255
19 Symfony\Component\Console\Command\Command::run(Object(Symfony\Component\Console\Input\ArgvInput),Object(Illuminate\Console\OutputStyle))
G:\Project\Laravel\EventPayment\vendor\laravel\framework\src\Illuminate\Console\Command.php:170
20 Illuminate\Console\Command::run(Object(Symfony\Component\Console\Input\ArgvInput),Object(Symfony\Component\Console\Output\ConsoleOutput))
G:\Project\Laravel\EventPayment\vendor\symfony\console\Application.php:1000
21 Symfony\Component\Console\Application::doRunCommand(Object(App\Console\Commands\CreateOrderPdf),Object(Symfony\Component\Console\Input\ArgvInput),Object(Symfony\Component\Console\Output\ConsoleOutput))
G:\Project\Laravel\EventPayment\vendor\symfony\console\Application.php:271
22 Symfony\Component\Console\Application::doRun(Object(Symfony\Component\Console\Input\ArgvInput),Object(Symfony\Component\Console\Output\ConsoleOutput))
G:\Project\Laravel\EventPayment\vendor\symfony\console\Application.php:147
23 Symfony\Component\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput),Object(Symfony\Component\Console\Output\ConsoleOutput))
G:\Project\Laravel\EventPayment\vendor\laravel\framework\src\Illuminate\Console\Application.php:90
24 Illuminate\Console\Application::run(Object(Symfony\Component\Console\Input\ArgvInput),Object(Symfony\Component\Console\Output\ConsoleOutput))
G:\Project\Laravel\EventPayment\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:133
25 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput),Object(Symfony\Component\Console\Output\ConsoleOutput))
G:\Project\Laravel\EventPayment\artisan:37
有人解决吗?
我正在使用
laravel: 5.8
barryvdh/laravel-dompdf: 0.8.7
dompdf/dompdf: 0.8
windows 10
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。