Creating immersive documents that let users rotate, zoom, and explore 3‑dimensional models directly inside a PDF is a powerful way to enhance product catalogs, engineering reports, and training manuals. Aspose.Words Cloud SDK for .NET provides a cloud‑based library that makes it easy to embed and preserve 3D content when converting DOCX files to PDF. In this guide you will learn how to generate interactive 3D PDF in C#, see a complete code sample, explore the equivalent cURL REST calls, and understand deployment considerations for real‑world applications.
The 3D PDF Generation Scenario Requirements
Developers building engineering portals or interactive product brochures often need to deliver PDFs that contain embedded 3D models. The typical requirements are:
- The source document must be a DOCX that already includes a 3D model in U3D or PRC format.
- The resulting PDF must retain the 3D data so that viewers like Adobe Acrobat can render it interactively.
- The conversion process should be automated, run on a server, and work with large batches without manual intervention.
Traditional desktop tools cannot be scripted reliably in a cloud environment, and they often strip out the 3D streams during conversion. A programmatic solution that preserves the 3D model while offering PDF/A compliance is therefore essential.
The Approach: Leveraging Aspose.Words Cloud for 3D PDF
Aspose.Words Cloud SDK for .NET offers a set of REST‑based operations that run on Aspose’s secure servers. Key capabilities that address the scenario include:
- Direct upload of DOCX files to Aspose Cloud storage.
PdfSaveOptionsDatathat lets you control PDF compliance, field updates, and, crucially, the preservation of embedded 3D content.- Asynchronous conversion methods that return a stream, allowing you to write the output file directly to disk.
Together these features enable a clean 3D to PDF workflow that can be integrated into CI pipelines, web services, or background jobs. Detailed API information is available in the official documentation and the API reference.
Generate Interactive 3D PDF in C#: Implementation
Below is a step‑by‑step walkthrough of the implementation. Each step includes a short code excerpt taken directly from the full example.
Install the Aspose.Words Cloud SDK for .NET
First, add the NuGet package to your project.
dotnet add package Aspose.Words-Cloud
You can also download the binaries from the download page.
Configure the WordsApi Client
Create a Configuration object with your client credentials and instantiate WordsApi.
var config = new Configuration
{
ClientId = "YOUR_CLIENT_ID",
ClientSecret = "YOUR_CLIENT_SECRET"
};
var wordsApi = new WordsApi(config);
The WordsApi class is documented in the API reference.
Upload a DOCX That Contains an Embedded 3D Model
Open the local DOCX file and upload it to Aspose Cloud storage, overwriting any existing file with the same name.
using (var fileStream = File.OpenRead(localDocxPath))
{
var uploadRequest = new UploadFileRequest(fileStream, remoteFileName);
await wordsApi.UploadFileAsync(uploadRequest);
}
Make sure the DOCX already includes a U3D or PRC model; this is the 3D Model Format that the SDK preserves.
Set PDF Save Options to Preserve 3D Content
Configure PdfSaveOptionsData to keep the 3D streams and use PDF/A‑1b compliance.
var pdfOptions = new PdfSaveOptionsData
{
UpdateFields = false,
Compliance = PdfCompliance.PdfA1b,
SaveFormat = "pdf"
};
These options are part of the 3D to PDF Workflow that ensures the interactive model remains intact.
Convert and Download the Interactive 3D PDF
Invoke the conversion request and write the resulting stream to a local PDF file.
var convertRequest = new ConvertDocumentRequest(
remoteFileName,
format: "pdf",
saveOptions: pdfOptions
);
using (var pdfStream = await wordsApi.ConvertDocumentAsync(convertRequest))
using (var fileWriter = File.Create(outputPdfPath))
{
await pdfStream.CopyToAsync(fileWriter);
}
After conversion you may optionally delete the temporary file from cloud storage.
Complete Code Example: Interactive 3D PDF Generation in C#
The following code demonstrates the entire process from start to finish.
using System;
using System.IO;
using System.Threading.Tasks;
using Aspose.Words.Cloud.Sdk;
using Aspose.Words.Cloud.Sdk.Model;
using Aspose.Words.Cloud.Sdk.Model.Requests;
namespace Generate3DPdfExample
{
class Program
{
static async Task Main(string[] args)
{
// -----------------------------------------------------------------
// 1. Configure Aspose.Words Cloud client (replace with your credentials)
// -----------------------------------------------------------------
var config = new Configuration
{
ClientId = "YOUR_CLIENT_ID",
ClientSecret = "YOUR_CLIENT_SECRET"
};
var wordsApi = new WordsApi(config);
// -----------------------------------------------------------------
// 2. Define file names and paths (generic placeholders)
// -----------------------------------------------------------------
const string localDocxPath = "input.docx"; // DOCX that already contains an embedded 3D model (U3D/PRC)
const string remoteFileName = "input.docx"; // Name used in Aspose Cloud storage
const string outputPdfPath = "output.pdf";
// -----------------------------------------------------------------
// 3. Upload the DOCX to Aspose Cloud storage (overwrites if exists)
// -----------------------------------------------------------------
using (var fileStream = File.OpenRead(localDocxPath))
{
var uploadRequest = new UploadFileRequest(fileStream, remoteFileName);
await wordsApi.UploadFileAsync(uploadRequest);
}
// -----------------------------------------------------------------
// 4. Prepare PDF save options – enable 3D content preservation
// -----------------------------------------------------------------
var pdfOptions = new PdfSaveOptionsData
{
// Preserve the embedded 3D model; the option name may vary depending on API version.
// Setting 'UpdateFields' to false speeds up conversion when fields are not required.
UpdateFields = false,
// Use PDF/A-1b compliance to keep the document portable while still supporting 3D.
Compliance = PdfCompliance.PdfA1b,
// Ensure the output is a single PDF file.
SaveFormat = "pdf"
};
// -----------------------------------------------------------------
// 5. Convert the uploaded DOCX to PDF with the defined options
// -----------------------------------------------------------------
var convertRequest = new ConvertDocumentRequest(
remoteFileName,
format: "pdf",
saveOptions: pdfOptions
);
using (var pdfStream = await wordsApi.ConvertDocumentAsync(convertRequest))
using (var fileWriter = File.Create(outputPdfPath))
{
await pdfStream.CopyToAsync(fileWriter);
}
// -----------------------------------------------------------------
// 6. Clean up remote file (optional)
// -----------------------------------------------------------------
var deleteRequest = new DeleteFileRequest(remoteFileName);
await wordsApi.DeleteFileAsync(deleteRequest);
Console.WriteLine($"3D PDF generated successfully at '{Path.GetFullPath(outputPdfPath)}'.");
}
}
}
Note: This code example demonstrates the core functionality. Before using it in your project, make sure to update the file paths (
input.docx,output.pdf, etc.) to match your actual file locations, 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.
Perform 3D PDF Conversion with cURL and the REST API
The same operation can be executed via cURL calls against the Aspose.Words Cloud REST endpoints.
- Obtain an access token (replace placeholders with your credentials).
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"
- Upload the DOCX containing the 3D model.
curl -X PUT "https://api.aspose.cloud/v4.0/words/storage/file/input.docx" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @input.docx
- Request PDF conversion with 3D preservation.
curl -X POST "https://api.aspose.cloud/v4.0/words/input.docx/saveAs/pdf" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"PdfSaveOptions": {
"UpdateFields": false,
"Compliance": "PdfA1b"
}
}' \
-o output.pdf
- Download the resulting PDF (the previous command already saved it locally, but you can also fetch it directly).
For more details on request bodies and additional parameters, see the official API documentation.
Deployment Considerations for 3D PDF Generation
When integrating this solution into a production environment, keep the following points in mind:
- Server Location - The conversion runs on Aspose’s cloud servers, so ensure your network allows outbound HTTPS traffic to
api.aspose.cloud. - Licensing - A commercial license is required for production use. You can start with a temporary license from the temporary license page.
- Scalability - Because the API is stateless, you can parallelize uploads and conversions across multiple worker instances to handle high‑volume batches, supporting full 3D to PDF Automation.
Conclusion
Generating interactive 3D PDF in C# becomes straightforward with the Aspose.Words Cloud SDK for .NET. By following the steps above you can embed U3D or PRC models, preserve them during PDF conversion, and automate the workflow with either the .NET library or direct REST calls. Remember to secure a proper license for production and to test the generated PDFs in a viewer that supports 3D, such as Adobe Acrobat. With this capability you can deliver richer, more engaging documents for engineering, marketing, and training scenarios.
FAQs
How do I generate interactive 3D PDF in C# using Aspose.Words Cloud?
Use the SDK to upload a DOCX that already contains a U3D or PRC model, configure PdfSaveOptionsData to keep the 3D streams, and call ConvertDocumentAsync. The full code example in this article shows the exact sequence.
Which 3D model formats can I embed for the PDF conversion?
Aspose.Words Cloud supports U3D and PRC formats, which are the standard formats for interactive 3D content in PDFs.
Is it possible to run the conversion without writing any C# code?
Yes, the same process can be performed with cURL commands against the Aspose.Words Cloud REST API, as demonstrated in the cURL section.
Where can I find pricing and licensing information?
Commercial licensing details are available on the product page, and you can obtain a temporary license for evaluation from the temporary license page.