Skip to content

Commit

Permalink
Add trailing slash to cMapUrl and standardFontDataUrl options
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Jul 21, 2023
1 parent c91f2a5 commit db43c90
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ Now that you have cMaps in your build, pass required options to Document compone
```ts
// Outside of React component
const options = {
cMapUrl: 'cmaps/',
cMapUrl: '/cmaps/',
cMapPacked: true,
};

Expand Down Expand Up @@ -388,7 +388,7 @@ Now that you have standard fonts in your build, pass required options to Documen
```tsx
// Outside of React component
const options = {
standardFontDataUrl: 'standard_fonts/',
standardFontDataUrl: '/standard_fonts/',
};

// Inside of React component
Expand Down Expand Up @@ -435,7 +435,7 @@ Loads a document passed using `file` prop.
| onPassword | Function called when a password-protected PDF is loaded. | Function that prompts the user for password. | `(callback) => callback('s3cr3t_p4ssw0rd')` |
| onSourceError | Function called in case of an error while retrieving document source from `file` prop. | n/a | `(error) => alert('Error while retrieving document source! ' + error.message)` |
| onSourceSuccess | Function called when document source is successfully retrieved from `file` prop. | n/a | `() => alert('Document source retrieved!')` |
| options | An object in which additional parameters to be passed to PDF.js can be defined. Most notably:<ul><li>`cMapUrl`;</li><li>`cMapPacked` - required for CMap support;</li><li>`httpHeaders` - custom request headers, e.g. for authorization);</li><li>`withCredentials` - a boolean to indicate whether or not to include cookies in the request (defaults to `false`)</li></ul>For a full list of possible parameters, check [PDF.js documentation on DocumentInitParameters](https://mozilla.github.io/pdf.js/api/draft/module-pdfjsLib.html#~DocumentInitParameters). **Note**: For performance reasons, make sure to define options object outside of your React component, and use `useMemo` if you can't. | n/a | `{ cMapUrl: 'cmaps/', cMapPacked: true }` |
| options | An object in which additional parameters to be passed to PDF.js can be defined. Most notably:<ul><li>`cMapUrl`;</li><li>`cMapPacked` - required for CMap support;</li><li>`httpHeaders` - custom request headers, e.g. for authorization);</li><li>`withCredentials` - a boolean to indicate whether or not to include cookies in the request (defaults to `false`)</li></ul>For a full list of possible parameters, check [PDF.js documentation on DocumentInitParameters](https://mozilla.github.io/pdf.js/api/draft/module-pdfjsLib.html#~DocumentInitParameters). **Note**: For performance reasons, make sure to define options object outside of your React component, and use `useMemo` if you can't. | n/a | `{ cMapUrl: '/cmaps/', cMapPacked: true }` |
| renderMode | Rendering mode of the document. Can be `"canvas"`, `"custom"`, `"none"` or `"svg"`. If set to `"custom"`, `customRenderer` must also be provided.<br />**Warning**: SVG render mode is no longer maintained and may be removed in the future. | `"canvas"` | `"svg"` |
| rotate | Rotation of the document in degrees. If provided, will change rotation globally, even for the pages which were given `rotate` prop of their own. `90` = rotated to the right, `180` = upside down, `270` = rotated to the left. | n/a | `90` |

Expand Down
4 changes: 2 additions & 2 deletions sample/create-react-app-5/src/Sample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pdfjs.GlobalWorkerOptions.workerSrc = new URL(
).toString();

const options = {
cMapUrl: 'cmaps/',
standardFontDataUrl: 'standard_fonts/',
cMapUrl: '/cmaps/',
standardFontDataUrl: '/standard_fonts/',
};

type PDFFile = string | File | null;
Expand Down
4 changes: 2 additions & 2 deletions sample/parcel2/Sample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pdfjs.GlobalWorkerOptions.workerSrc = new URL(
).toString();

const options = {
cMapUrl: 'cmaps/',
standardFontDataUrl: 'standard_fonts/',
cMapUrl: '/cmaps/',
standardFontDataUrl: '/standard_fonts/',
};

type PDFFile = string | File | null;
Expand Down
4 changes: 2 additions & 2 deletions sample/vite3/Sample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pdfjs.GlobalWorkerOptions.workerSrc = new URL(
).toString();

const options = {
cMapUrl: 'cmaps/',
standardFontDataUrl: 'standard_fonts/',
cMapUrl: '/cmaps/',
standardFontDataUrl: '/standard_fonts/',
};

type PDFFile = string | File | null;
Expand Down
4 changes: 2 additions & 2 deletions sample/vite4/Sample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pdfjs.GlobalWorkerOptions.workerSrc = new URL(
).toString();

const options = {
cMapUrl: 'cmaps/',
standardFontDataUrl: 'standard_fonts/',
cMapUrl: '/cmaps/',
standardFontDataUrl: '/standard_fonts/',
};

type PDFFile = string | File | null;
Expand Down
4 changes: 2 additions & 2 deletions sample/webpack5/Sample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ pdfjs.GlobalWorkerOptions.workerSrc = new URL(
).toString();

const options = {
cMapUrl: 'cmaps/',
standardFontDataUrl: 'standard_fonts/',
cMapUrl: '/cmaps/',
standardFontDataUrl: '/standard_fonts/',
};

type PDFFile = string | File | null;
Expand Down
4 changes: 2 additions & 2 deletions test/Test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ pdfjs.GlobalWorkerOptions.workerSrc = new URL(
).toString();

const options = {
cMapUrl: 'cmaps/',
standardFontDataUrl: 'standard_fonts/',
cMapUrl: '/cmaps/',
standardFontDataUrl: '/standard_fonts/',
};

export function readAsDataURL(file: Blob): Promise<string> {
Expand Down

0 comments on commit db43c90

Please sign in to comment.