Polyscope——面向 Laravel 的以代理为先的开发环境

Generate, Parse, and Convert Documents in PHP with Paperdoc

最后更新于 经过

Generate, Parse, and Convert Documents in PHP with Paperdoc image

Paperdoc is a PHP library by Zerarka Mohamed Ali Akram for generating, parsing, and converting documents across multiple file formats through a single unified API. Rather than juggling several format-specific packages, Paperdoc gives you one consistent interface for everything from PDFs to spreadsheets. It handles both modern formats (PDF, DOCX, XLSX, PPTX, HTML, CSV, Markdown) and legacy formats (DOC, XLS, PPT), and all of them work bidirectionally — you can both parse existing files and generate new ones in any of them.

主要特点

Document Generation — Create new documents from scratch in any supported format. You work with a structured document model (sections, paragraphs, tables, etc.) that maps cleanly to whichever output format you choose:

使用 Paperdoc\Support\DocumentManager ;
使用 Paperdoc\Document\Style\TextStyle ;
$doc = DocumentManager :: 创造 'pdf' , 'My PaperDoc Demo Document' (英文):
$boldStyle = TextStyle :: 制作 ()
-> setBold ()
-> setColor '#f9332b'
-> setFontSize 14 (英文):
$section = $doc -> openSection ();
$section -> addHeading 'Generate, Parse, and Convert Documents in PHP with Paperdoc' (英文):
$section -> addParagraph 'Paperdoc is a PHP library by Zerarka Mohamed Ali Akram for generating, parsing, and converting documents across multiple file formats through a single unified API.' (英文):
$section -> addParagraph
'Convert PDF, HTML, CSV, DOCX, XLSX, PPTX, Markdown and more.' ,
$boldStyle
(英文):
DocumentManager :: 节省 ($doc, 'output/paperdoc.pdf' (英文):

解析 — Load existing files into a normalized in-memory model. This gives you a consistent data structure to work with regardless of the source format:

$doc = DocumentManager :: 打开 'paperdoc.pdf' (英文):
foreach ($doc -> getSections () 作为 $section) {
foreach (部分) -> getParagraphs () 作为 $paragraph) {
回声 $paragraph -> getText ();
}
}

Format Conversion — Transform documents between any two supported formats in a single call:

DocumentManager :: 转变 'paperdoc.pdf' , 'paperdoc.docx' , 'docx' (英文):

Rendering to string — Rather than writing to disk, you can render a document directly to a string, which is useful for returning responses or piping output:

