Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👑 [需求]实现ant design pro 文档预览,如pdf,world,excel,png等 #10032

Closed
buxinren opened this issue Jul 16, 2022 · 5 comments
Closed

Comments

@buxinren
Copy link

🥰 需求描述 | Requirements description

使用 react-file-viewer 实现ant design pro 文档预览,如pdf,world,excel,png等。
有没有哪位大佬使用上述插件实现过,我这面报错
image

import { Button } from 'antd';
import React from 'react';
//react文件预览支持docx,xlsx
import FileViewer from 'react-file-viewer';
//react预览pdf文件插件
import PDF from 'react-pdf-js';
import styles from './styles.less';
import xiangmu from '@/assets/DocumentSharing/项目建议书.docx';
import { PageContainer } from '@ant-design/pro-layout';

const index = () => {
//const w = require('../../assets/DocumentSharing/项目建议书.docx');
const type = 'docx';

return (

<FileViewer
fileType={type} //文件类型
//filePath="../../assets/DocumentSharing/项目建议书.docx" //文件地址(后台给返的二进制流也可以)
filePath={xiangmu}
//onError={this.onError.bind(this)} //函数[可选]:当文件查看器在获取或呈现请求的资源时发生错误时将调用的函数。在这里可以传递日志记录实用程序的回调。
errorComponent={console.log('出现错误')} //[可选]:发生错误时呈现的组件,而不是react-file-viewer随附的默认错误组件。
unsupportedComponent={console.log('不支持')} //[可选]:在不支持文件格式的情况下呈现的组件。
/>

);
};

export default index;

@github-actions
Copy link

以下的 Issues 可能会帮助到你 / The following issues may help you

@chenshuai2144
Copy link
Collaborator

阿里云可以买到这个服务的,这不是前端能单独做到的事情

@pkaq
Copy link
Contributor

pkaq commented Aug 14, 2022

kkFileView 了解一下?

@wangxing0204
Copy link

我之前也想用这个,安装失败,现在统一做的处理是将他们转为pdf 然后进行预览

@eternallycyf
Copy link

别用了吧 几年不维护了。那个word excel基本样式全乱掉。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants