Skip to content

sugarshin/react-pdfobject

Repository files navigation

react-pdfobject

CircleCI Codecov npm version License

A React component for PDFObject .

npm install react-pdfobject

Usage

import * as React from 'react'
import { PDFObject } from 'react-pdfobject'

<PDFObject url="path/to/example.pdf" />

Props

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';

API / Static Methods Supported

PDFObject.supportsPDFs [Function]

if(PDFObject.supportsPDFs){
   console.log("Yay, this browser supports inline PDFs.");
} else {
   console.log("Boo, inline PDFs are not supported by this browser");
}

PDFObject.pdfobjectversion [Function]

console.log(PDFObject.pdfobjectversion); //"2.1.1"

ref: https://pdfobject.com/#api

License

MIT

© sugarshin