Commit 3102a879 by weiw

fix:隐藏工具栏的相关配置

parent eb51f0f7
...@@ -8,12 +8,7 @@ interface PdfPreviewProps { ...@@ -8,12 +8,7 @@ interface PdfPreviewProps {
onError?: (error: any) => void onError?: (error: any) => void
} }
export const PdfPreview: React.FC<PdfPreviewProps> = ({ export const PdfPreview: React.FC<PdfPreviewProps> = ({ src, className = '', onLoaded, onError }) => {
src,
className = '',
onLoaded,
onError,
}) => {
const handleLoad = () => { const handleLoad = () => {
onLoaded?.() onLoaded?.()
} }
...@@ -22,11 +17,21 @@ export const PdfPreview: React.FC<PdfPreviewProps> = ({ ...@@ -22,11 +17,21 @@ export const PdfPreview: React.FC<PdfPreviewProps> = ({
onError?.(new Error('PDF加载失败')) onError?.(new Error('PDF加载失败'))
} }
// 完整的PDF参数配置
// toolbar=0 隐藏工具栏 0=隐藏, 1=显示
// navpanes=0 隐藏导航面板 0=隐藏, 1=显示
// scrollbar=0 隐藏滚动条 0=隐藏, 1=显示
// statusbar=0 隐藏状态栏 0=隐藏, 1=显示
// messages=0 隐藏消息栏 0=隐藏, 1=显示
// view=FitH 设置视图模式 FitH=水平适应, FitV=垂直适应
// zoom=page-width 设置缩放模式 page-width=页面宽度
const pdfUrl = `${src}#toolbar=0&navpanes=0&scrollbar=0&view=FitH&statusbar=0&messages=0&zoom=page-width`
return ( return (
<div className={`${className} h-full flex flex-col`}> <div className={`${className} h-full flex flex-col`}>
<div className="flex-grow overflow-hidden bg-gray-100"> <div className="flex-grow overflow-hidden bg-gray-100">
<embed <embed
src={src} src={pdfUrl}
type="application/pdf" type="application/pdf"
className="w-full h-full border-0" className="w-full h-full border-0"
onLoad={handleLoad} onLoad={handleLoad}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment