Convert PNG to PDF using Node.js REST API

Follow this article to convert PNG to PDF using Node.js REST API. You will learn to transform PNG to PDF using Node.js RESTful Service with the Aspose.PDF Cloud SDK for Node.js. This guide shows how to convert one or multiple images to a PDF with the desired behavior.

Prerequisite

Steps to Convert PNG File to PDF using Node.js REST Interface

  1. Create an instance of the PdfApi class object to convert PNG to PDF
  2. Set the input image file name(s) and output PDF file name
  3. Read the image(s) into the memory stream and upload to the Cloud storage for conversion
  4. Create an image template to handle the uploaded image
  5. Add as many images as you want to the collection
  6. Create a conversion request by passing the image list and the flag for the OCR image
  7. Call the PutImageInStorageToPdf() method to transform the image to PDF
  8. Check the API response and download the resultant PDF if the operation is successful

These steps summarize the process of converting a PNG to a PDF using Node.js REST API. Create the PdfApi, define the PNG image names and output PDF file, upload the images to Cloud storage, build the image template, create the conversion request, invoke PutImageInStorageToPdf(), and save the resulting PDF locally.

Code to Change a PNG to a PDF using Node.js-based API

This sample code demonstrates how to convert a PNG to PDF using the Node.js Low Code API. When multiple images are added, each image becomes a separate PDF page in the output file. Setting IsOCR to true makes the PDF searchable and selectable.

To learn how to attach an image in a PDF, see the article Attach image to PDF using Node.js REST API.

Keywords: png to pdf using Node.js Low Code API; convert png to pdf using Node.js REST API.