1.0.5 • Published 2 years ago

pdf-monkey-wrapper v1.0.5

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

PDFMonkey API Wrapper For Node.js

Setup

Install the package with:

npm i pdf-monkey-wrapper

Usage

The package needs to be configured with your API secret key. This is available in the My account section.

CommonJS

const PDFMonkey = (...args) =>
  import("pdf-monkey-wrapper").then(
    ({ default: PDFMonkey }) => new PDFMonkey(...args)
  );

const API_TOKEN = "xxxxxxxxxxxxxxxx";

(async () => {
  const monkey = await PDFMonkey(API_TOKEN);

  // test your API-KEY
  const { errors, current_user } = await monkey.getAccountDetails();
  console.log(current_user, errors);
})();

ES Modules

import PDFMonkey from "pdf-monkey-wrapper";

const API_TOKEN = "xxxxxxxxxxxxxxxx";

(async () => {
  const monkey = new PDFMonkey(API_TOKEN);

  // test your API-KEY
  const { errors, current_user } = await monkey.getAccountDetails();
  console.log(current_user, errors);
})();

Generate a document

const DOCUMENT_TEMPLATE_ID = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX";

// pass your dynamic info
const payload = {
  user: {
    firstName: "John",
    lastName: "Doe",
  },
};

//Set the document name using the reserved field "_filename" or other metadata
const meta = {
  _filename: "test.pdf",
  customerId: "1985782",
};

// call the generateDocument method
monkey.generateDocument(DOCUMENT_TEMPLATE_ID, payload, meta).then((result) => {
  // print the document url
  console.log(result.document.download_url);
});

Disclaimer

This is not an official PDFMonkey client. It is a wrapper to simplify the usage of the PDFMonkey API. To see the official API documentation, please visit https://pdfmonkey.io/docs.

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago