To view a base64 encoded PDF in React, you can use the following code:

Copy codeimport React from "react";

const ViewPdf = ({ base64 }) => {
  return (
      style={{ width: "100%", height: "100%" }}

export default ViewPdf;

This component uses an iframe element with a src attribute that is set to the base64 encoded PDF. The src attribute is set using a data URI, which allows you to embed the PDF directly in the HTML without needing to link to an external file.

To use the component, you can pass the base64 encoded PDF as a prop to the component like this:

Copy code<ViewPdf base64={base64EncodedPdf} />

This will render the PDF in the component, allowing the user to view it in the browser.

I hope this helps! Let me know if you have any other questions or if there’s anything else I can do to assist.

(Visited 1 times, 1 visits today)
Was this article helpful?
Close Search Window