Skip to content

Commit

Permalink
added documentation about cmaps and fit-parent example in the menu
Browse files Browse the repository at this point in the history
  • Loading branch information
TaTo30 committed Feb 23, 2024
1 parent ae89d97 commit 1e53a5c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ export default {
text: 'Watermark',
link: 'watermark',
},
{
text: 'Fit Parent',
link: 'fit_parent',
},
{
text: 'Highlight Text',
link: 'highlight_text',
Expand Down
31 changes: 30 additions & 1 deletion docs/guide/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ yarn add @tato30/vue-pdf

## Basic Usage

The most basic usage is as simple as import the `VuePDF` and `usePDF` and uses it on your project :)
The most basic usage is as simple as import the `VuePDF` and `usePDF` and use them on your project :)

```vue
<script setup>
Expand Down Expand Up @@ -94,6 +94,35 @@ Check the example:

`VuePDF` is a client-side library, so if you are working with a SSR framework like `nuxt`, surely it will throw an error during the building stage, if that is the case, you could wrap `VuePDF` in some sort of "client only" directive or component, also `usePDF` should be wrapped.

## Supporting Non-Latin characters

If you are looking for display non-latin text or you are getting a warning like:
> Warning: Error during font loading: CMapReaderFactory not initialized, see the useWorkerFetch parameter
you will probably need to copy the `cmaps` directory from `node_modules/pdfjs-dist` to your project's `public` directory, don't worry about no having `pdfjs-dist` it's installed alongside `vue-pdf` package.


```
.
├─ node_modules
│ ├─ pdfjs-dist
│ │ └─ cmaps <--- Copy this directory
├─ src
├─ public
| ├─ *cmaps* <--- Paste it here!
├─ package.json
| ...
```

With that made the `cmaps` will be available on relative path `/cmaps/`, now you need the tell `usePDF` uses that `cmaps` url:

```js
const { pdf } = usePDF({
url: pdfsource,
cMapUrl: '/cmaps/',
})
```

## Contributing

Any idea, suggestion or contribution to the code or documentation are very welcome.
Expand Down

0 comments on commit 1e53a5c

Please sign in to comment.