Skip to content

pdf 预览无法显示文字 #23

@laixiaohuai

Description

@laixiaohuai
Image

Vue3
@flyfish-group/file-viewer3: 1.0.22

setup 模式 lang="ts"

import { FileViewer } from '@flyfish-group/file-viewer3'

渲染代码:
const response = await fetch(data.value.url)
data.value.name = data.value.name || 'unknown'
const contentDisposition = response.headers.get('Content-Disposition')
if (contentDisposition) {
const filenameMatch = contentDisposition.match(/filename[^;=\n]=((['"]).?\2|[^;\n]*)/)
if (filenameMatch && filenameMatch[1]) {
data.value.name = filenameMatch[1].replace(/['"]/g, '')
}
}

// 将 .conf 和 .cfg 文件扩展名替换为 .txt
const confExtensions = ['.conf', '.cfg']
confExtensions.forEach((ext) => {
if (data.value.name && data.value.name.endsWith(ext)) {
data.value.name = data.value.name.replace(new RegExp(${ext}$), '.txt')
}
})

const blob = await response.blob()

file.value = new File([blob], data.value.name, {
type: blob.type,
})

google浏览器。

麻烦大佬帮吗看看原因

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions