Converting complex 3D models into a universally viewable format is a frequent requirement for engineering and visualization pipelines. Aspose.Slides Cloud SDK for Node.js provides a powerful library that lets you programmatically convert 3D files to PDF in Node.JS. This guide walks you through the prerequisites, installation steps, a detailed code walkthrough, a complete example, REST cURL commands, and key configuration options so you can integrate 3D to PDF conversion into your applications quickly.
Setting Up Aspose.Slides Cloud SDK for Node.js
Before you start, make sure you have the following:
- Node.js 14 or later installed on your development machine.
- An Aspose Cloud account. Create one at the Aspose portal and note your Client Id and Client Secret.
- Internet connectivity for the SDK to call the Aspose Slides Cloud service.
Install the SDK via npm:
npm install asposeslidescloud
You can also download the latest package from the release page. After installation, import the SDK and configure your credentials as shown in the walkthrough below. With the SDK ready, you’re prepared to start converting 3D files.
Building It Step by Step: Convert 3D to PDF in Node.JS
Step 1: Initialize the Slides API Client
Create a configuration object with your client credentials and instantiate the SlidesApi class.
let configuration = new SlidesApi.Configuration("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");
let api = new SlidesApi.SlidesApi(configuration);
The SlidesApi class reference explains all available methods.
Step 2: Specify the Source 3D File
Provide the name of the 3D file you want to convert. The SDK supports formats such as OBJ, STL, and FBX.
let name = "sample.pptx";
Step 3: Define Target Format and Output Path
Set the desired output format to pdf and choose where the converted file will be saved.
let format = "pdf";
let outPath = "output.pdf";
Step 4: Execute the Conversion
Call convertAndSave and handle the promise to confirm success or capture errors.
api.convertAndSave(name, format, outPath, null, null, null, null, null)
.then(() => console.log("Converted"))
.catch(err => console.error(err));
This snippet demonstrates the core of how to convert 3D to PDF in Node.JS using the Aspose.Slides Cloud library.
Complete Code Example: Convert 3D to PDF Efficiently
The following example puts all the pieces together in a single, runnable script.
let SlidesApi = require("asposeslidescloud");
let configuration = new SlidesApi.Configuration("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET");
let api = new SlidesApi.SlidesApi(configuration);
let name = "sample.pptx";
let format = "pdf";
let outPath = "output.pdf";
api.convertAndSave(name, format, outPath, null, null, null, null, null)
.then(() => console.log("Converted"))
.catch(err => console.error(err));
Note: This code example demonstrates the core functionality. Before using it in your project, make sure to update any file paths and configuration values to match your actual environment, verify that all required dependencies are properly installed, and test thoroughly in your development environment. If you encounter any issues, please refer to the official documentation or reach out to the support team for assistance.
Performing 3D to PDF Conversion via REST API Using cURL
If you prefer a pure REST approach, the same conversion can be achieved with cURL commands.
1. Obtain an Access Token
curl -X POST "https://api.aspose.cloud/connect/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET"
2. Upload the Source 3D File
curl -X PUT "https://api.aspose.cloud/v3.0/slides/storage/file/sample.pptx" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-T "./sample.pptx"
3. Request Conversion to PDF
curl -X POST "https://api.aspose.cloud/v3.0/slides/sample.pptx/convert/pdf" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-o "output.pdf"
4. Download the Converted PDF (if not saved directly)
curl -X GET "https://api.aspose.cloud/v3.0/slides/storage/file/output.pdf" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-o "output.pdf"
For a full list of parameters and additional options, see the API reference.
Configuring Conversion Settings for 3D to PDF
The SDK lets you tweak several parameters to control the conversion output. Below are two commonly used options:
- Output Path - Determines where the converted PDF will be saved on the server.
let outPath = "custom_folder/converted.pdf";
- Password Protection - You can add a password to the resulting PDF for security. This option is set via the
passwordparameter in theconvertAndSavemethod (refer to the API reference for exact usage).
Adjusting these settings helps you tailor the conversion to your project’s requirements.
Conclusion
Now that you’ve worked through the tutorial, you should be able to transform 3D slides into PDF files directly from a Node.js app using the Aspose.Slides Cloud SDK for Node.js. The SDK handles the heavy lifting of rendering, while the underlying REST API gives you the flexibility to call the service without the client library. Remember to secure a valid license for any production deployment either by purchasing a subscription on the Aspose pricing page or by requesting a temporary key from the temporary‑license page. With the sample code and configuration tips provided, you can quickly embed 3D‑to‑PDF conversion into your own projects.
FAQs
How can I convert 3D to PDF in Node.JS using Aspose.Slides Cloud SDK?
Use the convertAndSave method of the SlidesApi class after configuring your client credentials. Provide the source 3D file name, set the format to "pdf", and specify an output path.
What 3D file formats does the SDK support for PDF conversion?
The SDK supports OBJ, STL, FBX, 3DS, GLTF, and several other industry‑standard 3D formats. See the documentation for the complete list.
Do I need to manage authentication tokens manually?
No. Once you set the clientId and clientSecret in the configuration object, the SDK automatically obtains and refreshes the access token for each request.
Is there a limit on the size of 3D files I can convert?
The cloud service accepts files up to 200 MB. Larger files should be split or compressed before uploading.