diegomura / diegomura/react-pdf

Attaching a data file to a PDF report

Open
#1,751 2 comments 1 reaction 0 assignees View on GitHub
new feature
Dominant language
TypeScript
Stars
16.8k
Forks
1.3k
Avg merge
5h 6m
Merged PRs (30d)
52

Description

**Is your feature request related to a problem? Please describe.**
I'm interested in embedding an JSON document in my PDF report.

While not commonly used, I like the idea of users with the PDF report having access to the underlying data.

**Describe the solution you'd like**
A hook allowing access to the pdfkit doc object as part of rendering process. It should allow attachments and annotations to be included before the document is finalised.

**Describe alternatives you've considered**
Reproducing the [pdf() function](https://github.com/diegomura/react-pdf/blob/aa5a438c75e84c644c7139823c059eca3e65d5d1/packages/renderer/src/index.js#L19) in my code to provide a hook point. Not clear to me how to do that.

**Additional context**

PDFKit seems to provide the necessary features to embed a data file and make a region of the doc clickable to access it.

http://pdfkit.org/docs/attachments.html

For example, with access to the doc object we can add a file...
```
doc.file(path.join(__dirname, 'example.txt'))
```

and also to annotate a page so it's a clickable link...

```
const file = {
src: path.join(__dirname, 'example.txt'),
name: 'example.txt',
description: 'file annotation description'
}
const options = { Name: 'Paperclip' }

doc.fileAnnotation(100, 100, 100, 100, file, options)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.