简体   繁体   English

什么在反应中创建PDF

[英]What to create pdf in react

I am working on a (reactjs + webpack + nodejs + express) application and i have to create pdf of a page. 我正在(reactjs + webpack + nodejs + express)应用程序上工作,我必须创建页面pdf。

I try the following npm packages for that: 我为此尝试了以下npm软件包:

urltopdf This npm package create the pdf of the website,that i pass it as param but when ever i pass the url of reactjs application, i download the blank pdf. urltopdf这个npm包创建网站的pdf,我将其作为参数传递,但是每当我传递reactjs应用程序的url时,我都会下载空白的pdf。 Need your favor inorder to complete this. 需要您的帮助才能完成此操作。

var myurlpdf = require("myurltopdf");
myurlpdf.myurltopdf("http://mind2minds.com", {fileName:"...../filename.pdf"}, function(err){
  if(err){
    console.log(err);
  }else{
    console.log("file created successfully");
  }
});

I also try the pdfkit 我也尝试pdfkit

Thanks 谢谢

A React page isn't static, it's generated through JavaScript. React页面不是静态的,而是通过JavaScript生成的。 I imagine that your HTML document is likely empty, save for the required tags, and an entry div where your React content goes. 我想您的HTML文档可能是空的,除了必需的标签,还有一个React内容所在的条目div。 When you request the page, you are getting a blank page, and this will stay that way unless the JavaScript is run against the page. 当您请求页面时,您将得到一个空白页面,除非对页面运行JavaScript,否则它将保持这种状态。 I don't have a solution, but I don't have enough reputation to put this as a comment. 我没有解决方案,但是我没有足够的声誉来发表意见。

There may be libraries which can handle this in Node.js, but I'm not sure. 在Node.js中可能有可以处理此问题的库,但是我不确定。 This was actually an issue with early search engines. 这实际上是早期搜索引擎的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM