Code Monkey home page Code Monkey logo

react-pdfobject's Introduction

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

react-pdfobject's People

Contributors

dependabot[bot] avatar lvstross avatar ngs avatar r17x avatar renovate-bot avatar renovate[bot] avatar sugarshin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-pdfobject's Issues

Pass node reference to PDFObject

In v1.1. a custom ID is provided to pdfobject API call this may cause problems if a user forgets to provide containerId property and instantiates two or more <PDFObject />

The target parameter can accept a CSS selector, HTML node, or jQuery object.

A more elegant solution could be to use refs (which are DOM nodes, so are supported by API), this should not cause any problem because componentDidMount will be called after render and the reference should be populated.

Can't seem to replace PDF

If I render a and then later with a different url prop, it seems that the previously rendered PDF is not replaced with the new one. I tried a force update (after obtaining a ref on the PDFObject component), but to no avail.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Repository problems

These problems occurred while renovating this repository. View logs.

  • WARN: Using npm packages for Renovate presets is now deprecated. Please migrate to repository-based presets instead.

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm codecov Unavailable
npm tslint Unavailable

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update All patch update devDependencies (patch) (@types/enzyme, @types/enzyme-adapter-react-16, codecov, enzyme-adapter-react-16)
  • Update actions/checkout action to v4
  • Update dependency husky to v9
  • Update dependency lint-staged to v15
  • Update dependency node to v20
  • Update dependency prettier to v3
  • Update dependency tslint to v6
  • Update dependency typescript to v5
  • Update dependency ubuntu to v22
  • Update react monorepo to v18 (major) (react, react-dom)
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

circleci
.circleci/config.yml
  • circleci/node 10.14.2
  • circleci/node 10.14.2
  • circleci/node 10.14.2
github-actions
.github/workflows/github-release.yml
  • actions/checkout v2
  • actions/create-release v1
  • ubuntu 20.04
nodenv
.node-version
  • node 10.14.2
npm
package.json
  • pdfobject ^2.1.1
  • @types/enzyme 3.10.13
  • @types/enzyme-adapter-react-16 1.0.6
  • @types/jest 23.3.14
  • @types/pdfobject 2.0.6
  • codecov 3.8.2
  • custom-tslint-formatters 2.4.0
  • enzyme 3.11.0
  • enzyme-adapter-react-16 1.15.7
  • enzyme-to-json 3.6.2
  • husky 1.3.1
  • jest 23.6.0
  • lint-staged 8.2.1
  • prettier 1.19.1
  • react 16.14.0
  • react-dom 16.14.0
  • ts-jest 23.10.5
  • tslint 5.20.1
  • tslint-config-prettier 1.18.0
  • tslint-eslint-rules 5.4.0
  • tslint-plugin-prettier 2.3.0
  • typescript 3.9.10

  • Check this box to trigger a request for Renovate to run again on this repository

supportsPDFs support issue

Hello, how i'm able to use supportsPDFs property?
I found, that it was implemented in #122, but im not able use PDFObject.supportsPDFs/PDFObject.supportsPDFs() as it's not detected

My package version:
"react-pdfobject": "^1.1.1",

Object prototype may only be an Object or null: undefined

I have a react application using gulp. When i try to run in my server after bundle I am getting this error. Works fine in my local. Any idea why this is happening?

Object prototype may only be an Object or null: undefined

NOTE: without using react-pdfobject, everything working fine

PDF doesn't automatically render, needs to manually open

I have a React app where I get a URL from my server that contains a PDF, and while I can view it, a team member of mine sees it differently. The strange thing is that, for them, it opens normally in other browsers (firefox, safari), but not on Chrome. For me, it works across browsers.

I'm using the library, react-pdfobject

Example (normal):
enter image description here

This is what they see:
enter image description here

Here is my code:

import { PDFObject } from 'react-pdfobject';

// ....
return (
  <>
    <Modal
      {...props}
      width="auto"
      styles={{ body: { height: window.innerHeight - 300 } }}
      onOk={() => {
        if (!data?.me.signatures.length) {
          setNoSignatureModalOpen(true);
          return;
        }
        bulkSignSignableDocuments();
      }}
      okText="Sign"
    >
      <Typography.Title level={4} style={{ textAlign: 'center' }}>
        Review and approve the {documentCount} {documentCount > 1 ? 'documents' : 'document'}{' '}
        you've selected to sign:
      </Typography.Title>
      <div style={{ display: 'flex', height: '100%' }}>
        <DocumentList
          setSelectedDocument={setSelectedDocument}
          preparedDocuments={preparedDocuments}
        />
        {selectedDocument?.pendingSignaturePdfUrl && (
          <PDFContainer>
            <PDFObject url={selectedDocument.pendingSignaturePdfUrl} />
          </PDFContainer>
        )}
      </div>
    </Modal>
    <NoSignatureModal
      open={noSignatureModalOpen}
      onCancel={() => setNoSignatureModalOpen(false)}
    />
  </>
);

How do I get this to automatically open?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.