How to save edited PDF submissions to Supabase
You have added SimplePDF to your app, or your AI Agent and you would like to store the PDF submissions in your Supabase Storage.
You could for example by trying to:
- Automate further the handling of the submissions: for example extracting the data from the forms to process them
- Store the PDF in a vector store to offer semantic search or automatically detect duplicates or similarities in the submitted PDF
For this tutorial we'll be using two PRO features from SimplePDF:
- The webhooks integration - together with Supabase Edge Functions
The code for the Supabase Edge function can be found here
- The S3 integration - together with Supabase Storage
Configuring Supabase Storage for the PDF submissions
In this section we'll walk you through setting up Supabase Storage as a storage for the edited PDF submissions (and documents) instead of SimplePDF's default storage.
-
Head over to Storage in your Supabase project and click New bucket
-
Name your bucket, keep it private (do not toggle Public bucket) and then click Save
- In the Storage settings, create a new S3 Access Keys
- Head over to your SimplePDF account and configure the S3 storage as follows:
You can find a step-by-step here
Endpoint: <COPIED the endpoint in the S3 Connection in Supabase Storage settings>
Path-style: <TOGGLE enabled>
Region: <SELECT the region visible in the S3 Connection in Supabase Storage settings>
Bucket: <ENTER the name of the bucket: in our example we used "pdf">
Access Key ID: <PASTE the value you get in the step 3. above>
Secret Access Key: <PASTE the value you get in the step 3. above>
- Click Update and head over to your Supabase storage and notice that a new file has been automatically added: this confirms that the configuration is ready!
Feel free to delete this file: you won't need it anymore
Configuring a new Supabase Table to store the PDF submissions metadata
In this section we'll be creating a new table to store the metadata we receive from SimplePDF for each new submissions. We'll be using Supabase Edge Functions to insert the data in the table.
If you want to jump ahead and skip the tutorial, you can see the full source code, table definition and pre-requisites over here
-
Head over to Database > Tables and create a new table - we'll name it
simplepdf_submissions
-
Define the following schema: You can see the schema defined in SQL in Github over here
- id:
int8
- Primary - document_name:
text
- document_id:
text
- submission_id:
text
- submission_bucket_path:
text
- context:
jsonb
- Deploy the read-made Edge Function we have created for you: source code on Github
npm i
npm run deploy
- Create a new RLS policy to allow this edge function to insert rows into the
simplepdf_submissions
table:
For production use, we recommend a stricter RLS policy or to authenticate the webhooks calls by passing an authorization header from SimplePDF's end
alter policy "Allow edge function to insert into simplepdf_submissions"
on "public"."simplepdf_submissions"
to anon
with check (true);
- Copy the URL of the
simplepdf-webhooks
Edge Function in the Edge Functions section in supabase
- Head over to SimplePDF and configure the webhooks to point to your deployed
simplepdf-webhooks
function
You can find a step-by-step here
That's it! The integration is ready! Storing edited PDFs in Supabase Storage and saving events (and metadata) using Supabase Edge Functions about edited PDF submissions in a table!
If you have any questions, feel free to reach out to support@simplepdf.com
You may also be interested in
- Customize the editor and add your own branding
- Customize the submission confirmation
- Get email notifications on PDF form submissions
- Configure your own S3 bucket for PDF form submissions
- Configure Webhooks to get notified of new PDF form submissions
- Save the PDF submissions to your Bubble Database using Bubble workflows
- Connect SimplePDF with Activepieces to automate your PDF forms processing
- Use the Robocorp integration to leverage AI in your IDP workflow
- Add the embed PDF editor to a Next.js App
- View and edit PDF in Excalidraw