ByteScout Cloud API Server - CSV To PDF API - JavaScript - Convert CSV To PDF From File (Node.js) - Async API - ByteScout

ByteScout Cloud API Server – CSV To PDF API – JavaScript – Convert CSV To PDF From File (Node.js) – Async API

  • Home
  • /
  • Articles
  • /
  • ByteScout Cloud API Server – CSV To PDF API – JavaScript – Convert CSV To PDF From File (Node.js) – Async API

How to convert CSV to PDF from file (node for CSV to PDF API in JavaScript with ByteScout Cloud API Server

Step-by-step tutorial:How to convert CSV to PDF from file (node to have CSV to PDF API in JavaScript

If you want a quick and easy way to add a required functionality into your application then check this sample source code documentation. ByteScout Cloud API Server was designed to assist CSV to PDF API in JavaScript. ByteScout Cloud API Server is API server that is ready to use and can be installed and deployed in less than 30 minutes on your own Windows server or server in a cloud. It can save data and files on your local server-based file storage or in Amazon AWS S3 storage. Data is processed solely on the API server and is powered by ByteScout engine, no cloud services or Internet connection is required for data processing..

The SDK samples displayed below below explain how to quickly make your application do CSV to PDF API in JavaScript with the help of ByteScout Cloud API Server. This JavaScript sample code can be used by copying and pasting into your project. Once done,just compile your project and click Run. Want to see how it works with your data then code testing will allow the function to be tested and work properly.

Trial version of ByteScout is available for free download from our website. This and other source code samples for JavaScript and other programming languages are available.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

app.js
      
/*jshint esversion: 6 */ // Please NOTE: In this sample we're assuming Cloud Api Server is hosted at "https://localhost". // If it's not then please replace this with with your hosting url. var https = require("https"); var path = require("path"); var fs = require("fs"); // `request` module is required for file upload. // Use "npm install request" command to install. var request = require("request"); // Source CSV file const SourceFile = "./sample.csv"; // Destination PDF file name const DestinationFile = "./result.pdf"; // Prepare request uri for `CSV To PDF` API call var query = `https://localhost/pdf/convert/from/csv`; let reqOptions = { uri: query, formData: { name: path.basename(DestinationFile), async: 'True', file: fs.createReadStream(SourceFile) }, }; // Send request request.post(reqOptions, function (error, response, body) { if (error) { return console.error("Error: ", error); } // Parse JSON response let data = JSON.parse(body); console.log(`Job #${data.jobId} has been created!`); checkIfJobIsCompleted(data.jobId, data.url); }); function checkIfJobIsCompleted(jobId, resultFileUrl) { let queryPath = `/job/check?jobid=${jobId}`; let reqOptions = { host: "localhost", path: encodeURI(queryPath), method: "GET" }; https.get(reqOptions, (response) => { response.on("data", (d) => { response.setEncoding("utf8"); // Parse JSON response let data = JSON.parse(d); console.log(`Checking Job #${jobId}, Status: ${data.status}, Time: ${new Date().toLocaleString()}`); if (data.status == "working") { // Check again after 3 seconds setTimeout(function () { checkIfJobIsCompleted(jobId, resultFileUrl); }, 3000); } else if (data.status == "success") { // Download PDF file var file = fs.createWriteStream(DestinationFile); https.get(resultFileUrl, (response2) => { response2.pipe(file) .on("close", () => { console.log(`Generated PDF file saved as "${DestinationFile}" file.`); }); }); } else { console.log(`Operation ended with status: "${data.status}".`, data); } }) }); }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Cloud API Server Home Page

Explore ByteScout Cloud API Server Documentation

Explore Samples

Sign Up for ByteScout Cloud API Server Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

package.json
      
{ "name": "test", "version": "1.0.0", "description": "PDF.co", "main": "app.js", "scripts": { }, "keywords": [ "pdf.co", "web", "api", "bytescout", "api" ], "author": "ByteScout & PDF.co", "license": "ISC", "dependencies": { "request": "^2.88.2" } }

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Cloud API Server Home Page

Explore ByteScout Cloud API Server Documentation

Explore Samples

Sign Up for ByteScout Cloud API Server Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit ByteScout Cloud API Server Home Page

Explore ByteScout Cloud API Server Documentation

Explore Samples

Sign Up for ByteScout Cloud API Server Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Tutorials:

prev
next