2023-12-21 18:36:51 +08:00

93 lines
3.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 属性
## src
- 类型String, ArrayBuffer, Blob
文档地址文件在CDN或服务器上的地址或者是通过FileReader读取的文件ArrayBuffer或者Blob格式。
## request-options
- 类型Object
如果属性src是个文件地址组件内部会通过window.fetch进行请求对应window.fetch的请求参数可以用来设置header等请求信息。
## options
- 类型: Object
预览需要的一些特殊配置,不同预览组件可配置项各不相同。
- excel预览
excel相关的配置目前支持配置项很少。
minColLength: excel最少渲染多少列如果想实现xlsx文件内容有几列就渲染几列可以将此值设置为0.
minRowLength: excel最少渲染多少行如果想实现根据xlsx实际函数渲染可以将此值设置为0.
widthOffset在默认渲染的列表宽度上再加 Npx宽
heightOffset在默认渲染的列表高度上再加 Npx高
transformData在预览之前可以通过transformData对即将渲染数据及样式进行修改
```javascript
{
"minColLength": 20,
"minRowLength": 100,
"widthOffset": 10, //在默认渲染的列表宽度上再加10px宽
"heightOffset": 10, //在默认渲染的列表高度上再加10px高
"transformData": function (workbookData){
//修改workbookData
return workbookData;
}
}
```
- docx预览
docx预览组件支持的可配置项如下
```typescript
{
className: string = "docx", //class name/prefix for default and document style classes
inWrapper: boolean = true, //enables rendering of wrapper around document content
ignoreWidth: boolean = false, //disables rendering width of page
ignoreHeight: boolean = false, //disables rendering height of page
ignoreFonts: boolean = false, //disables fonts rendering
breakPages: boolean = true, //enables page breaking on page breaks
ignoreLastRenderedPageBreak: boolean = false, //disables page breaking on lastRenderedPageBreak elements
experimental: boolean = false, //enables experimental features (tab stops calculation)
trimXmlDeclaration: boolean = true, //if true, xml declaration will be removed from xml documents before parsing
useBase64URL: boolean = false, //if true, images, fonts, etc. will be converted to base 64 URL, otherwise URL.createObjectURL is used
useMathMLPolyfill: boolean = false, //includes MathML polyfills for chrome, edge, etc.
showChanges: false, //enables experimental rendering of document changes (inserions/deletions)
debug: boolean = false, //enables additional logging
}
```
- pdf预览
pdf 预览组件支持的可配置项如下
```javascript
const options = {
width: 500, //number可不传用来控制pdf预览的宽度默认根据文档实际宽度计算
httpHeaders: {}, //object, Basic authentication headers
password: '', //string, 加密pdf的密码
//更多配置参见 https://mozilla.github.io/pdf.js/api/draft/module-pdfjsLib.html
}
```
## staticFileUrl [pdf特有属性]
- 类型: String
pdf渲染时可能会请求一些bcmap文件这些文件默认从 https://unpkg.com/pdfjs-dist@3.1.81/ 加载但是可能存在网络不通问题如果遇到这种问题可以将这些文件放到自己静态目录然后修改该属性告诉组件去这里请求bcmap文件。
涉及的文件存放在当前github项目中examples/public/cmaps目录下可将cmaps目录复制到你的静态服务目录下然后修改staticFileUrl为cmaps文件夹对应的父地址必须已http或https开头如 http://yourdomain/static/