joaopaulolndev/filament-pdf-viewer

用于显示PDF文档查看器的Filament包

v1.0.6 2024-09-26 08:14 UTC

This package is auto-updated.

Last update: 2024-09-26 08:16:17 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

FilamentPHP包,用于展示数据库中保存的记录的PDF文档,或以资源形式展示没有数据库的文档。

Screenshot of Application Feature

功能 & 截图

  • 表单字段:在表单字段中显示PDF文档查看器。
  • 信息列表条目:在信息列表条目中显示PDF文档查看器。
  • 支持: Laravel 11Filament 3.x

安装

您可以通过composer安装此包

composer require joaopaulolndev/filament-pdf-viewer

可选,您可以使用以下命令发布视图:

php artisan vendor:publish --tag="filament-pdf-viewer-views"

在表单字段中使用

use Joaopaulolndev\FilamentPdfViewer\Forms\Components\PdfViewerField;

public static function form(Form $form): Form
{
    return $form
        ->schema([
            PdfViewerField::make('file')
                ->label('View the PDF')
                ->minHeight('40svh')
        ]);
}

在信息列表条目中使用

use Joaopaulolndev\FilamentPdfViewer\Infolists\Components\PdfViewerEntry;

public static function infolist(Infolist $infolist): Infolist 
{
    return $infolist
        ->schema([
            PdfViewerEntry::make('file')
                ->label('View the PDF')
                ->minHeight('40svh')
        ]);
}

可选,您可以使用其他方法设置PDF查看器

use Joaopaulolndev\FilamentPdfViewer\Infolists\Components\PdfViewerEntry;

public static function infolist(Infolist $infolist): Infolist 
{
    return $infolist
        ->schema([
            PdfViewerEntry::make('file')
                ->label('View the PDF')
                ->minHeight('40svh')
                ->fileUrl(Storage::url('dummy.pdf')) // Set the file url if you are getting a pdf without database
                ->columnSpanFull()
        ]);
}

可选,您可以使用部分来设置PDF查看器

use Joaopaulolndev\FilamentPdfViewer\Infolists\Components\PdfViewerEntry;

public static function infolist(Infolist $infolist): Infolist 
{
    return $infolist
        ->schema([
            \Filament\Infolists\Components\Section::make('PDF Viewer')
            ->description('Prevent the PDF from being downloaded')
            ->collapsible()
            ->schema([
                PdfViewerEntry::make('file')
                    ->label('View the PDF')
                    ->minHeight('40svh')
                    ->fileUrl(Storage::url('dummy.pdf')) // Set the file url if you are getting a pdf without database
                    ->columnSpanFull()
            ]);        
        ]);
}

测试

composer test

变更日志

请参阅 CHANGELOG 了解最近的变化。

贡献

请参阅 CONTRIBUTING 了解详细信息。

安全漏洞

请审查 我们的安全策略 了解如何报告安全漏洞。

致谢

许可

MIT许可(MIT)。请参阅 许可文件 了解更多信息。