3.0.0 • Published 5 years ago

@datafire/api2pdf v3.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

@datafire/api2pdf

Client library for Api2Pdf - PDF Generation, Powered by AWS Lambda

Installation and Usage

npm install --save @datafire/api2pdf
let api2pdf = require('@datafire/api2pdf').create({
  HeaderApiKey: "",
  QueryApiKey: ""
});

.then(data => {
  console.log(data);
});

Description

Introduction

Api2Pdf is a powerful PDF generation API with no rate limits or file size constraints. Api2Pdf runs on AWS Lambda, a serverless architecture powered by Amazon to scale to millions of requests while being up to 90% cheaper than alternatives. Supports wkhtmltopdf, Headless Chrome, LibreOffice, and PDF Merge. You can also generate barcodes with ZXING (Zebra Crossing).

SDKs & Client Libraries

We've made a number of open source libraries available for the API

Authorization

Create an account at portal.api2pdf.com to get an API key.

Authorize your API calls

  • GET requests, include apikey=YOUR-API-KEY as a query string parameter
  • POST requests, add Authorization to your header. Authorization: YOUR-API-KEY

Quickstart

If you are looking for just a quick call to grab PDFs of a URL, you can do a GET request like: https://v2018.api2pdf.com/chrome/url?url={UrlToConvert}&apikey={YourApiKey}

For more advanced usage and settings, see the API specification below.

Actions

chromeFromHtmlPost

Convert HTML to a PDF using Headless Chrome on AWS Lambda.

Authorize via Header of Request

Authorization: YOUR-API-KEY

api2pdf.chromeFromHtmlPost({}, context)

Input

Output

chromeFromUrlGET

Convert a URL or Web Page to PDF using Headless Chrome on AWS Lambda. This GET request is for convenience and does not support advanced options. Use the POST request for more flexibility.

Authorize via Query String Parameter

apikey=YOUR-API-KEY

Example

https://v2018.api2pdf.com/chrome/url?url={UrlToConvert}&apikey={YourApiKey}

api2pdf.chromeFromUrlGET({
  "url": ""
}, context)

Input

  • input object
    • url required string: Url of the page to convert to PDF. Must start with http:// or https://.
    • output string: Specify output=json to receive a JSON output. Defaults to PDF file.

Output

chromeFromUrlPost

Convert a URL or Web Page to PDF using Headless Chrome on AWS Lambda..

Authorize via Header of Request

Authorization: YOUR-API-KEY

api2pdf.chromeFromUrlPost({}, context)

Input

Output

libreConvertPost

Convert an office document (Word, Excel, Powerpoint) or an image (jpg, gif, png) to a PDF using LibreOffice on AWS Lambda.

Authorize via Header of Request

Authorization: YOUR-API-KEY

api2pdf.libreConvertPost({}, context)

Input

Output

mergePost

Merge two or more PDFs together on AWS Lambda.

Authorize via Header of Request

Authorization: YOUR-API-KEY

api2pdf.mergePost({}, context)

Input

Output

wkhtmltopdfFromHtmlPost

Convert HTML to a PDF using WkHtmlToPdf on AWS Lambda.

Authorize via Header of Request

Authorization: YOUR-API-KEY

api2pdf.wkhtmltopdfFromHtmlPost({}, context)

Input

Output

wkhtmltopdfFromUrlGET

Convert a URL or Web Page to PDF using WkHtmlToPdf on AWS Lambda. This GET request is for convenience and does not support advanced options. Use the POST request for more flexibility.

Authorize via Query String Parameter

apikey=YOUR-API-KEY

Example

https://v2018.api2pdf.com/wkhtmltopdf/url?url={UrlToConvert}&apikey={YourApiKey}

api2pdf.wkhtmltopdfFromUrlGET({
  "url": ""
}, context)

Input

  • input object
    • url required string: Url of the page to convert to PDF. Must start with http:// or https://.
    • output string: Specify output=json to receive a JSON output. Defaults to PDF file.

Output

wkhtmltopdfFromUrlPost

Convert a URL or Web Page to PDF using WkHtmlToPdf on AWS Lambda..

Authorize via Header of Request

Authorization: YOUR-API-KEY

api2pdf.wkhtmltopdfFromUrlPost({}, context)

Input

Output

zebraGET

See full list of options and documentation here

Authorize via Query String Parameter

apikey=YOUR-API-KEY

Example

https://v2018.api2pdf.com/zebra?format={format}&apikey={YourApiKey}&value={YourText}

api2pdf.zebraGET({
  "format": "",
  "value": ""
}, context)

Input

  • input object
    • format required string: Most common is CODE_39 or QR_CODE
    • value required string: Specify the text value you want to convert
    • showlabel boolean: Show label of text below barcode
    • height integer: Height of the barcode generated image
    • width integer: Width of the barcode generated image

Output

  • output string

Definitions

ApiResponseFailure

  • ApiResponseFailure object
    • reason string: The reason for the PDF generation failure
    • success boolean: Will be false if the operation failed

ApiResponseSuccess

  • ApiResponseSuccess object
    • cost number: Cost of the operation (mbIn + mbOut) * $.001
    • mbIn number: The amount of megabytes of bandwidth used to process the pdf
    • mbOut number: The amount of megabytes of bandwidth generated from the resulting pdf
    • pdf string: A url to the PDF that will exist only for 24 hours
    • success boolean: Will be true if the operation suceeded

ChromeAdvancedOptions

  • ChromeAdvancedOptions object
    • landscape string
    • printBackground boolean

ChromeHtmlToPdfRequest

  • ChromeHtmlToPdfRequest object

ChromeUrlToPdfRequest

  • ChromeUrlToPdfRequest object

LibreOfficeConvertRequest

  • LibreOfficeConvertRequest object
    • fileName string
    • inlinePdf boolean
    • url required string

MergeRequest

  • MergeRequest object
    • fileName string
    • inlinePdf boolean
    • urls required array
      • items string

WkHtmlToPdfAdvancedOptions

  • WkHtmlToPdfAdvancedOptions object
    • orientation string
    • pageSize string

WkHtmlToPdfHtmlToPdfRequest

WkHtmlToPdfUrlToPdfRequest