Convert DWG to PSD using Node.js REST API

This quick tutorial explains how to convert DWG to PSD using Node.js REST API. You will learn to develop a DWG to PSD converter using Node.js REST Interface with the help of a Node.js-based Cloud SDK. The sample code demonstrates the complete process, starting from uploading the source file to retrieve the converted file and saving on the desk.

Prerequisite

Steps for DWG to PSD Converter using Node.js REST Interface

  1. Instantiate CadApi with your Client ID, Client Secret, and base URL so you can call the Aspose.CAD Cloud service
  2. Point inputPath to the DWG you want to convert and set outputPath to a .psd file where the result will be saved
  3. Open the source file, copy its bytes into a MemoryStream, and rewind to the start so it’s ready to send
  4. Wrap the in-memory stream in a PutDrawingPsdRequest to tell the service you want PSD output
  5. Call PutDrawingPsd on your CadApi instance to perform the cloud conversion and receive the result as a stream
  6. Create the destination file at outputPath, copy the result stream into it, and print a success message showing where the PSD was saved

Set up CadApi with your credentials and base URL, set your input DWG and output PSD files, then read the input file into a MemoryStream. Wrap that stream in PutDrawingPsdRequest, call PutDrawingPsd to get the converted data, and save it to outputPath.

Code for DWG to PSD Converter Online using Node.js RESTful Service

The above code shows how to develop a DWG to PSD converter with Node.js-based API. Pass rasterization and format options with your PutDrawingPsdRequest/PutDrawingPdfRequest instead of only the bytes to override the default values. In this way, you can control page size, DPI, background, layout(s), and layers, etc.

This tutorial has guided us to transform DWG to PSD. If you want to convert DWG to PDF, refer to the article on Convert DWG file to PDF using Node.js REST API.

 English