简体   繁体   中英

Send Rendered React component to Function App(Node Js) in AZURE to create a PDF

I have to generate a PDF when the user click the button in react. I have tried client side genaration for PDF, which doesn't seem to render well for smartphones. So I am doing the same in node Js but this is hosted as a function app in Azure, and react part as a web app.

I am using handler and puppeteer to generate pdf and store it in a blob. How do I generate HTML dynamically for each request or send the whole component as a payload from the web app.

Instead of sending HTML, you could probably try to send a Deep Link to the exact view, have puppeteer render it and generate the PDF.

Downsides of this would be

  1. Would have to impersonate the user if authentication is required
  2. Would have to have lots of security implications to think about for avoiding misuse and data leaks

Also, you could build a separate service for doing this instead of trying to generate from the client application markup.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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