Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: wojtekmaj/react-pdf
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.0.1
Choose a base ref
...
head repository: wojtekmaj/react-pdf
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v7.0.2
Choose a head ref
  • 12 commits
  • 17 files changed
  • 1 contributor

Commits on May 25, 2023

  1. Copy the full SHA
    08a019e View commit details
  2. Copy the full SHA
    5126990 View commit details
  3. Remove unnecessary file

    wojtekmaj committed May 25, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7230290 View commit details

Commits on May 28, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    bfd32ed View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3ed4707 View commit details

Commits on May 29, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    47112f4 View commit details

Commits on May 30, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d454a68 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    233f875 View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f6f2116 View commit details

Commits on May 31, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    bacc5bd View commit details
  2. Don't dispatch REJECT action to resolver when loadingTask was destroyed

    loadingTask.promise throws after loadingTask.destroy() is called, and we call loadingTask.destroy() to destroy worker once it loaded the PDF. If we destroy it before loadingTask.promise resolves, this produces an error that should not be treated as one.
    wojtekmaj committed May 31, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    597bec1 View commit details
  3. v7.0.2

    wojtekmaj committed May 31, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    975b753 View commit details
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
{
"files": ["sample/**", "test/**"],
"rules": {
"@typescript-eslint/no-var-requires": "off",
"import/no-unresolved": "off"
}
}
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -40,14 +40,14 @@ React-PDF is under constant development. This documentation is written for React

React-PDF supports all modern browsers. It is tested with the latest versions of Chrome, Edge, Safari, Firefox, and Opera.

The following browsers are supported in React-PDF v7:
The following browsers are supported out of the box in React-PDF v7:

- Chrome ≥88
- Edge ≥88
- Safari ≥14.1
- Firefox ESR
- Chrome ≥92
- Edge ≥92
- Safari ≥15.4
- Firefox ≥90

You may extend the list of supported browsers by providing additional polyfills (e.g. for `Promise.allSettled`) and configuring your bundler to transpile `pdfjs-dist`.
You may extend the list of supported browsers by providing additional polyfills (e.g. for `Array.prototype.at` or `Promise.allSettled`) and either configuring your bundler to transpile `pdfjs-dist` or using [legacy PDF.js worker](#legacy-pdfjs-worker).

If you need to support older browsers, you will need to use React-PDF v6 or v5.

@@ -177,6 +177,25 @@ import { pdfjs } from 'react-pdf';
pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js`;
```

#### Legacy PDF.js worker

If you need to support older browsers, you may use legacy PDF.js worker. To do so, follow the instructions above, but replace `/build/` with `legacy/build/` in PDF.js worker import path, for example:

```diff
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
- 'pdfjs-dist/build/pdf.worker.min.js',
+ 'pdfjs-dist/legacy/build/pdf.worker.min.js',
import.meta.url,
).toString();
```

or:

```diff
-pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js`;
+pdfjs.GlobalWorkerOptions.workerSrc = `//unpkg.com/pdfjs-dist@${pdfjs.version}/legacy/build/pdf.worker.min.js`;
```

### Support for annotations

If you want to use annotations (e.g. links) in PDFs rendered by React-PDF, then you would need to include stylesheet necessary for annotations to be correctly displayed like so:
1 change: 0 additions & 1 deletion __mocks__/styleMock.js

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-pdf",
"version": "7.0.1",
"version": "7.0.2",
"description": "Display PDFs in your React app as easily as if they were images.",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
@@ -49,7 +49,7 @@
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.0",
"eslint": "^8.26.0",
"eslint-config-wojtekmaj": "^0.8.3",
"eslint-config-wojtekmaj": "^0.8.4",
"husky": "^8.0.0",
"jsdom": "^21.1.0",
"prettier": "^2.7.0",
4 changes: 4 additions & 0 deletions sample/webpack4/package.json
Original file line number Diff line number Diff line change
@@ -22,12 +22,16 @@
"@babel/preset-env": "^7.21.0",
"@babel/preset-react": "^7.18.0",
"@babel/preset-typescript": "^7.21.0",
"@types/copy-webpack-plugin": "^6.4.0",
"@types/node": "*",
"babel-loader": "^8.0.0",
"copy-webpack-plugin": "^6.4.0",
"css-loader": "^5.2.0",
"file-loader": "^6.0.0",
"html-webpack-plugin": "^4.5.0",
"style-loader": "^2.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.0",
"webpack": "^4.46.0",
"webpack-cli": "^4.7.0",
"webpack-dev-server": "^4.13.1"
2 changes: 1 addition & 1 deletion sample/webpack4/tsconfig.json
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react",
"module": "esnext",
"module": "commonjs",
"moduleResolution": "node",
"noUncheckedIndexedAccess": true,
"outDir": "dist",
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const webpack = require('webpack');
const path = require('node:path');
import webpack from 'webpack';
import path from 'node:path';

const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
import CopyWebpackPlugin from 'copy-webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';

import type { Configuration } from 'webpack';
import 'webpack-dev-server';

const isProduction = process.env.NODE_ENV === 'production';

@@ -12,7 +15,7 @@ const standardFontsDir = path.join(
'standard_fonts',
);

module.exports = {
const config = {
mode: isProduction ? 'production' : 'development',
bail: isProduction,
context: path.join(__dirname),
@@ -61,4 +64,6 @@ module.exports = {
hot: true, // enable HMR on the server
port: 3000,
},
};
} satisfies Configuration;

export default config;
Loading