项目作者: PDFTron

项目描述 :
Sign and request signatures on PDFs, MS Office documents
高级语言: JavaScript
项目地址: git://github.com/PDFTron/pdftron-sign-app.git
创建时间: 2020-05-26T15:24:45Z
项目社区:https://github.com/PDFTron/pdftron-sign-app

开源协议:Other

下载


PDFTron Sign App

PDFTron Sign App demonstrates building a signing application where users can request signatures on the documents by placing fields, sign documents, review signed documents using PDFTron PDF SDK.

Watch the video here:
image

This repo is designed to help to get started in creating your own signing workflow.

What is new in the latest release

Watch a quick recap

  • Ability to add date fields
  • Ability to see when the document was requested and signed
  • Update WebViewer to 10.0

Install

Watch this quick video to setup this project.

  1. npm install

Firebase Configuration

This application uses Firebase to store PDFs and data for signatures. You can use any other backend of your choice.
However, to get started with this sample, please register a new app with Firebase.

After you have registered an app, create .env file in the root of the directory and place the following:

  1. REACT_APP_API_KEY=your_key_goes_here
  2. REACT_APP_MESSAGING_SENDER_ID=your_key_goes_here
  3. REACT_APP_APP_ID=your_key_goes_here
  4. REACT_APP_AUTH_DOMAIN=your_domain_goes_here
  5. REACT_APP_DATABASE_URL=your_database_go_here
  6. REACT_APP_PROJECT_ID=your_project_id
  7. REACT_APP_STORAGE_BUCKET=your_storage_bucket

The above information can be found under settings of your Firebase app.
Screenshot

Make sure you create a storage bucket, and enable authentication for email and Google.
Screenshot

After you have your storage bucket and Firestore setup give authenticated users read and write permissions.

Rules for storage which will host your PDF documents.
Screenshot

Rules for Firestore which will host document signing metadata.
Screenshot

Change Firestore Database rules to:

  1. rules_version = '2';
  2. service cloud.firestore {
  3. match /databases/{database}/documents {
  4. match /{document=**} {
  5. allow read, write: if request.auth != null;
  6. }
  7. }
  8. }

Change Storage rules to:

  1. rules_version = '2';
  2. service firebase.storage {
  3. match /b/{bucket}/o {
  4. match /{allPaths=**} {
  5. allow read, write: if request.auth != null;
  6. }
  7. }
  8. }

Now you can run the application and start requesting signatures.

CORS

You will need to set up CORS on your Firestore to allow WebViewer to access files stored in your bucket. I created a CORS file called cors.json:

  1. [
  2. {
  3. "origin": ["*"],
  4. "method": ["GET"],
  5. "maxAgeSeconds": 3600
  6. }
  7. ]

And then used gsutil to update it:
https://cloud.google.com/storage/docs/configuring-cors

The walkthrough recommends siging up for billing but that is not necessary to use this demo.

Run

  1. npm start

Project structure

  1. src/
  2. app/ - Redux Store Configuration
  3. components/ - React components
  4. Assign/ - Add users to a document that needs to be signed
  5. Lists/ - List components to list files for signing and review
  6. MergeAnnotations/ - Merge all signatures and flatten them onto a PDF
  7. PasswordReset/ - Reset password
  8. PrepareDocument/ - Drag and drop signatures, text fields onto a PDF to prepare it for signing
  9. Profile/ - Profile information and a sign out button
  10. SignDocument/ - Sign PDF
  11. SignIn/ - Sign in
  12. SignUp/ - Sign up
  13. ViewDocument/ - Review document after signing
  14. AssignUsers - Component combines Profile and Assign
  15. Header - Header when the user is not logged in
  16. Preparation - Component combines Profile and PrepareDocument
  17. Sign - Component combines Profile and SignDocument
  18. View - Component combines Profile and ViewDocument
  19. Welcome - Component combines Profile, SignList, Preparation, SignedList
  20. App - Configuration for navigation, authentication
  21. index - Entry point and configuration for React-Redux
  22. firebase/ - Firebase configuration for authentication, updating documents, storing PDFs
  23. tools/ - Helper function to copy over PDFTron dependencies into /public on post-install

Firebase Document Structure

  1. docRef: docToSign/c4Y72M0d0pZx3476jxJFxrFA3Qo21593036106369.pdf"
  2. email: "andrey@email.com"
  3. emails: ["julia@email.com"]
  4. signed: true
  5. signedBy: ["julia@email.com"]
  6. requestedTime: July 17, 2020 at 12:01:24 PM UTC-7
  7. signedTime: July 17, 2020 at 12:01:24 PM UTC-7
  8. uid: "c4Y72M0d0pZx3476jxJFxrFA3Qo2"
  9. xfdf: ["<?xml version="1.0" encoding="UTF-8" ?><xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">...</xfdf>"]
  • docRef - string - storage reference to the actual PDF
  • email - string - email of the requestor of the signature
  • emails - an array of strings - users to sign the document
  • signed - boolean - value for whether or not all users have signed the document (gets determined by checking lengths of emails array and xfdf array)
  • requestedTime - TimeStamp - value for when the signature was requested
  • signedTime - TimeStamp - value for when the document was signed
  • uid - string - unique identifier for the requestor of the signature
  • xfdf - an array of strings - signature appearance/form field values for each user

API documentation

See API documentation.

License

See license.