在React中发布文本和图像给PDF

发布于 2025-01-26 16:38:34 字数 104 浏览 2 评论 0原文

我正在尝试创建一个博客文章网站,任何人都可以发布任何内容。而且,任何用户都可以一次点击下载任何帖子。因此,是否可以实现一个按钮,以下载除侧菜单除外并在React中发表评论以外的整个特定帖子内容。

I'm trying to create a blog post website where anyone can post anything. And also any user can download any post in one click. So is it possible to implement a button for download whole specific post content except side menus and comment in react.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多像笑话 2025-02-02 16:38:34

我假设您想让用户能够下载博客文章(React组件)为PDF。

查看 robin wieruch

您基本上要做的是创建参考对于您的组件,然后使用HTML2Canvas NPM软件包将其转换为画布,然后将其转换为图像数据。

使用PDFJS NPM软件包将图像数据添加到PDF中并下载。

有关详细信息,请参见链接。

I assume you want to give the user the ability to download a blog post (react component) as pdf.

Check out this tutorial by Robin Wieruch

What you basically do is create a ref for your component and then convert it to a canvas with html2canvas npm package, then to image data.

The image data is added to a pdf with pdfjs npm package and downloaded.

See the link for details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文