├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── lib └── pdfcrowd.js ├── makefile ├── package.json └── test ├── client_test.js ├── makefile ├── sample.html └── sample.html.zip /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | .*~ 3 | \#*\# 4 | .\#* 5 | dist/* 6 | test/config.js 7 | node-pdfcrowd.tgz 8 | test_files 9 | package-lock.json -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Change Log 2 | ========== 3 | 4 | 6.5.0 5 | ----- 6 | 7 | - NEW: The error handling system has been updated. This includes revised status codes and messages, as well as the addition of new methods to the error class: getStatusCode, getReasonCode, and getDocumentationLink. The getCode method is deprecated and should be replaced with getStatusCode. 8 | 9 | 6.4.0 10 | ----- 11 | 12 | - NEW: setConverterUserAgent method for HtmlToPdf and HtmlToImage API client 13 | 14 | 6.3.0 15 | ----- 16 | 17 | - NEW: setHtmlNamespace method for PdfToHtml API client 18 | - NEW: setConverterVersion method for PdfToHtml API client 19 | - fix a crash in PdfToHtml API client when PDF file contains a specific type3 font 20 | 21 | 6.2.1 22 | ----- 23 | 24 | - fix setContentViewportWidth and setContentViewportHeight accepts a numeric value followed by the "px" unit to specify pixels 25 | 26 | 6.2.0 27 | ----- 28 | 29 | - NEW: setType3Mode and setCustomCss methods for PdfToHtml API client 30 | - NEW: the conversion config JSON supports `odd`, `even`, and `last` for page definition 31 | - NEW: setPrintPageRange supports `odd`, `even`, and `last` for page selection 32 | 33 | 6.1.0 34 | ----- 35 | 36 | - NEW: setConversionConfig and setConversionConfigFile methods for configuring HtmlToPdf API client 37 | 38 | 6.0.1 39 | ----- 40 | 41 | - minor reorder of methods 42 | 43 | 6.0.0 44 | ----- 45 | 46 | - NEW: the converter version 24.04 is used by default for the HtmlToPdf and HtmlToImage API client 47 | - NEW: setContentViewportWidth method for the HtmlToPdf API client 48 | - NEW: setContentViewportHeight method for the HtmlToPdf API client 49 | - NEW: setContentFitMode method for the HtmlToPdf API client 50 | - NEW: option `all` for the HtmlToPdf API client `setRemoveBlankPages` method 51 | 52 | 5.20.0 53 | ------ 54 | 55 | - NEW: PdftoImage API client for the converion from PDF to image 56 | 57 | 5.19.0 58 | ------ 59 | 60 | - NEW: `setConverterVersion` can now be switched to the beta version of converter 24.04 61 | 62 | 5.18.0 63 | ------ 64 | 65 | - NEW: setSplitLigatures method for the PdfToHtml API client 66 | 67 | 5.17.0 68 | ------ 69 | 70 | - NEW: setImageFormat method for the PdfToHtml API client 71 | - NEW: mode value 'none' for setImageMode method for the PdfToHtml API client 72 | 73 | 5.16.0 74 | ------ 75 | 76 | - NEW: setDpi method for the PdfToHtml API client 77 | 78 | 5.15.0 79 | ------ 80 | 81 | - NEW: setMaxLoadingTime method for the HtmlToPdf and HtmlToImage API clients 82 | 83 | 5.14.0 84 | ------ 85 | 86 | - NEW: setCustomCss method for the HtmlToPdf and HtmlToImage API clients 87 | 88 | 5.13.0 89 | ------ 90 | 91 | - NEW: setRemoveBlankPages method for the HtmlToPdf API client 92 | 93 | 5.12.1 94 | ------ 95 | 96 | - FIX: retry conversion on error 503 97 | 98 | 5.12.0 99 | ------ 100 | 101 | - NEW: setCropAreaX, setCropAreaY, setCropAreaWidth, setCropAreaHeight and setRemoveBorders methods for ImageToImage and ImageToPdf API client 102 | 103 | 5.11.0 104 | ------ 105 | 106 | - NEW: canvas setup options for ImageToImage API client 107 | - NEW: page setup, watermark/background and output options for ImageToPdf API client 108 | - FIX: rotation for ImageToPdf API client 109 | 110 | 5.10.0 111 | ------ 112 | 113 | - NEW: PdftoText API client for the converion from PDF to plain text 114 | - NEW: ImageToPdf API client supports watermarks, backgrounds and PDF format options 115 | - NEW: single-page-fit-ex mode for setSmartScalingMode API method 116 | 117 | 5.9.0 118 | ----- 119 | 120 | - NEW: getTotalPageCount to get the total page count of the source document 121 | - NEW: readability-v4 mode for setReadabilityEnhancements API method 122 | 123 | 5.8.0 124 | ----- 125 | 126 | - images can be used as a watermark and a background in HTML to PDF and PDF to PDF converter 127 | 128 | 5.7.0 129 | ----- 130 | 131 | - NEW: readability-v2 and readability-v3 modes for setReadabilityEnhancements API method 132 | 133 | 5.6.2 134 | ----- 135 | 136 | - minor update of documentation links 137 | 138 | 5.6.1 139 | ----- 140 | 141 | - minor update of the text of the error message 142 | 143 | 5.6.0 144 | ----- 145 | 146 | - NEW: setEnablePdfForms to convert HTML forms to fillable PDF forms 147 | - minor update of the text of the error message 148 | 149 | 5.5.0 150 | ----- 151 | 152 | - NEW: setAutodetectElementToConvert to detect the main HTML element for conversion 153 | - NEW: setReadabilityEnhancements to enhance the input HTML to improve the readability 154 | - NEW: pdfcrowd-source-title CSS class available for header and footer HTML 155 | 156 | 5.4.0 157 | ----- 158 | 159 | - NEW: PDF to HTML converter 160 | - NEW: setInputPdfPassword for PDF to PDF converter 161 | 162 | 5.3.0 163 | ----- 164 | 165 | - NEW: setUseMobileUserAgent for HTML to PDF and HTML to Image 166 | 167 | 5.2.2 168 | ----- 169 | 170 | - FIX: the hyperlinks to the Pdfcrowd API documentation have been updated 171 | 172 | 5.2.0 173 | ----- 174 | 175 | - NEW: setZipMainFilename 176 | - NEW: setZipHeaderFilename 177 | - NEW: setZipFooterFilename 178 | - NEW: setExtractMetaTags 179 | - NEW: setTitle for PDF to PDF 180 | - NEW: setSubject for PDF to PDF 181 | - NEW: setAuthor for PDF to PDF 182 | - NEW: setKeywords for PDF to PDF 183 | 184 | 5.1.1 185 | ----- 186 | 187 | - minor documentation updates 188 | 189 | 5.1.0 190 | ----- 191 | 192 | - NEW: convertStream 193 | - NEW: convertStreamToStream 194 | - NEW: convertStreamToFile 195 | - FIX: The main window scrollbar is not rendered in HTML to Image outputs. 196 | 197 | 5.0.0 198 | ----- 199 | 200 | - NEW: converter version 20.10 supported 201 | - NEW: setConverterVersion 202 | - NEW: setLoadIframes 203 | - NEW: setLocale 204 | - NEW: setNoHeaderFooterHorizontalMargins 205 | - NEW: setCssPageRuleMode 206 | - NEW: setLayoutDpi 207 | - NEW: setContentsMatrix 208 | - NEW: setHeaderMatrix 209 | - NEW: setFooterMatrix 210 | - NEW: setDisablePageHeightOptimization 211 | - NEW: setHeaderFooterCssAnnotation 212 | - NEW: setMainDocumentCssAnnotation 213 | - NEW: setBackgroundColor for the HtmlToImage API client 214 | 215 | Older versions 216 | -------------- 217 | 218 | - Details on the [Pdfcrowd blog](https://pdfcrowd.com/blog/). 219 | 220 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 pdfcrowd.com 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pdfcrowd API - Node.js client library 2 | 3 | The Pdfcrowd API lets you easily convert between HTML, PDF and various image 4 | formats in your Node.js applications. 5 | 6 | To use the API, you need an account on 7 | [http://pdfcrowd.com](https://pdfcrowd.com). If you don't have one, you 8 | can sign up [here](https://pdfcrowd.com/pricing/api/). 9 | 10 | ## Installation 11 | 12 | To install via npm: 13 | 14 | $ npm install pdfcrowd 15 | 16 | Or clone from GitHub and create a symlink in `~/.node_libraries`: 17 | 18 | $ git clone git@github.com:pdfcrowd/pdfcrowd-nodejs.git 19 | $ ln -s /path/to/pdfcrowd-nodejs ~/.node_libraries/pdfcrowd 20 | 21 | Dependencies 22 | 23 | * http *native module* 24 | * querystring *native module* 25 | * fs *native module* 26 | 27 | 28 | ## Learn more 29 | 30 | * API Home: 31 | * API Reference: 32 | * Interactive API Playground: 33 | * Node.js: 34 | * Express.js: 35 | 36 | ## License 37 | 38 | This client library is licensed under the MIT License. 39 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | VERSION = 6.5.0 2 | 3 | .PHONY: dist 4 | dist: 5 | rm -rf dist/ ; mkdir dist/ 6 | rm -rf /tmp/pdfcrowd-$(VERSION) 7 | mkdir /tmp/pdfcrowd-$(VERSION) 8 | cp -r * /tmp/pdfcrowd-$(VERSION) 9 | cd /tmp && ls -la pdfcrowd-$(VERSION) 10 | cd /tmp && zip -r $(CURDIR)/dist/pdfcrowd-$(VERSION)-nodejs.zip \ 11 | -x\*dist\* \ 12 | pdfcrowd-$(VERSION) 13 | 14 | publish: 15 | npm publish --access public 16 | 17 | clean: 18 | rm -rf dist/* *.tgz 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pdfcrowd", 3 | "version": "6.5.0", 4 | "repository": { 5 | "type": "git", 6 | "url": "git@github.com:pdfcrowd/pdfcrowd-nodejs.git" 7 | }, 8 | "directories": { 9 | "lib": "lib" 10 | }, 11 | "engines": { 12 | "node": "*" 13 | }, 14 | "files": [ 15 | "" 16 | ], 17 | "description": "A client library for the Pdfcrowd API. It lets you convert between HTML, PDF and various image formats.", 18 | "homepage": "https://pdfcrowd.com/api/", 19 | "author": "Pdfcrowd (https://pdfcrowd.com/api/)", 20 | "main": "./lib/pdfcrowd", 21 | "license": "MIT" 22 | } 23 | -------------------------------------------------------------------------------- /test/client_test.js: -------------------------------------------------------------------------------- 1 | var pdf = require('../lib/pdfcrowd'); 2 | var assert = require('assert'); 3 | 4 | credentials = require('./config').Credentials; 5 | 6 | myPdfcrowd = new pdf.Pdfcrowd(credentials.username, 7 | credentials.apikey, 8 | credentials.host); 9 | 10 | var apiOptions = { 11 | width: "11in", 12 | height: "8.5in", 13 | vmargin: ".4in", 14 | footer_html: '
\ 15 | Page %p out of %n\ 16 |
' 17 | }; 18 | 19 | assert.throws(function() { myPdfcrowd.convertHtml(""); }); 20 | assert.throws(function() { myPdfcrowd.convertURI(null); }); 21 | 22 | function out_stream(name) { 23 | return pdf.saveToFile("../test_files/out/node_client_" + name); 24 | } 25 | 26 | myPdfcrowd.convertFile("sample.html.zip", out_stream("zfile.pdf"), apiOptions); 27 | myPdfcrowd.convertHtml("raw code", out_stream("html.pdf")); 28 | myPdfcrowd.convertURI("http://example.com", out_stream("url.pdf")); 29 | myPdfcrowd.convertFile("sample.html", out_stream("file.pdf")); 30 | myPdfcrowd.convertHtml('footer example', out_stream("footer.pdf"), apiOptions); 31 | 32 | 33 | -------------------------------------------------------------------------------- /test/makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @true 3 | 4 | test: 5 | node client_test.js 6 | 7 | clean: 8 | rm -rf *.pdf -------------------------------------------------------------------------------- /test/sample.html: -------------------------------------------------------------------------------- 1 |

2 | A sample HTML 3 |

4 | -------------------------------------------------------------------------------- /test/sample.html.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdfcrowd/pdfcrowd-nodejs/a45acfc1e1f90e4195044c096b9594b90b69f5b4/test/sample.html.zip --------------------------------------------------------------------------------