Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@react-pdf-viewer/core
Advanced tools
@react-pdf-viewer/core is a React library that provides a set of components and hooks to easily integrate PDF viewing capabilities into your React applications. It offers a customizable and extensible way to display PDF documents, navigate through pages, zoom in and out, and more.
Basic PDF Viewer
This code demonstrates how to set up a basic PDF viewer using the @react-pdf-viewer/core package. It includes the necessary imports and sets up the Worker and Viewer components to display a PDF file.
import { Worker, Viewer } from '@react-pdf-viewer/core';
import '@react-pdf-viewer/core/lib/styles/index.css';
const App = () => (
<div>
<Worker workerUrl={`https://unpkg.com/pdfjs-dist@2.6.347/build/pdf.worker.min.js`}>
<Viewer fileUrl='/path/to/your/pdf-file.pdf' />
</Worker>
</div>
);
Custom Toolbar
This code demonstrates how to create a custom toolbar for the PDF viewer. It uses the Toolbar component and slots to include buttons for toggling the sidebar, navigating pages, and zooming in and out.
import { Worker, Viewer, ToolbarSlot, Toolbar } from '@react-pdf-viewer/core';
import '@react-pdf-viewer/core/lib/styles/index.css';
const App = () => (
<div>
<Worker workerUrl={`https://unpkg.com/pdfjs-dist@2.6.347/build/pdf.worker.min.js`}>
<Toolbar>
{(slots: ToolbarSlot) => (
<>
{slots.toggleSidebarButton}
{slots.previousPageButton}
{slots.nextPageButton}
{slots.zoomOutButton}
{slots.zoomInButton}
</>
)}
</Toolbar>
<Viewer fileUrl='/path/to/your/pdf-file.pdf' />
</Worker>
</div>
);
Thumbnail View
This code demonstrates how to add a thumbnail view to the PDF viewer using the ThumbnailPlugin. It initializes the plugin and includes it in the Viewer component's plugins array.
import { Worker, Viewer, ThumbnailPlugin } from '@react-pdf-viewer/core';
import '@react-pdf-viewer/core/lib/styles/index.css';
const thumbnailPluginInstance = ThumbnailPlugin();
const App = () => (
<div>
<Worker workerUrl={`https://unpkg.com/pdfjs-dist@2.6.347/build/pdf.worker.min.js`}>
<Viewer fileUrl='/path/to/your/pdf-file.pdf' plugins={[thumbnailPluginInstance]} />
</Worker>
</div>
);
react-pdf is a popular library for displaying PDF documents in React applications. It provides a simple API for rendering PDFs and supports features like text selection, annotations, and more. Compared to @react-pdf-viewer/core, react-pdf is more focused on basic PDF rendering and may require additional customization for advanced features.
pdf-viewer-reactjs is another library for embedding PDF viewers in React applications. It offers basic functionalities like page navigation and zooming. However, it is less customizable and extensible compared to @react-pdf-viewer/core, making it suitable for simpler use cases.
pdfjs-dist is the official PDF.js library from Mozilla, which can be used to build custom PDF viewers. While it provides a lot of flexibility and control, it requires more effort to integrate into a React application compared to @react-pdf-viewer/core, which offers ready-to-use components and hooks.
FAQs
A React component to view a PDF document
The npm package @react-pdf-viewer/core receives a total of 65,957 weekly downloads. As such, @react-pdf-viewer/core popularity was classified as popular.
We found that @react-pdf-viewer/core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.