
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
@llamaindex/pdf-viewer
Advanced tools
PDF viewer component as used by secinsights. Using react-pdf.
npm install @llamaindex/pdf-viewer
import React from 'react';
import '@llamaindex/pdf-viewer/index.css';
import { PDFViewer, PdfFocusProvider } from '@llamaindex/pdf-viewer';
const file = {
id: 'sample-document',
url: 'https://d687lz8k56fia.cloudfront.net/sec-edgar-filings/0001045810/10-Q/0001045810-22-000147/filing-details.pdf',
};
function App() {
return (
<div className="AppContainer">
<PdfFocusProvider>
<PDFViewer file={file} />
</PdfFocusProvider>
</div>
);
}
<PdfFocusProvider>
<PDFViewer containerClassName="your-container-class-name" file={file} />
</PdfFocusProvider>
<PdfFocusProvider>
<div className="your-layout-class-name">
<PDFViewer file={file1} />
<PDFViewer file={file2} />
<PDFViewer file={file3} />
</div>
</PdfFocusProvider>
NextJs applications may need to update their configuration to be compatible with react-pdf v9 and pdfjs v4
If you have issues related to canvas, you can add the following to your next.config.js
:
module.exports = {
+ webpack: (config) => {
+ config.resolve.alias.canvas = false;
+ return config;
+ },
}
Another common issue is: TypeError: Promise.withResolvers is not a function
To fix this issue, you need to use dynamic imports for the PDF component (to indicate to NextJs to use it for client-side rendering only).
- import { PDFViewer, PdfFocusProvider } from "@llamaindex/pdf-viewer";
+ import dynamic from "next/dynamic";
+ // Dynamic imports for client-side rendering only
+ const PDFViewer = dynamic(
+ () => import("@llamaindex/pdf-viewer").then((module) => module.PDFViewer),
+ { ssr: false },
+ );
+ const PdfFocusProvider = dynamic(
+ () =>
+ import("@llamaindex/pdf-viewer").then((module) => module.PdfFocusProvider),
+ { ssr: false },
+ );
When making changes to this project, please follow these steps:
yarn changeset
yarn new-version
yarn release
Thanks to the developers of the following dependencies that we're using:
FAQs
React PDF viewer for LLM applications
We found that @llamaindex/pdf-viewer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.