React native pdf在webview中只显示第一页



从WebView (expo project)中渲染的api中获取base64

在webview中渲染对象和iframe后,我得到了所需的pdf,但我只能看到第一页,而不能滚动页面

<WebView
javaScriptEnabled={true}
scrollEnabled={false}
source={{
html: `
<div style="display:flex;height:100%">
<object style="margin:auto" width data="data:application/pdf;base64, ${pdf64}" type="application/pdf">
<iframe style="width:'100%;height:100%" src="https://docs.google.com/viewer?&embedded=true"></iframe>
</object>
</div>
`,
}}
/>

这是当前运行的代码

请尝试将您的代码包装在ScrollView中以使内容可见/可滚动。参考下面的例子

const [pdfData, setPdfData] = useState("");
let image = "data:application/pdf;base64, ${yourPdfBase64}";
setPdfData(image);
<SafeAreaView style={{flex: 1}}>
<ScrollView
style={{ width: '100%' }}
contentContainerStyle={{ flexGrow: 1 }}>
<WebView
useWebKit={true}
originWhitelist={['*']}
scrollEnabled={true}
mediaPlaybackRequiresUserAction={true}
source={{
html: `
<html>
<object data="${pdfData}" type="application/pdf">
<embed 
scrollbar="1" 
src="${pdfData}" 
type="application/pdf" 

/>
</object>
</html>
`}}
/>
</ScrollView>
</SafeAreaView>