Gottox / node-pdfutils

tool for analyzing and converting PDF
103 stars 23 forks source link

Example for streaming the output to an http request? #7

Closed wmbutler closed 10 years ago

wmbutler commented 10 years ago

I'm attempting to use this to split a file into individual pages and then push to couchdb. Is there any chance that you could provide an example in the readme where you make reference to streams?

Ideally I'd like to:

for ( var i=0 ; i<doc.length; i++) {
  doc[i].toPDF().toStream()
}

Then I'd like to pick up the stream for each file and push make 1 http request per page.

wmbutler commented 10 years ago

Getting closer, but just don't know how to redirect this to the http PUT / POST.

doc[i].asPDF().pipe(toCouch);
Gottox commented 10 years ago

See this example: http://nodejs.org/docs/v0.10.0/api/http.html#http_http_request_options_callback

Replace the write() and end() calls by doc[i].asPDF().pipe(req);.

wmbutler commented 10 years ago

Thanks