跳至正文
Wener Notes

ReactPDF

约 1 分钟阅读
标签:React
TSX
export const PDFViewer = ({ title, style, className, children, innerRef, showToolbar = true, ...props }) => {
  const [instance, updateInstance] = usePDF();

  useEffect(() => updateInstance(children), [children]);

  const src = instance.url ? `${instance.url}#toolbar=${showToolbar ? 1 : 0}` : null;

  return <iframe src={src} title={title} ref={innerRef} style={style} className={className} {...props} />;
};

FAQ

The "windows-1252" encoding is not supported

  • fontkit
JavaScript
new TextDecoder('ascii');
text
RangeError [ERR_ENCODING_NOT_SUPPORTED]: The "windows-1252" encoding is not supported

fix

bash
apk add icu-data-full

关联信息

反向链接、本文链接的其他页面和外部资料。

反向链接

  • PDF
    笔记 · React PDF

    analyzer/debugger · hyzyla/pdf-debugger · 显示 pdfjs 的解析结果 · https://github.com/itext/i7j-rups (java -jar /Downloads/itext-rups-7.2.5.jar)

参考资料

GitHub4 条
其他外链1 条
最近更新commit d8b44e6编辑