Socket
Socket
Sign inDemoInstall

da-qr-watermark

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    da-qr-watermark

An example of using the DocumentAlchemy API to generate a QR code and then stamp it on each page of a PDF as a watermark image.


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Watermarking a PDF document with a QR code

In this example we will follow a two-step process to first create (and store) an image of a QR code and then use that image to watermark a PDF document.

This example demonstrates several features of the Document Alchemy API:

  1. How to create a QR code image.

  2. How to create a document directly within the Document Alchemy file-store.

  3. How to use a stored document within another API call.

  4. How to watermark a PDF document (using a stored image and an uploaded PDF file).

  5. How to delete a file from the Document Alchemy file-store.

Installing

(These instructions assume you've already installed a modern version of Node.js/IO.js. If you haven't yet, see https://nodejs.org/ for details.)

To simplify the task, this example uses the popular request module (on GitHub at request/request).

To install the module, simply run:

npm install

from within this directory (the one containing package.json and this README file). This will download and install all of the necessary third-party libraries.

Running

To run this example, you will need:

  1. A DocumentAlchemy API key. If you don't have one yet, you can obtain one immediately by signing up for DocumentAlchemy.

  2. A PDF document to watermark.

The general format for running this program is this:

node qr-watermark.js <API-KEY> <TEXT-TO-ENCODE> <PDF-TO-WATERMARK> [<OUTPUT-FILE-NAME>]

For example, if your API key value is HbblCNv7gLN2pasWFK44, the command:

node qr-watermark.js HbblCNv7gLN2pasWFK44 "http://www.example.com/" myDocument.pdf watermarkedDocument.pdf

will create (or overwrite) the file watermarkedDocument.pdf, containing a copy of myDocument.pdf with a QR code (pointing to www.example.com) stamped on every page.

The output of the program may look something like this:

Creating the QR code...
...Success! Created and stored QR code as document ID "8cxwka1gbjoflxrqi2ux2z2".
Watermarking the PDF document using that stored image...
...Success! Watermarked PDF document saved at "watermarkedDocument.pdf".
Deleting the QR code...
...Success! Stored document deleted from the server.

(Note that qr-watermark.js is also directly executable via:

qr-watermark.js <API-KEY> <TEXT-TO-ENCODE> <PDF-TO-WATERMARK> [<OUTPUT-FILE-NAME>]

if your shell recognizes the #!/usr/bin/env node hash-bang identifier.)

How it works

Please review the code and comments found in qr-watermark.js for a detailed explanation of the process.

Keywords

FAQs

Last updated on 10 Mar 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc