react-pdfobject
Version:
A React component for PDFObject
100 lines (77 loc) • 2.27 kB
Markdown
for [PDFObject](https://github.com/pipwerks/PDFObject) .
```sh
npm install react-pdfobject
```
```ts
import * as React from 'react'
import { PDFObject } from 'react-pdfobject'
<PDFObject url="path/to/example.pdf" />
```
```ts
interface Props {
url: string;
containerId?: string;
containerProps?: React.HTMLProps<HTMLDivElement>;
width?: string;
height?: string;
page?: string | number;
id?: string;
fallbackLink?: string | false;
pdfOpenParams?: OpenParams;
PDFJS_URL?: string;
forcePDFJS: boolean;
assumptionMode: boolean;
}
export interface OpenParams {
page?: number;
zoom?: ZoomMode;
nameddest?: string;
pagemode?: PageMode;
view?: ViewMode;
}
export type ZoomMode = 'scale' | 'scale,left,top';
export type PageMode = 'bookmarks' | 'thumbs' | 'none';
export type ViewMode =
| 'Fit'
| 'FitH'
| 'FitH,top'
| 'FitV'
| 'FitV,left'
| 'FitB'
| 'FitBH'
| 'FitBH,top'
| 'FitBV'
| 'FitBV,left';
```
```ts
if(PDFObject.supportsPDFs){
console.log("Yay, this browser supports inline PDFs.");
} else {
console.log("Boo, inline PDFs are not supported by this browser");
}
```
```ts
console.log(PDFObject.pdfobjectversion); //"2.1.1"
```
ref: https://pdfobject.com/#api
[ ][license-url]
© sugarshin
[ ]: https://circleci.com/gh/sugarshin/react-pdfobject/tree/master.svg?style=svg&circle-token=5faa6707fd0e1803cf6e01a16b6bacaba92b23b3
[ ]: https://circleci.com/gh/sugarshin/react-pdfobject/tree/master
[ ]: https://codecov.io/gh/sugarshin/react-pdfobject/branch/master/graph/badge.svg
[ ]: https://codecov.io/gh/sugarshin/react-pdfobject
[ ]: https://img.shields.io/npm/v/react-pdfobject.svg?style=flat-square
[ ]: https://www.npmjs.org/package/react-pdfobject
[ ]: https://img.shields.io/:license-mit-blue.svg?style=flat-square
[ ]: https://sugarshin.mit-license.org/
[![CircleCI][circleci-image]][circleci-url]
[![Codecov][codecov-image]][codecov-url]
[![npm version][npm-image]][npm-url]
[![License][license-image]][license-url]
A React component