@coolsoftwaretyler/cool-pdf

中文文档
0.1.10发布于 2025/10/06MITTypeScriptCommonJS零依赖近 30 天下载 2053

PDF View Component for Expo

原始使用文档
文档目录8 节
  1. Roadmap
  2. Installation
  3. Add the package to your dependencies
  4. Run a fresh prebuild
  5. Run your app
  6. Usage
  7. Compatibility with react-native-pdf
  8. Props

cool-pdf

PDF View Component for Expo. Intended as a drop-in replacement for react-native-pdf. Check compatibility table for current progress. Contributions welcome.

Roadmap

See this GitHub issue explaining the motivation and intentions for the project

Installation

Add the package to your dependencies

npm install @coolsoftwaretyler/cool-pdf

Run a fresh prebuild

npx expo prebuild --clean

Run your app

Start up Android or iOS

Usage

import { CoolPdfView } from "@coolsoftwaretyler/cool-pdf";

<CoolPdfView source={{ uri: url }} />;

Compatibility with react-native-pdf

Overall compatibility: 89%

  • 27/29 props
  • 6/6 source parameters
  • 6/9 types of source uri
  • 39/44 total props supported

Props

PropertyTypeDefaultDescriptioniOSAndroidSupported
sourceobjectnot nullPDF source like {uri:xxx, cache:false}. see the following for detail.✔✔✔
pagenumber1initial page index✔✔✔
scalenumber1.0should minScale<=scale<=maxScale✔✔✔
minScalenumber1.0min scale✔✔✔
maxScalenumber3.0max scale✔✔✔
horizontalboolfalsedraw page direction, if you want to listen the orientation change, you can use react-native-orientation-locker✔✔✔
showsHorizontalScrollIndicatorbooltrueshows or hides the horizontal scroll bar indicator on iOS✔✔
showsVerticalScrollIndicatorbooltrueshows or hides the vertical scroll bar indicator on iOS✔✔
scrollEnabledbooltrueenable or disable scroll✔✔
fitPolicynumber20:fit width, 1:fit height, 2:fit both(default)✔✔✔
spacingnumber10the breaker size between pages✔✔✔
passwordstring""pdf password, if password error, will call OnError() with message "Password required or incorrect password."✔✔✔
styleobject{backgroundColor:"#eee"}support normal view style, you can use this to set border/spacing color...✔✔✔
progressContainerStyleobject{backgroundColor:"#eee"}support normal view style, you can use this to set border/spacing color...✔✔✔
renderActivityIndicator(progress) => Componentwhen loading show it as an indicator, you can use your component✔✔✔
enableAntialiasingbooltrueimprove rendering a little bit on low-res screens, but maybe course some problem on Android 4.4, so add a switch✖✔✖
enablePagingboolfalseonly show one page in screen✔✔✔
enableRTLboolfalsescroll page as "page3, page2, page1"✔✖✔
enableAnnotationRenderingbooltrueenable rendering annotation, notice:iOS only support initial setting,not support realtime changing✔✔✔
enableDoubleTapZoombooltrueEnable double tap to zoom gesture✔✔✔
trustAllCertsbooltrueAllow connections to servers with self-signed certification✔✔✖
singlePageboolfalseOnly show first page, useful for thumbnail views✔✔✔
onLoadProgressfunction(percent)nullcallback when loading, return loading progress (0-1)✔✔✔
onLoadCompletefunction(numberOfPages, path, {width, height}, tableContents)nullcallback when pdf load completed, return total page count, pdf local/cache path, {width,height} and table of contents✔✔✔
onPageChangedfunction(page,numberOfPages)nullcallback when page changed ,return current page and total page count✔✔✔
onErrorfunction(error)nullcallback when error happened✔✔✔
onPageSingleTapfunction(page)nullcallback when page was single tapped✔✔✔
onScaleChangedfunction(scale)nullcallback when scale page✔✔✔
onPressLinkfunction(uri)nullcallback when link tapped✔✔✔

parameters of source

parameterDescriptiondefaultiOSAndroidSupported
uripdf source, see the following for detail.required✔✔✔
cacheuse cache or notfalse✔✔✔
cacheFileNamespecific file name for cached pdf fileSHA1(uri) result✔✔✔
expirationcache file expired seconds (0 is not expired)0✔✔✔
methodrequest method when uri is a url"GET"✔✔✔
headersrequest headers when uri is a url{}✔✔✔

types of source.uri

UsageDescriptioniOSAndroidSupported
{uri:"http://xxx/xxx.pdf"}load pdf from a url✔✔✔
{require("./test.pdf")}load pdf relate to js file (do not need add by xcode)✔✔✔
{uri:"bundle-assets://path/to/xxx.pdf"}load pdf from assets, the file should be at android/app/src/main/assets/path/to/xxx.pdf✖✔✔
{uri:"bundle-assets://xxx.pdf"}load pdf from assets, you must add pdf to project by xcode. this does not support folder.✔✖✔
{uri:"data:application/pdf;base64,JVBERi0xLjcKJc..."}load pdf from base64 string✔✔✔
{uri:"file:///absolute/path/to/xxx.pdf"}load pdf from local file system✔✔✔
{uri:"ms-appx:///xxx.pdf"}}load pdf bundled with UWP app✖✖✖
{uri:"content://com.example.blobs/xxxxxxxx-...?offset=0&size=xxx"}load pdf from content URI✔*✖✖
{uri:"blob:xxxxxxxx-...?offset=0&size=xxx"}load pdf from blob URL✖✔✖

版本与发布记录

@coolsoftwaretyler/cool-pdf 共发布 11 个版本,首次发布于 2025/10/05;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.10latest2025/10/061.1 年前
0.1.92025/10/061.1 年前
0.1.82025/10/061.1 年前
0.1.72025/10/051.1 年前
0.1.62025/10/051.1 年前
0.1.52025/10/051.1 年前

关于 @coolsoftwaretyler/cool-pdf 的常见问题

@coolsoftwaretyler/cool-pdf 是什么?

PDF View Component for Expo

如何安装 @coolsoftwaretyler/cool-pdf?

在项目目录运行 npm install @coolsoftwaretyler/cool-pdf,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:expo(*)、react(*)、react-native(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@coolsoftwaretyler/cool-pdf 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@coolsoftwaretyler/cool-pdf 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@coolsoftwaretyler/cool-pdf 可以商用吗?

@coolsoftwaretyler/cool-pdf 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@coolsoftwaretyler/cool-pdf 的下载量有多少?

根据 npm 官方下载统计,@coolsoftwaretyler/cool-pdf 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,053 次,日均约 68 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@coolsoftwaretyler/cool-pdf 还在维护吗?

最新版本 0.1.10 发布于 2025/10/06(1.1 年前);至今共发布 11 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/10/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。