Skip to content

feat: useEmbed #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 12, 2025
Merged

feat: useEmbed #17

merged 3 commits into from
Feb 12, 2025

Conversation

bendersej
Copy link
Collaborator

@bendersej bendersej commented Feb 11, 2025

Background

This PR introduces the hook useEmbed that allows to programmatically control the editor:

import { EmbedPDF, useEmbed } from "@simplepdf/react-embed-pdf";

const { embedRef, actions } = useEmbed();

return (
   <>
      <button onClick={() => await actions.submit({ downloadCopyOnDevice: false })}>Submit</button>
      <button onClick={() => await actions.selectTool('TEXT')}>Select Text Tool</button>
      <EmbedPDF
         companyIdentifier="yourcompany"
         ref={embedRef}
         mode="inline"
         style={{ width: 900, height: 800 }}
         documentURL="https://cdn.simplepdf.com/simple-pdf/assets/sample.pdf"
      />
   </>
);

Coupled with the upcoming headless SimplePDF feature, this allows to fully customise the look and feel of SimplePDF by removing the sidebar entirely and controlling the editor programmatically.

Currently the two following actions have been implemented:

  • Select tool
  • Submit

Upcoming actions:

  • Fill fields

Changes

  • Introduce useEmbed
  • Add documentation
  • Publish @simplepdf/react-embed-pdf@1.9.0

@bendersej bendersej self-assigned this Feb 11, 2025
@bendersej bendersej merged commit 344b9d6 into main Feb 12, 2025
1 check passed
@bendersej bendersej deleted the react-use-embed branch February 12, 2025 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant