Code Monkey home page Code Monkey logo

pdftron-sign-app's Introduction

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.

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:

REACT_APP_API_KEY=your_key_goes_here
REACT_APP_MESSAGING_SENDER_ID=your_key_goes_here
REACT_APP_APP_ID=your_key_goes_here
REACT_APP_AUTH_DOMAIN=your_domain_goes_here
REACT_APP_DATABASE_URL=your_database_go_here
REACT_APP_PROJECT_ID=your_project_id
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:

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

Change Storage rules to:

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

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:

[
  {
    "origin": ["*"],
    "method": ["GET"],
    "maxAgeSeconds": 3600
  }
]

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

npm start

Project structure

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

Firebase Document Structure

docRef: docToSign/c4Y72M0d0pZx3476jxJFxrFA3Qo21593036106369.pdf"
email: "[email protected]"
emails: ["[email protected]"]
signed: true
signedBy: ["[email protected]"]
requestedTime: July 17, 2020 at 12:01:24 PM UTC-7
signedTime: July 17, 2020 at 12:01:24 PM UTC-7
uid: "c4Y72M0d0pZx3476jxJFxrFA3Qo2"
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.

pdftron-sign-app's People

Contributors

andreysaf avatar bollain avatar correyl avatar mike-mh avatar mparizeau-pdftron avatar tyler-gordon avatar yatish-wk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pdftron-sign-app's Issues

The app shows Firestore connection error when signing in

index.js:1 [2023-04-03T15:39:18.803Z] @firebase/firestore: Firestore (8.2.2): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.

SigningCertificateV2 error in DSS verification

Hello! I'm trying to develop an API for PAdES Signatures using PDFTron and OpenSSL and I have an issue while adding signingCertificatev2 attribute which is required by PAdES standard. I tried to use this slice of code to create ESS_SIGNING_CERT field:

ESS_SIGNING_CERT_V2* signing_cert = OSSL_ESS_signing_cert_v2_new_init(EVP_get_digestbyname(this->hash_type.c_str()), this->x509_cert, this->x509_chain, -1);

	int len_sign_cert = i2d_ESS_SIGNING_CERT_V2(signing_cert, NULL);

	unsigned char* encoded_data = (unsigned char*)malloc(len_sign_cert * sizeof(unsigned char));
	unsigned char* copy = encoded_data;
	i2d_ESS_SIGNING_CERT_V2(signing_cert, &encoded_data);

	ASN1_OCTET_STRING* octet_string = ASN1_OCTET_STRING_new();
	ASN1_OCTET_STRING_set(octet_string, copy, len_sign_cert);

	PKCS7_add_signed_attribute(p7Si, NID_id_smime_aa_signingCertificateV2, V_ASN1_OCTET_STRING, octet_string);

I also tried to create this field using this method:

static std::vector<UChar> pdftron::PDF::DigitalSignatureField::GenerateESSSigningCertPAdESAttribute (const Crypto::X509Certificate &  in_signer_cert,
  const Crypto::DigestAlgorithm::Type  in_digest_algorithm_type)

my function has the following code:

PDFDoc& PadesSignatureService::signfile(SignatureHandler&handler,char*Reason)
{

	SignatureHandlerId sigHandlerId = this->document->AddSignatureHandler(handler);
	
	this->signature_field->SignOnNextSaveWithCustomHandler(sigHandlerId);
	
	Date* d = new Date();
	d->SetCurrentTime();
	this->signature_field->SetSigDictTimeOfSigning(*d);

        //i tried with and without this sequence (i replaced it with the OpenSSL field for ESSSIgnatureCert when i didn't use this call)
	std::vector<unsigned char>signing_certificate = this->signature_field->GenerateESSSigningCertPAdESAttribute(((PadesSignatureBHandler&)handler).getcertificate(), ((PadesSignatureBHandler&)handler).getdigestalgorithm());

	Obj sig_dict = this->signature_field->GetSDFObj();

	sig_dict.FindObj("V").PutName("SubFilter", "ETSI.CAdES.detached");

	this->signature_field->SetReason(Reason);

	char *output_file=get_output_filename(this->filename);
	try {
		this->document->Save(output_file, SDFDoc::e_incremental, NULL);
	}
	catch (pdftron::Common::Exception e)
	{
		std::cout << e.GetMessage();
	}
	return *(this->document);
}

