node.js - react-pdf 从后端 url 渲染图像不加载图像
问题描述
我正在尝试使用react-pdf呈现 pdf我面临的问题是我正在使用 URL 显示来自后端服务器的图像。但它在pdf中显示为空白。当我进一步调试时才知道,当我在突出显示的行上放置断点时,图像就会显示出来。可能没有时间从远程 URL 加载图像?
<Page size="A4" style={styles.page}>
{this.state.productsToBeExported.map((product) => {
const img = this.getImageSource(product);
//if breakpoint is added here then the images are displayed
return (
<View
key={product.productId}
style={styles.section}
>
<Image
style={{
width: imgWidth + "px",
border: "2pt solid #999898",
}}
src={img}
></Image>
</View>)
});
</Page>
//remote Image Url (Node server)
getImageSource(product) {
return `${URL}/${this.props.timestamp}/${product.productId}.jpg`;
}
任何帮助将非常感激。
注意:这些图像是在后端动态生成的。所以我不能导入它们。
解决方案
我遇到了同样的问题,这似乎是 react-pdf 的问题。它似乎只显示带有.jpeg
扩展名的文件
推荐阅读
- javascript - 如何使用自定义参数创建函数
- python - 如何加速 numpy.all 和 numpy.nonzero()?
- python - 如何读取核分割数据集的 TCGA 注释格式?
- python-3.x - 我一直在寻找在 Python3 中以 Json 格式返回多个 SQL 结果的方法
- mysql - 如何打破每个月的日期范围
- python - 如何在我的命令行中显示消息文本?
- quarkus - 原生 Quarkus 应用程序是否比 JVM 上的更好?
- python - Python netmiko 无法安装 - pynacl 的问题
- python - 为什么只删除产品,而不是其相关动作?
- c - 检查进程是否正在运行的问题