Skip to content

A native JavaScript / Node.js client for the DocRaptor document generation service.

License

Notifications You must be signed in to change notification settings

DocRaptor/docraptor-javascript

Repository files navigation

DocRaptor JavaScript Native Client Library

WARNING: This is not production ready, you should use https://docraptor.com/documentation/node

This is a JavaScript library and Node.js module for using DocRaptor API to convert HTML to PDF and XLSX.

Installation

npm install docraptor

Usage

See examples for runnable examples with file output, error handling, etc.

var docraptor = require("docraptor");

var auth = docraptor.ApiClient.default.authentications.basicAuth;
auth.username = "YOUR_API_KEY_HERE"; // this key works for test documents

doc_api = new docraptor.DocApi();

doc_api.createDoc({
  test: true,                                                    // test documents are free but watermarked
  document_content: "<html><body>Hello World</body></html>",     // supply content directly
  // document_url: "http://docraptor.com/examples/invoice.html", // or use a url
  name: "test",                                                  // help you find a document later
  document_type: "pdf",                                          // pdf or xls or xlsx
  // javascript: true,                                           // enable JavaScript processing
  // prince_options: {
  //   media: "screen",                                          // use screen styles instead of print styles
  //   baseurl: "http://hello.com",                              // pretend URL when
  // },
  }, function(error, data, response) {
    // ...
  }
})

Docs created like this are limited to 60 seconds to render, check out the async example which allows 10 minutes.

We have guides for doing some of the common things:

More Help

DocRaptor has a lot of more styling and implementation options.

Stuck? We're experts at using DocRaptor so please email us if you run into trouble.

Development

The majority of the code in this repo is generated using swagger-codegen on docraptor.yaml. You can modify this file and regenerate the client using script/generate_language javascript.

The generated client needed a few fixes

  • response buffer
  • binary string response handling

Release Process

  1. script/test
  2. Increment version in code:
  • swagger-config.json
  • package.json
  1. Update CHANGELOG.md
  2. TODO

Version Policy

This library follows Semantic Versioning 2.0.0.

About

A native JavaScript / Node.js client for the DocRaptor document generation service.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published