Now, the issue is that my signature is recognized by FoxitReader, but not by AdobeReader. The error that I encounter is this one:
image

In FoxitReader, the signature does not have any problem:
image

Using DSS Verification I obtained the following results:
image
image

I attach here also the report of DSS:
DSS-Detailed-report.pdf

I used a GemBox PKCS12 for testing.

Could you help me?
Best Wishes,
Ionut Corbu

How we can validate the required fields?

I want to validate and make sure that end user filled in all the required fields upon clicking Complete button.

I could not find that code in your repo. could you put some light on this please?
image

Thanks

Merge Annotations Issue

I'm attempting to merge my annotations from a new URL on my domain and the xfdf data stored in the database and receive the following error but am unsure what it means or how to troubleshoot that.

{ message:
   'Exception: \n\t Message: XML Parsing error\n\t Conditional expression: false\n\t Version      : 8.1                                     .0.30519\n\t Platform     : Linux\n\t Architecture : AMD64\n\t Filename     : XMLParser.cpp\n\t Function     : Advance\n\t Linenumber   : 132\n',
  type: 'InvalidPDF' }

I pull the pdf link this:

const urlx = await new URL(`https://mydomain.com/uploads/${uuid}/${docRef}`);
const doc = await PDFNet.PDFDoc.createFromURL(urlx.href);

It happens when I attempt to add the xml data via let res to this:

await PDFNet.FDFDoc.createFromXFDF(res);

This is what is contained inside of "res":

<?xml version="1.0" encoding="UTF-8"?><xfdf xmlns="http://ns.adobe.com/xfdf/" xmlns:xml="" xml:space="preserve"><fields><field name="[email protected]"><field name="io_SIGNATURE_16121228784590"><value>_DEFAULT</value></field></field></fields><annots><ink page="0" rect="141.353,462.4451018329939,460.397,581.139" color="#000000" flags="print" name="bb08dcd4-eb07-413b-bb35-31edf0397635" title="Guest" subject="Signature" date="D:20210131115455-08'00'" creationdate="D:20210131115454-08'00'"><inklist><gesture>149.25870672097759,538.9391317040055;150.1611846571623,538.9391317040055;155.57605227427024,544.353 9993211134;165.50330957230145,555.1837345553292;180.84543448744063,567.8184256619145;205.21233876442636 ,578.6481608961303;220.55446367956552,579.550638832315;222.35941955193482,578.6481608961303;221.4569416 1575017,566.0134697895452;206.11481670061102,545.256477257298;177.235522742702,526.3044405974201;151.06 366259334695,511.8647936184657;142.94136116768502,507.3524039375425;168.2107433808554,505.5474480651730 6;237.70154446707403,499.23010251188055;349.60880855397147,483.88797759674134;431.7343007467754,468.545 8526816021;442.56403598099115,464.03346300067886;438.95412423625254,464.03346300067886;430.831822810590 6,464.03346300067886;429.92934487440607,464.9359409368635;429.0268669382213,479.3755879158181;440.75908 010862184,492.9127569585879;454.29624915139175,504.64497012898846;458.808638832315,510.9623156822811;45 8.808638832315,514.5722274270197;456.10120502376105,518.1821391717583</gesture></inklist></ink></annots><pages><defmtx matrix="1,0,0,-1,0,792"/></pages></xfdf>

So based on the error I'm unsure if its a XML issue or a PDF issue in the way that I'm storing the file in the urlx.href link..
Any help in troubleshooting would be appreciated.

code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'

pdftron-sign-app\node_modules\postcss-safe-parser\lib\safe-parser.js:1:17) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
anybody who can help me in this to run?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.