A react library to render pdf document in html. Latest version: 1.0.0, last published: 9 months ago. Start using react-pdfjs-dist in your project by running `npm i react-pdfjs-dist`. There are no other projects in the npm registry using react-pdfjs-dist.
其实就是pdfjs库,只是对其进行打包发布到npm了 直接根据官方文档的案例对比进行操作就行了 PDF.js - Examplesmozilla.github.io/pdf.js/examples/ import{useEffect,useRef}from'react'import*asPDFJSfrom'pdfjs-dist'PDFJS.GlobalWorkerOptions.workerSrc=`//unpkg.com/pdfjs-dist@${pdfjs.version}/legacy/bu...
npm install react-pdf@8.0.2 -S 1、PC端的使用 1.1、封装一个组件:PdfViewModal.tsx import React, { useState } from 'react'import { Modal, Spin, Alert } from'antd'import { Document, Page, pdfjs } from'react-pdf'import'react-pdf/dist/esm/Page/AnnotationLayer.css'import'react-pdf/dist/...
Add pdfjs-viewer to your project by executingnpm install pdfjs-vieweroryarn add pdfjs-viewer. Usage Here's an example of basic usage: importReact,{Component}from'react'; importPropTypesfrom'prop-types'; importPdfViewerfrom'pdfjs-viewer'; ...
在React项目中使用pdf.js来查看和渲染PDF文件,你可以按照以下步骤进行: 在React项目中安装pdf.js库: 首先,你需要在你的React项目中安装pdf.js库。这可以通过npm来完成。 bash npm install pdfjs-dist 导入pdf.js库到React组件中: 在你的React组件中,你需要导入pdf.js库以及worker文件。 javascript import * as...
参考文档 https://www.npmjs.com/package/react-pdf https://github.com/wojtekmaj/react-pdf#readme 一、概述 react项目中,很多时候(尤其是需展示报告的页面)会遇到需要预览pdf文件的需求。而据调研,使用react
pdf.js 快速搭建项目 > yarn create vite pdf-preview --template react-ts 现在我们安装下pdf.js 通过官网的介绍,并没有发现 npm 的下载方式,这时候很多人估计就会直接安装 umd 版本的了,其实使用一个库除了看文档,看官方案例也是非常重要的,通过源代码下的examples/webpack/main.js文件,我们看到pdfjs-dist这...
npm i alloyfinger@0.1.7 npm install css3transform 2.封装React pdf 预览组件 import React, {Component} from 'react'; import PropTypes from 'prop-types'; import PDFJS from 'pdfjs-dist'; import styles from './index.scss'; import {isPdfFile} from './../../utils/utils'; ...
前端实现PDF预览有多种选择,其中pdfjs-dist是pdf.js库的npm版本,直接使用官方文档案例可操作,但相对较繁琐。为简化过程,react-pdf对pdfjs-dist进行了封装,使得操作更为简便,但功能有限,需要自定义实现。对于更全面的需求,pdf-viewer是Vite和React环境下的选择,通过引入其build和web文件夹并以...
Simple react PDF viewer component with controls based on PDF.js.. Latest version: 2.2.3, last published: 4 years ago. Start using pdf-viewer-reactjs in your project by running `npm i pdf-viewer-reactjs`. There are 4 other projects in the npm registry usi