Gathering detailed insights and metrics for @unionpdf/react
Gathering detailed insights and metrics for @unionpdf/react
Gathering detailed insights and metrics for @unionpdf/react
Gathering detailed insights and metrics for @unionpdf/react
npm install @unionpdf/react
Typescript
Module System
Node Version
NPM Version
TypeScript (71.42%)
JavaScript (26.15%)
CSS (1.36%)
C++ (0.45%)
Dockerfile (0.43%)
HTML (0.09%)
Shell (0.09%)
Makefile (0.02%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
16 Stars
239 Commits
2 Forks
2 Watchers
2 Branches
2 Contributors
Updated on Jul 08, 2025
Latest Version
0.34.0
Package Id
@unionpdf/react@0.34.0
Unpacked Size
1.57 MB
Size
255.09 kB
File Count
16
NPM Version
10.7.0
Node Version
18.20.4
Published on
Jul 03, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
3
22
This pacakge contains several React components for showing PDF files on Web.
1npm install @unionpdf/react
1function App() { 2 const engine = createMockPdfEngine(); 3 const pdfAppElemRef = useRef<HTMLDivElement>(null); 4 const [viewport, setViewport] = useState({ x: 0, y: 0 }); 5 6 useLayoutEffect(() => { 7 const pdfAppElem = pdfAppElemRef.current; 8 if (pdfAppElem) { 9 const style = getComputedStyle(pdfAppElem); 10 console.log(style.height, style.width); 11 } 12 }, [pdfAppElemRef.current]); 13 14 return ( 15 <PdfNativeAdapterProvider> 16 <div className="App"> 17 <LoggerContextProvider logger={logger}> 18 <ThemeContextProvider 19 theme={{ 20 background: 'blue', 21 }} 22 > 23 <PdfApplicationContextProvider provider={provider}> 24 <PdfEditorStampsContextProvider 25 stamps={stamps} 26 onAddStamp={addStamp} 27 onRemoveStamp={removeStamp} 28 > 29 <PdfEngineContextProvider engine={engine}> 30 <PdfApplication> 31 <PdfNavigatorContextProvider> 32 <PdfDocument 33 file={file} 34 password={password} 35 onOpenSuccess={() => { 36 setIsPasswordOpened(false); 37 }} 38 onOpenFailure={(error: PdfEngineError) => { 39 if (error.code === PdfiumErrorCode.Password) { 40 setIsPasswordOpened(true); 41 } 42 }} 43 > 44 <PdfEditorContextProvider> 45 <PdfToolbar onClose={closeFile} /> 46 <PdfPageAnnotationComponentContextProvider 47 component={PdfPageDefaultAnnotation} 48 > 49 <PdfLinkAnnoContextProvider 50 onClick={(evt, annotation) => { 51 console.log(evt, annotation); 52 }} 53 > 54 <PdfPages 55 prerenderRange={[-1, 1]} 56 cacheRange={[-1, 1]} 57 pageLayers={[ 58 PdfPageCanvasLayer, 59 PdfPageTextLayer, 60 PdfPageAnnotationsLayer, 61 PdfPageEditorLayer, 62 ]} 63 /> 64 </PdfLinkAnnoContextProvider> 65 </PdfPageAnnotationComponentContextProvider> 66 <PdfMetadata /> 67 <PdfThumbnails 68 layout={{ 69 direction: 'vertical', 70 itemsCount: 2, 71 }} 72 size={{ width: 100, height: 100 }} 73 scaleFactor={0.25} 74 /> 75 <PdfBookmarks /> 76 <PdfSearchPanel /> 77 <PdfAttachments /> 78 <PdfSignatures /> 79 <PdfDownloader /> 80 <PdfPrinter method={PrinterMethod.Iframe} /> 81 <PdfEditor /> 82 </PdfEditorContextProvider> 83 </PdfDocument> 84 </PdfNavigatorContextProvider> 85 </PdfApplication> 86 </PdfEngineContextProvider> 87 </PdfEditorStampsContextProvider> 88 </PdfApplicationContextProvider> 89 </ThemeContextProvider> 90 </LoggerContextProvider> 91 </div> 92 </PdfNativeAdapterProvider> 93 ); 94}
Every pdf page contains multiple layers, like canvas layer for rendering content or annotation layer for showing differnt kinds of annotations
Of course, you can build your own pdf page layer, every layer is a React component that will be rendered into pdf page
Below shows how to display the page number in the bottom of every pdf page
1function PdfPageNumber(props: { index: number }) { 2 return ( 3 <div 4 className="pdf__page__number" 5 style={{ 6 color: 'white', 7 position: 'absolute', 8 bottom: 0, 9 left: '50%', 10 transform: 'translate(-50%, -50%)', 11 }} 12 > 13 {index + 1} 14 </div> 15 ); 16} 17 18<PdfPages 19 visibleRange={[-1, 1]} 20 viewport={viewport} 21 pageLayers={[PdfPageCanvasLayer, PdfPageNumber]} 22/>;
For the full code you can check the demo app
Canvas Layer
This layer will render PDF content into canvas
Text Layer
This layer will display PDF text in HTML Node
Annotation Layer
This layer will display annotations, supported annotations including
3.1 Link
3.2 Text
3.3 Widget (Basic ArcoForm, XFA is not supported yet)
Editor Layer
This layer is for editing pdf files, supports features
4.1 drawing new ink annotations 4.2 move annotations through drag and drop
Also, it has build in support for undo/redo.
Decoration Layer This laywer is for showing dynamic decoration on pdf page, which won't save to pdf file
A PDF Plugin is a component that can add specific functionalty to PDF document. In the plugins folder, there are several buildin plugins.
To build a pdf plugin, you just need to use hooks usePdfDocument and usePdfEngine to provide functionalities. Do note that you should avoid coupling between plugins.
No vulnerabilities found.
No security vulnerabilities found.