承接 soap/dompdf-thai 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

soap/dompdf-thai

最新稳定版本:v1.0.0

Composer 安装命令:

composer require soap/dompdf-thai

包简介

Add Thai fonts for Laravel DomPdf wrapper package

README 文档

README

Latest Version on Packagist Total Downloads GitHub Actions

Add thai font support for barryvdh/laravel-dompdf package. Currently only THSanrabunNew is included.

Installation

You can install the package via composer:

composer require soap/dompdf-thai

Publish the assets (font files) into public/vendor/dompdf-thai

php artisan vendor:publish --tag="dompdf-thai-assets"

Create storage/fonts to store cache files.

mkdir storage/fonts

Usage

Add @DompdfThaiFont inside head of your pdf view layout. You may put in resources/views/layouts/pdf.blade.php file. The following file was adapted from Laravel Breeze Guest layout file.

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="csrf-token" content="{{ csrf_token() }}">

        <title>{{ config('app.name', 'Laravel') }}</title>

        <!-- Fonts -->
        <link rel="preconnect" href="https://fonts.bunny.net">
        <link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />

        <!-- Scripts -->
        @DompdfThaiFont
        @vite(['resources/css/app.css', 'resources/js/app.js'])
        <style>
            body {
                font-family: 'THSarabunNew';
            }
        </style>
    </head>
    <body class="font-sans antialiased text-gray-900">
        <div class="flex flex-col items-center min-h-screen pt-6 bg-gray-100 sm:justify-center sm:pt-0 dark:bg-gray-900">
            <div>
                <a href="/">
                    <x-application-logo class="w-20 h-20 text-gray-500 fill-current" />
                </a>
            </div>

            <div class="w-full px-6 py-4 mt-6 overflow-hidden bg-white shadow-md sm:max-w-md dark:bg-gray-800 sm:rounded-lg">
                {{ $slot }}
            </div>
        </div>
    </body>
</html>

The following file is in resources/views/products. This file will be used by ProductController to stream pdf content.

<x-pdf-layout>
    <div class="py-12">
        <div class="mx-auto max-w-7xl sm:px-6 lg:px-8">
            <div class="overflow-hidden bg-white shadow-sm dark:bg-gray-800 sm:rounded-lg">
                <div class="p-6 text-gray-900 dark:text-gray-100">
                    ทดสอบ This is a test for pdf
                </div>
            </div>
        </div>
    </div>
</x-pdf-layout>

This is part of the product controller.

  namespace App\Http\Controllers;

  use App\Models\Product;
  use App\Http\Requests\StoreProductRequest;
  use App\Http\Requests\UpdateProductRequest;
  use Barryvdh\DomPDF\Facade\Pdf;

  ....
    /**
     * Remove the specified resource from storage.
     */
    public function destroy(Product $product)
    {
        //
    }

    public function toPdf()
    {
        $pdf = Pdf::loadView('products.pdf'); //, ['products' => Product::all()]);

        return $pdf->stream();
    }

Please consult the barryvdh/laravel-dompdf documentation for detail how to produce pdf from Laravel view.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email prasit.gebsaap@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

统计信息

  • 总下载量: 398
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固