Skip to content

Latest commit

 

History

History

javascript

pdf_stamper

PdfStamper - JavaScript client for pdf_stamper The PDF Stamper API enables the possibility to add both static and dynamic stamps on existing PDFs. The stamps can consist of one or more barcode, hyperlink, image, line or text elements. The API also supports digital signatures (blue bar), blockchain registrations and filling out forms The flow is generally as follows: 1. Make a configuration containing the stamp information 2. Create a job specifying the desired configuration 3. Add one or more PDF files to the job 4. Start the job for processing 5. Retrieve the processed files Full API Documentation: https://docs.sphereon.com/api/pdf-stamper/1.0 Interactive testing: A web based test console is available in the Sphereon API Store at https://store.sphereon.com This SDK is automatically generated by the Swagger Codegen project:

  • API version: 1.0
  • Package version: 1.0
  • Build package: io.swagger.codegen.languages.JavascriptClientCodegen For more information, please visit https://sphereon.com

Installation

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install pdf_stamper --save
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

Finally, switch to the directory you want to use your pdf_stamper from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

You should now be able to require('pdf_stamper') in javascript files from the directory you ran the last command above from.

git

If the library is hosted at a git repository, e.g. https://github.com/GIT_USER_ID/GIT_REPO_ID then install it via:

    npm install GIT_USER_ID/GIT_REPO_ID --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually use this library):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var PdfStamper = require('pdf_stamper');

var defaultClient = PdfStamper.ApiClient.instance;

// Configure OAuth2 access token for authorization: oauth2schema
var oauth2schema = defaultClient.authentications['oauth2schema'];
oauth2schema.accessToken = "YOUR ACCESS TOKEN"

var api = new PdfStamper.ConfigApi()

var stampConfiguration = new PdfStamper.StamperConfig(); // {StamperConfig} The PDF stamper configuration


var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.createConfiguration(stampConfiguration, callback);

Documentation for API Endpoints

All URIs are relative to https://gw.api.cloud.sphereon.com/pdf/stamp/1.0

Class Method HTTP request Description
PdfStamper.ConfigApi createConfiguration POST /config Create PDF stamper configuration
PdfStamper.ConfigApi deleteConfiguration DELETE /config/{configId} Delete PDF stamper configuration
PdfStamper.ConfigApi deleteResources DELETE /config/{configId}/streams Delete resources
PdfStamper.ConfigApi getConfiguration GET /config/{configId} Get PDF stamper configuration
PdfStamper.ConfigApi updateConfiguration PUT /config/{configId} Update PDF stamper configuration
PdfStamper.ConfigApi uploadResource POST /config/{configId}/streams/multipart Upload a configuration resource
PdfStamper.JobsApi addContent POST /jobs/{jobId}/streams/content Upload a base64 encoded file
PdfStamper.JobsApi addInputFile POST /jobs/{jobId}/streams/multipart Upload a file
PdfStamper.JobsApi addInputStreamLocations POST /jobs/{jobId}/streams/location Add Input Stream Location(s)
PdfStamper.JobsApi createJob POST /jobs Create PDF stamper job
PdfStamper.JobsApi deleteJob DELETE /jobs/{jobId} Delete a job manually
PdfStamper.JobsApi getFirstStream GET /jobs/{jobId}/streams/result Get the current/first result stream
PdfStamper.JobsApi getJob GET /jobs/{jobId} Job definition and state
PdfStamper.JobsApi getJobs GET /jobs Get all jobs
PdfStamper.JobsApi getStreamById GET /jobs/{jobId}/streams/result/{correlationId} Get the result stream by correlation Id
PdfStamper.JobsApi submitJob PUT /jobs/{jobId} Submit PDF stamper job for processing
PdfStamper.SynchronousApi syncJobContent POST /sync/streams/content Execute a synchronous stamp job with a content request/response.
PdfStamper.SynchronousApi syncJobStreamLocation POST /sync/streams/location Execute a synchronous stamp job with a streamlocation.

Documentation for Models

Documentation for Authorization

oauth2schema

  • Type: OAuth
  • Flow: application
  • Authorization URL:
  • Scopes:
    • global: accessEverything