Skip to content

Commit 2add4e9

Browse files
committed
docs: add documentation
1 parent 13de28a commit 2add4e9

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

react/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,35 @@ import { EmbedPDF } from '@simplepdf/react-embed-pdf';
120120
/>;
121121
```
122122

123+
### Programmatic Control
124+
125+
_Requires a SimplePDF account_
126+
127+
Use `const { embedRef, actions } = useEmbed();` to programmatically control the embed editor:
128+
129+
- `actions.submit`: Submit the document (specify or not whether to download a copy of the document on the device of the user)
130+
- `actions.selectTool`: Select a tool to use
131+
132+
```jsx
133+
import { EmbedPDF, useEmbed } from "@simplepdf/react-embed-pdf";
134+
135+
const { embedRef, actions } = useEmbed();
136+
137+
return (
138+
<>
139+
<button onClick={() => await actions.submit({ downloadCopyOnDevice: false })}>Submit</button>
140+
<button onClick={() => await actions.selectTool('TEXT')}>Select Text Tool</button>
141+
<EmbedPDF
142+
companyIdentifier="yourcompany"
143+
ref={embedRef}
144+
mode="inline"
145+
style={{ width: 900, height: 800 }}
146+
documentURL="https://cdn.simplepdf.com/simple-pdf/assets/sample.pdf"
147+
/>
148+
</>
149+
);
150+
```
151+
123152
### <a id="available-props"></a>Available props
124153

125154
<table>
@@ -129,6 +158,12 @@ import { EmbedPDF } from '@simplepdf/react-embed-pdf';
129158
<th>Required</th>
130159
<th>Description</th>
131160
</tr>
161+
<tr>
162+
<td>ref</td>
163+
<td>EmbedRefHandlers</td>
164+
<td>No</td>
165+
<td>Used for programmatic control of the editor</td>
166+
</tr>
132167
<tr>
133168
<td>mode</td>
134169
<td>"inline" | "modal"</td>

0 commit comments

Comments
 (0)