What can I integrate?
You can integrate the FastRedact document editor into your web application using an iframe. This allows your users to redact documents directly within your app, providing a seamless experience.
Getting started
It is easy to use the FastRedact document editor in your application: all you need is an iframe and a URL.
Steps to embed:
- Take the embed token from the account page
- Retrieve an embed URL from the FastRedact API (authenticate with the embed token)
- Use the embed URL as the src of your iframe
Example HTML file:
1. Retrieve embed URL using the embed token from the account page.
async function fetchEmbedUrl(embedToken) {
/* Minimal function for retrieving embed URL */
// 1. Create request
const res = await fetch("https://api.fastredact.eu/embed/editor", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer " + embedToken,
},
body: JSON.stringify({ mode: "all" }),
});
// 2. Handle response
const data = await res.json();
return data.embed_url;
}
2. Create an iframe
<iframe
src={embedUrl}
width={900}
height={800}
/>
3. Listen for messages from the iframe
function onWindowMessage(event: MessageEvent) {
/* Listens for messages on the window */
// Get data from event
const d = event.data as Record<string, unknown>;
// 1. Check event type; e.g. client clicked "export" button
if (d.type === "fastredact.exported") {
// 2. Extract file Blob and result ID from event data
const result_id = d.result_id;
const file = d.file;
// 3. Handle the exported file (e.g. download it or send to server)
console.log("FastRedact export completed");
console.log("File:", file);
}
}
window.addEventListener("message", onMessage);