pteal/plugin-pdf-viewer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

pteal/plugin-pdf-viewer

Composer 安装命令:

composer require pteal/plugin-pdf-viewer

包简介

PDF document viewer with pinch-to-zoom, popup screen panel with close and native share functionality for iOS and Android

README 文档

README

Opens PDF documents in a full-screen native viewer with pinch-to-zoom, a share button (left), and a close button (right). Supports both remote URLs and local file paths. Works on iOS and Android.

  • iOS — uses PDFKit (built-in, no external dependencies, iOS 11+)
  • Android — uses the built-in PdfRenderer (no external dependencies, API 21+)

Installation

composer require pteal/plugin-pdf-viewer

# Register the plugin
php artisan native:plugin:register pteal/plugin-pdf-viewer

# Verify
php artisan native:plugin:list

Requirements

Android

  • Minimum API 21 (Android 5.0)
  • No external dependencies or Gradle repository changes required
  • Optional: declare a FileProvider with authority ${applicationId}.provider for the best share experience (see Android FileProvider Setup). Without it, the plugin falls back to sharing via MediaStore.Downloads (API 29+)

iOS

  • iOS 11+, Xcode 13+
  • No additional configuration needed

Usage

Open a remote URL

use Pteal\PdfViewer\Facades\PdfViewer;

PdfViewer::url('https://example.com/document.pdf');

// With title and description
PdfViewer::url('https://example.com/report.pdf', 'Annual Report', 'Q4 2025 financial summary');

Open a local file

use Pteal\PdfViewer\Facades\PdfViewer;

PdfViewer::path('/absolute/path/to/file.pdf');

// With title and description
PdfViewer::path(storage_path('app/documents/invoice.pdf'), 'Invoice #1042', 'Due 2026-04-01');

Method signatures

PdfViewer::url(string $url, string $title = '', string $description = ''): mixed
PdfViewer::path(string $path, string $title = '', string $description = ''): mixed
  • $title — displayed in the viewer toolbar. If empty, no title is shown.
  • $description — displayed as a subtitle below the title. If empty, no subtitle is shown.

Viewer UI

Control Position Behaviour
Share Left of toolbar Opens the system native share sheet for the PDF file
Close Right of toolbar Dismisses the viewer and fires PdfViewerClosed

Remote PDFs are downloaded before display. The share sheet always shares the actual PDF file (not just a link), even for remote URLs.

Events

Event Payload Description
PdfViewerClosed { filePath: string } Fired when the user dismisses the viewer. filePath contains the original URL or file path that was opened.

Listening in Livewire

use Native\Mobile\Attributes\OnNative;
use Pteal\PdfViewer\Events\PdfViewerClosed;

#[OnNative(PdfViewerClosed::class)]
public function onPdfClosed(string $filePath): void
{
    // $filePath is the URL or path that was opened
}

Android FileProvider Setup

Adding a FileProvider gives the best share experience on all Android versions. Without it, the plugin falls back to MediaStore.Downloads (API 29+) — sharing will silently fail on API 21–28 without FileProvider.

Add the following inside <application> in your AndroidManifest.xml:

<provider
    android:name="androidx.core.content.FileProvider"
    android:authorities="${applicationId}.provider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths" />
</provider>

Create res/xml/file_paths.xml:

<?xml version="1.0" encoding="utf-8"?>
<paths>
    <files-path name="files" path="." />
    <external-files-path name="external_files" path="." />
</paths>

License

MIT

pteal/plugin-pdf-viewer 适用场景与选型建议

pteal/plugin-pdf-viewer 是一款 基于 Kotlin 开发的 Composer 扩展包,目前已累计 64 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 03 月 23 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 pteal/plugin-pdf-viewer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 pteal/plugin-pdf-viewer 我们能提供哪些服务?
定制开发 / 二次开发

基于 pteal/plugin-pdf-viewer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: Kotlin

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-23