$html = DocumentManager :: renderAs ($doc, ‘html’ (英文):

OCR Processing — Extract text from scanned documents using Tesseract, making it possible to work with image-based or non-machine-readable PDFs. You'll need the Tesseract binary installed on your system and the path configured in config/paperdoc.php

AI Augmentation — An optional Neuron AI integration adds LLM-powered capabilities such as document summarization, translation, and structured data extraction.

缩略图 — Generate preview images of any document via thumbnail() 或者 thumbnailDataUri() for inline use. Note that high-quality rendering requires third-party binaries depending on the format — LibreOffice for Office files, and Imagick or Ghostscript for PDFs.

批处理 — Open and process multiple documents in a single call:

$docs = DocumentManager :: openBatch ([
'file1.pdf' ,
'file2.docx' ,
'file3.xlsx' ,
]);

Laravel 集成

Paperdoc ships with first-party Laravel support including a ServiceProvider, Facade, and Artisan commands, targeting Laravel 11+. The Facade is registered automatically via package auto-discovery, giving you a clean Paperdoc 界面:

使用 Paperdoc\Facades\Paperdoc ;
$doc = Paperdoc :: 创造 'md' , 'Paperdoc + Laravel' (英文):
$doc -> openSection ()
-> addParagraph 'Paperdoc also works great with Laravel!' (英文):
Paperdoc :: 节省 ($doc, 存储路径 'app/private/articles/paperdoc-and-laravel.pdf' ));
Paperdoc :: 转变 'articles/paperdoc-and-laravel.md' , 'articles/paperdoc-laravel.pdf' , 'pdf' (英文):
$html = Paperdoc :: renderAs ($doc, ‘html’ (英文):
$docs = Paperdoc :: openBatch ([
'file1.pdf' ,
'file2.docx' ,
'file3.xlsx' ,
]);

You can find the source code on GitHub and learn more on the official Paperdoc website

Yannick Lyn Fatt 的照片

Laravel News 的特约撰稿人和全栈 Web 开发人员。

归档于:
立方体

Laravel 时事通讯

加入超过 4 万名开发者的行列,不错过任何新的技巧、教程等内容。

图像
Laravel 代码审查

几天内即可获得 Laravel 代码审查方面的专家指导

访问 Laravel 代码审查
Tinkerwell 徽标

廷克威尔

Laravel 开发者必备的代码运行器。可在本地和生产环境中体验 AI、自动补全和即时反馈功能。

廷克威尔
几天内即可获得 Laravel 代码审查徽标的专家指导

几天内即可获得 Laravel 代码审查方面的专家指导

专家级代码审查!两位拥有 10 年以上 Laravel 开发经验的开发者将为您提供清晰、实用的反馈,帮助团队构建更优质的应用程序。

几天内即可获得 Laravel 代码审查方面的专家指导
PhpStorm 标志

PhpStorm

首选的 PHP IDE,对 Laravel 及其生态系统提供广泛的开箱即用支持。

PhpStorm
Laravel Cloud 标志

Laravel 云

轻松创建和管理服务器,并在几秒钟内部署 Laravel 应用程序。

Laravel 云
了解 Softtech 的标志

了解软科技

Acquaint Softtech 提供 AI 就绪的 Laravel 开发人员,48 小时内即可上手,每月费用为 3000 美元,没有冗长的销售流程,并提供 100% 退款保证。

了解软科技
Kirschbaum 标志

樱桃树

提供创新和稳定性,确保您的Web应用程序取得成功。

樱桃树
Shift 标志

转移

还在运行旧版本的 Laravel?立即实现 Laravel 自动升级和代码现代化,让您的应用程序保持最新状态。

转移
鱼叉:新一代时间跟踪和发票标志

Harpoon:新一代时间跟踪和发票系统

新一代时间跟踪和计费软件,帮助您的机构规划和预测盈利的未来。

Harpoon:新一代时间跟踪和发票系统
Lucky Media 标志

幸运传媒

Get Lucky Now——拥有十余年经验的 Laravel 开发理想之选!

幸运传媒
SaaSykit:Laravel SaaS 入门套件徽标

SaaSykit:Laravel SaaS 入门套件

SaaSykit 是一个多租户 Laravel SaaS 入门套件,包含运行现代 SaaS 所需的所有功能,例如支付、美观的结账界面、管理面板、用户仪表盘、身份验证、现成组件、统计数据、博客、文档等等。

SaaSykit:Laravel SaaS 入门套件
MongoDB 徽标

MongoDB

Enhance your PHP applications with the powerful integration of MongoDB and Laravel, empowering developers to build applications with ease and efficiency. Support transactional, search, analytics and mobile use cases while using the familiar Eloquent APIs. Discover how MongoDB's flexible, modern database can transform your Laravel applications.

MongoDB
Debounceable Queued Jobs in Laravel 13.6.0 image

Debounceable Queued Jobs in Laravel 13.6.0

阅读文章
Build Custom Middleware for Query Performance Monitoring and Optimization in Laravel with MongoDB image

Build Custom Middleware for Query Performance Monitoring and Optimization in Laravel with MongoDB

阅读文章
An Opinionated Agent Skill for Building REST APIs in Laravel image

An Opinionated Agent Skill for Building REST APIs in Laravel

阅读文章
使用 SaaSykit 镜像启动您梦想中的 SaaS 应用

使用 SaaSykit 启动您梦寐以求的 SaaS 应用

阅读文章
Generate, Parse, and Convert Documents in PHP with Paperdoc image

Generate, Parse, and Convert Documents in PHP with Paperdoc

阅读文章
Spatie Shares Their Coding Guidelines as AI Skills image

Spatie Shares Their Coding Guidelines as AI Skills

阅读文章