@@ -122,31 +122,74 @@ import { EmbedPDF } from '@simplepdf/react-embed-pdf';
122122
123123### Programmatic Control
124124
125- _ Requires a SimplePDF account_
125+ _ Some actions require a SimplePDF account_
126126
127127Use ` const { embedRef, actions } = useEmbed(); ` to programmatically control the embed editor:
128128
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
129+ | Action | Description |
130+ | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------- |
131+ | ` actions.goTo({ page }) ` | Navigate to a specific page |
132+ | ` actions.selectTool(toolType) ` | Select a tool: ` 'TEXT' ` , ` 'BOXED_TEXT' ` , ` 'CHECKBOX' ` , ` 'PICTURE' ` , ` 'SIGNATURE' ` , or ` null ` to deselect (` CURSOR ` ) |
133+ | ` actions.createField(options) ` | Create a field at specified position (see below) |
134+ | ` actions.clearFields(options?) ` | Clear fields by ` fieldIds ` or ` page ` , or all fields if no options |
135+ | ` actions.getDocumentContent({ extractionMode }) ` | Extract document content (` extractionMode: 'auto' ` or ` 'ocr' ` ) |
136+ | ` actions.submit({ downloadCopyOnDevice }) ` | Submit the document |
131137
132- ``` jsx
133- import { EmbedPDF , useEmbed } from " @simplepdf/react-embed-pdf" ;
134-
135- const { embedRef , actions } = useEmbed ();
138+ All actions return a ` Promise ` with a result object: ` { success: true, data: ... } ` or ` { success: false, error: { code, message } } ` .
136139
137- return (
138- <>
139- < button onClick= {() => await actions .submit ({ downloadCopyOnDevice: false })}> Submit< / button>
140- < button onClick= {() => await actions .selectTool (' TEXT' )}> Select Text Tool< / button>
140+ ``` jsx
141+ import { EmbedPDF , useEmbed } from ' @simplepdf/react-embed-pdf' ;
142+
143+ const Editor = () => {
144+ const { embedRef , actions } = useEmbed ();
145+
146+ const handleSubmit = async () => {
147+ const result = await actions .submit ({ downloadCopyOnDevice: false });
148+ if (result .success ) {
149+ console .log (' Submitted!' );
150+ }
151+ };
152+
153+ const handleExtract = async () => {
154+ const result = await actions .getDocumentContent ({ extractionMode: ' auto' });
155+ if (result .success ) {
156+ console .log (' Document name:' , result .data .name );
157+ console .log (' Pages:' , result .data .pages );
158+ }
159+ };
160+
161+ const handleCreateTextField = async () => {
162+ const result = await actions .createField ({
163+ type: ' TEXT' ,
164+ page: 1 ,
165+ x: 100 ,
166+ y: 200 ,
167+ width: 150 ,
168+ height: 30 ,
169+ value: ' Hello World' ,
170+ });
171+ if (result .success ) {
172+ console .log (' Created field:' , result .data .field_id );
173+ }
174+ };
175+
176+ return (
177+ <>
178+ < button onClick= {handleSubmit}> Submit< / button>
179+ < button onClick= {handleExtract}> Extract Content< / button>
180+ < button onClick= {handleCreateTextField}> Add Text Field< / button>
181+ < button onClick= {() => actions .selectTool (' TEXT' )}> Select Text Tool< / button>
182+ < button onClick= {() => actions .goTo ({ page: 2 })}> Go to Page 2 < / button>
141183 < 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"
184+ companyIdentifier= " yourcompany"
185+ ref= {embedRef}
186+ mode= " inline"
187+ style= {{ width: 900 , height: 800 }}
188+ documentURL= " https://cdn.simplepdf.com/simple-pdf/assets/sample.pdf"
147189 / >
148- < / >
149- );
190+ < / >
191+ );
192+ };
150193```
151194
152195### <a id =" available-props " ></a >Available props
@@ -160,19 +203,19 @@ return (
160203 </tr >
161204 <tr >
162205 <td>ref</td>
163- <td>EmbedRefHandlers </td>
206+ <td>EmbedActions </td>
164207 <td>No</td>
165- <td>Used for programmatic control of the editor</td>
208+ <td>Used for programmatic control of the editor (see Programmatic Control section) </td>
166209 </tr >
167210 <tr >
168211 <td>mode</td>
169212 <td>"inline" | "modal"</td>
170213 <td>No (defaults to "modal")</td>
171214 <td>Inline the editor or display it inside a modal</td>
172215 </tr >
173- <tr>
216+ <tr >
174217 <td>locale</td>
175- <td>"en" | "de" | "es" | "fr" | "it" | "pt"</td>
218+ <td>"en" | "de" | "es" | "fr" | "it" | "nl" | " pt"</td>
176219 <td>No (defaults to "en")</td>
177220 <td>Language to display the editor in (ISO locale)</td>
178221 </tr >
@@ -188,6 +231,12 @@ return (
188231 <td>No</td>
189232 <td><a href="https://simplepdf.com/embed">Allows collecting customers submissions</a></td>
190233 </tr >
234+ <tr >
235+ <td>baseDomain</td>
236+ <td>string</td>
237+ <td>No</td>
238+ <td>Override the base domain for self-hosted deployments (e.g., "yourdomain.com"). Contact sales@simplepdf.com for enterprise self-hosting</td>
239+ </tr >
191240 <tr >
192241 <td>context</td>
193242 <td>Record<string, unknown></td>
@@ -225,12 +274,12 @@ return (
2252741 . Link the widget
226275
227276``` sh
228- yarn link
229- yarn start
277+ npm link
278+ npm start
230279```
231280
2322812 . Use it in the target application
233282
234283``` sh
235- yarn link @simplepdf/react-embed-pdf
284+ npm link @simplepdf/react-embed-pdf
236285```
0 commit comments