Adding these lines seems to fix the code for me:
const bytes = new Uint8Array( pdfBytes );
const blob = new Blob( [ bytes ], { type: "application/pdf" } );
const docUrl = URL.createObjectURL( blob );
setPdfInfo( docUrl );
Or use it directly:
return <iframe src={docUrl} type="application/pdf" />
Answer from Saed Jaber on Stack Overflownpm
npmjs.com › package › pdf-lib
pdf-lib - npm
react-native-pdf-lib is a PDF generation and modification library for React Native environments.
» npm install pdf-lib
Published Nov 06, 2021
Version 1.17.1
Author Andrew Dillon
Repository https://github.com/Hopding/pdf-lib
Homepage https://pdf-lib.js.org/
PDF-LIB
pdf-lib.js.org
PDF-LIB · Create and modify PDF documents in any ...
Works in any JavaScript runtime, including browsers, Node, Deno, and even React Native. Add, insert, and remove pages. Split a single PDF into separate ones. Or merge multiple PDFs into a single document.
Videos
11:14
Build a React.js Canvas PDF Editor & Renderer in Browser Using ...
11:58
Build a React.js PDF-LIB PDF Viewer & Editor to Add ...
03:44
Build a React.js jsPDF & PDF-LIB PDF Editor & Renderer With Live ...
React.js PDF-LIB Project to Export Multiple Images to PDF ...
14:28
This React PDF-Viewer Component Is Amazing! - YouTube
15:35
How to generate PDF in React using React pdf - YouTube
React-pdf
react-pdf.org
React-pdf
React renderer for creating PDF files on the browser and server
Adding these lines seems to fix the code for me:
const bytes = new Uint8Array( pdfBytes );
const blob = new Blob( [ bytes ], { type: "application/pdf" } );
const docUrl = URL.createObjectURL( blob );
setPdfInfo( docUrl );
Or use it directly:
return <iframe src={docUrl} type="application/pdf" />
Answer from Saed Jaber on Stack Overflow Top answer 1 of 4
9
Adding these lines seems to fix the code for me:
const bytes = new Uint8Array( pdfBytes );
const blob = new Blob( [ bytes ], { type: "application/pdf" } );
const docUrl = URL.createObjectURL( blob );
setPdfInfo( docUrl );
Or use it directly:
return <iframe src={docUrl} type="application/pdf" />
2 of 4
1
What I did and worked: I added a reference to the iframe instance:
import React, { useState, useEffect, useRef } from 'react';
const LoadPDF = () => {
...
const viewer = useRef(null);
const modifyPDF = async () => {
...
};
return (
<>{<iframe title="test-frame" src={pdfInfo} ref={viewer} type="application/pdf" />}</>
);
}
Mozilla
mozilla.github.io › pdf.js
PDF.js - Home
A general-purpose, web standards-based platform for parsing and rendering PDFs.
GitHub
github.com › Hopding › react-native-pdf-lib
GitHub - Hopding/react-native-pdf-lib: Library for creating and editing PDFs in React Native.
This library's purpose is to fill the gap that currently exists in the React Native ecosystem for PDF creation and editing. It aims to provide an easy, simple, and consistent API for both creating new and editing existing PDF documents in React ...
Starred by 200 users
Forked by 78 users
Languages C 75.5% | C++ 22.6% | Objective-C++ 0.9% | Java 0.7% | JavaScript 0.3% | Ruby 0.0%
Honeybadger
honeybadger.io › blog › pdf-node
Managing PDFs in Node.js with pdf-lib - Honeybadger Developer Blog
November 16, 2023 - As your PDF manipulation needs evolve, you'll often find yourself needing to modify existing PDF documents. pdf-lib offers a versatile set of tools to help you efficiently make changes to PDFs. In this section, we'll dive into more detail about how to load, edit, and save modifications to existing PDFs using pdf-lib. Before you can modify an existing PDF, you need to load it into a PDFDocument instance.
GitHub
github.com › Shogobg › rn-pdf-lib
GitHub - Shogobg/rn-pdf-lib: Library for creating and editing PDFs in React Native.
Starred by 10 users
Forked by 2 users
Languages C 75.4% | C++ 22.6% | Objective-C++ 0.9% | Java 0.8% | JavaScript 0.3% | Ruby 0.0%
npm
npmjs.com › package › react-pdf
react-pdf - npm
October 9, 2025 - Display PDFs in your React app as easily as if they were images.. Latest version: 10.2.0, last published: 2 months ago. Start using react-pdf in your project by running `npm i react-pdf`. There are 985 other projects in the npm registry using ...
» npm install react-pdf
Published Oct 09, 2025
Version 10.2.0
Author Wojciech Maj
Repository https://github.com/wojtekmaj/react-pdf
Reddit
reddit.com › r/reactjs › best library for showing a pdf in react
r/reactjs on Reddit: Best library for showing a pdf in react
December 2, 2022 -
Hey, I wanted to find out a library in react which can display a pdf from a url. So far I have tried react-pdf from wojtekmaj, it works just fine but I wanted a free library which can provide toolbars also. Let me know if you know any library or a way to build it.
Thanks
Top answer 1 of 5
38
If you don't need direct control over the PDF in any way, then just use an IFrame. It'll make the browser use their default viewer, which is generally a pretty decent one. There's also one made by Mozilla ( PDF.js ), but any PDF viewer is going to be pretty heavy in terms of code size.
2 of 5
6
SimplePDF embed for React will allow you to not only display PDFs but also edit them: Add text, pictures, signatures Add, remove, rotate pages Disclosure: I’m the developer behind SimplePDF
JSFiddle
jsfiddle.net › Hopding › vcwmfnbe › 2
Set Document Metadata (pdf-lib) - JSFiddle - Code Playground
JSFiddle - Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle.
Stack Overflow
stackoverflow.com › questions › tagged › pdf-lib.js
Highest scored 'pdf-lib.js' questions - Stack Overflow
I am trying to add links to a PDF document using the pdf-lib JavaScript library. When I open the PDF in a browser and click on a link, it opens the website, but it does so in the same browser tab.
CloudDefense.ai
clouddefense.ai › code › javascript › example › pdf-lib
Top 10 Examples of pdf-lib code in Javascript
Since this is a Node script, we can just // save the `pdfBytes` to the file system, where it can be opened with a PDF // reader. const filePath = `${__dirname}/modified.pdf`; fs.writeFileSync(filePath, pdfBytes); console.log(`PDF file written to: ${filePath}`); ... // JavaScript runtime (e.g. ...