Downloading the PDF file
Let’s use React PDF to generate a PDF file for a product with dynamic content based on the product data provided by the Shopify Storefront API.
Backend code update
Section titled “Backend code update”- Install the React PDF package.
- Update the Storefront API GraphQL query to include the product data needed for the PDF generation.
- Use Read PDF to generate the PDF file.
- Update the Gadget route response to return the PDF file.
Frontend code update
Section titled “Frontend code update”- Use the received PDF data to open it in a new tab as an inline PDF file.