Skip to content

Does react-pdf render PDF forms? #1908

Answered by joshgreco
wra1w0 asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, react-pdf can render forms.

The Page component accepts a renderForms prop. Pass it a true and make sure you're loading the styles from AnnotationLayer.css and you should be good to go.

The documentation states that in order for forms to be rendered, renderAnnotationLayer also needs to be true, but it is by default. As long as you aren't disabling it somewhere, it should just work.

Here's a rough example of how I'm doing it:

import {useState} from "react";
import {Document, Page} from 'react-pdf';

import 'react-pdf/dist/Page/TextLayer.css';
import 'react-pdf/dist/Page/AnnotationLayer.css';

const MyComponent = () => {
  const [pages, setPages] = useState([]);
  const [scale, setScale…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@wra1w0
Comment options

Answer selected by wra1w0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants