All articles
Document Tips5 min read

How to Add a PDF Search Box to Any Website With One Line of Code

An embed widget sounds technical, but it's just one line of HTML. Here's what it actually does, how to get it, and how to paste it into any website in under 10 minutes.

Sparks Simple Team

28 January 2026

What "One Line of Code" Actually Means

If you're not a developer, the phrase "embed code" might sound more technical than it is. An embed snippet is a short piece of text — often a single line — that you paste into a specific place on your website. Your website builder does the rest.

You've almost certainly encountered embed codes before without knowing it. YouTube gives you one to paste a video into a website. Google Maps gives you one to embed a map. Calendly gives you one to embed a booking form. PDF search widgets work exactly the same way.

This guide explains what the embed code does, how to get it, and how to paste it into the most common website platforms — without any coding knowledge.

What the Embed Code Does

When a visitor loads your webpage, their browser reads your page's HTML and renders it into what they see. An embed snippet tells the browser to also load a small piece of software from an external server — in this case, the document search widget.

A Sparks Simple embed snippet looks like this:

<script src="https://cdn.sparkssimple.com/widget.js" data-widget="your-unique-id"></script>

That's it. When the browser encounters this line, it loads the widget script from Sparks Simple's servers and renders a search box at that location on the page. The script connects to your document index — the searchable version of your PDFs — and handles all the search logic.

Nothing is stored on your website. Nothing runs on your server. The heavy lifting (indexing, searching, returning results) all happens on the Sparks Simple infrastructure. Your website just displays the result.

Step 1: Get Your Embed Code

Sign up for Sparks Simple and create a widget. Upload your PDF files. Once at least one document shows a "Searchable" status, your widget is ready to embed.

Navigate to your widget's Embed tab and copy the script tag that's displayed there. The data-widget attribute contains your unique widget ID, which connects the embed to your specific document library. Don't share this ID publicly if you want to restrict who can search your documents, though for public-facing resources there's no issue.

Step 2: Paste It Into Your Website

The method depends on which platform your website runs on. Here's how it works on the most common ones:

Squarespace

Edit the page where you want the search widget. Click + to add a new block. Search for "Code" and select the Code block. Paste your embed code into the editor. Click Apply, then Save.

WordPress (Block Editor)

Edit the page or post. Click + to add a new block. Search for "Custom HTML." Paste your embed code into the HTML block. Click Preview or Publish to see the live result.

WordPress (Classic Editor)

Edit the page and switch from "Visual" to "Text" mode using the tab in the top-right of the editor. Find where you want the widget to appear and paste the embed code directly into the HTML. Switch back to Visual to check the layout, then Update or Publish.

Webflow

In the Designer, add an Embed element to your page (found under Components in the Add Elements panel). Double-click the element to open the code editor. Paste your embed code and click Save & Close. Preview or publish to see the live widget.

Wix

In the Wix editor, click + Add > Embed > Embed a Widget or Embed HTML. In the HTML settings panel that appears, paste your embed code. Resize the embed element to fit the widget appropriately on your page.

Framer

In the Framer canvas, add a new Frame. Select the frame and in the Properties panel, switch to Code mode. Add a Code component using dangerouslySetInnerHTML with your embed code, or use Framer's built-in Embed component if available. Alternatively, add the script to your project's custom code settings so it loads site-wide.

Custom HTML / any website

If you manage your own HTML, paste the embed code anywhere in the <body> of the page where you want the widget to appear. The widget renders at that location in the page flow.

Where to Place It on the Page

The widget works best when it's prominent. Visitors shouldn't have to scroll to find it. Ideal placements include:

  • Top of your Resources or Documents page — before any list of document links
  • In a hero section with a heading like "Search our document library"
  • In the sidebar of a page-heavy resources section

Think of it like your website's search bar: it should be immediately visible and clearly labelled so visitors know exactly what to do with it.

What Your Visitors Will See

Once live, the widget displays as a search box styled to match your brand colours. Visitors type a word or phrase — a policy name, a document topic, a plain English question — and results appear below the search box within a second, showing the document name and the relevant excerpt.

Clicking a result opens the relevant section of the document (depending on your widget settings, this might open the document in the browser or highlight the relevant section).

On mobile, the widget scales to fit the screen. The search experience is identical on desktop and phone.

Keeping Your Documents Current

When you update a document, log into Sparks Simple and upload the new version. The index updates automatically. Your embed code stays exactly the same — no changes to your website required. New documents, updated files, removed files — all managed from the dashboard, not the website.

That's It

One line of code, pasted into a text or HTML block on your website, gives your visitors full-text search across your entire document library. No plugins. No server configuration. No developer. If you can copy and paste text, you can do this.

Ready to get started?

Make your documents searchable in 15 minutes.

Start your free 14-day trial — no credit card required. Upload your PDFs, embed a search widget, done.

Start free trial →