Permalink
Browse files

added test code

  • Loading branch information...
1 parent ada5886 commit 5c082422a740c21ac33f95267da9830da4507983 @pdfcrowd committed Apr 28, 2011
Showing with 32 additions and 0 deletions.
  1. +22 −0 test/client_test.js
  2. +7 −0 test/makefile
  3. +3 −0 test/sample.html
View
22 test/client_test.js
@@ -0,0 +1,22 @@
+var Pdfcrowd = require('../lib/pdfcrowd');
+var fs = require('fs');
+
+credentials = require('./config').Credentials;
+
+function saveToFile(fname) {
+ return {
+ pdf: function(rstream) {
+ wstream = fs.createWriteStream(fname);
+ rstream.pipe(wstream);
+ },
+ end: function() { console.log("end"); },
+ error: function(errMessage, statusCode) { console.log("ERROR: " + errMessage); },
+ };
+}
+
+myPdfcrowd = new Pdfcrowd(credentials.username,
+ credentials.apikey);
+
+//myPdfcrowd.convertHtml("raw code", saveToFile("html.pdf"))
+//myPdfcrowd.convertURI("http://example.com", saveToFile("url.pdf"))
+myPdfcrowd.convertFile("sample.html", saveToFile("file.pdf"))
View
7 test/makefile
@@ -0,0 +1,7 @@
+all: client_test
+
+client_test:
+ node client_test.js
+
+clean:
+ rm -rf *.pdf
View
3 test/sample.html
@@ -0,0 +1,3 @@
+<p>
+ A <i>sample<i> HTML
+</p>

0 comments on commit 5c08242

Please sign in to comment.