Skip to content

3D Rendering

3D rendering in PDF converts 3D models into 2D images or animations embedded in the document. 3D models can be created with dedicated 3D modeling or CAD (computer-aided design) software and then rendered into a 2D format viewable in PDF.

A 3D annotation lets users add contextual information to specific parts of a 3D model in a PDF. Annotations can include text, images, or links to external resources, providing more detailed information and insight about the model.

System Requirements

Platform: Windows

Languages: C, C++, Java, Python, C#

License: A license key that includes the 3D module

SDK version:

  • Foxit PDF SDK 10.0+

Display 3D Annotations

c++
#include "include/addon/3d/fs_pdf3d.h"

// Load PDF document.
...
PDF3DContext pdf_context = PDF3DContext(pdf_doc);
...

void CXXXView::On3dDisplay3dannot()
{
    / Get the 3d annotation instance array.
    PDF3DAnnotInstanceArray annot_data_arr = pdf_context.GetPage3DAnnotArray(0);
    if (annot_data_arr.GetSize() == 0) return;
    / Class parameter.
    PDF3DAnnotInstance annotData = annot_data_arr.GetAt(0);
    / Activate the canvas to display the 3d annotation. Pass in a window handle to embed canvas.
    annotData.ActivateCanvas(this->GetSafeHwnd());
}
c
#include "include/fs_pdf3d_c.h"

// Load PDF document.
...

FS_PDF3DCONTEXT_HANDLE pdf_context;
FSDK_PDF3DContext_Create(pdf_doc, &pdf_context);

// Get the 3d annotation instance array.
FS_PDF3DANNOTINSTANCE_HANDLE* annot_data_arr = NULL;
FS_UINT32 array_length;
FSDK_PDF3DContext_GetPage3DAnnotArray(pdf_context, 0, NULL, &array_length);
if (array_length == 0) return;
annot_data_arr = (FS_PDF3DANNOTINSTANCE_HANDLE*)malloc(sizeof(FS_PDF3DANNOTINSTANCE_HANDLE) * array_length);
FSDK_PDF3DContext_GetPage3DAnnotArray(pdf_context, 0, annot_data_arr, &array_length);

// Class parameter.
FS_PDF3DANNOTINSTANCE_HANDLE annotData = annot_data_arr[0];
// Activate the canvas to display the 3d annotation. Pass in a window handle to embed canvas.
FSDK_PDF3DAnnotInstance_ActivateCanvas(annotData, window handle);
java
import com.foxit.sdk.addon.pdf3d.*;

// Load PDF document.
...
PDF3DContext pdf_context = new PDF3DContext(pdf_doc);
 
// Get the 3d annotation instance array.
PDF3DAnnotInstanceArray annot_data_arr = pdf_context.getPage3DAnnotArray(0);
if(annot_data_arr.getSize() == 0 ) return;
// Class parameter.
PDF3DAnnotInstance annotData = annot_data_arr.getAt(0);
// Activate the canvas to display the 3d annotation. Pass in a "window handle" to embed canvas.
annotData.activateCanvas(window handle);
py
import os
import sys

// Load PDF document.
...
pdf_context = PDF3DContext(pdf_doc)
 
// Get the 3d annotation instance array.
annot_data_arr = pdf_context.GetPage3DAnnotArray(0)
if(annot_data_arr.GetSize() == 0 ) return
// Class parameter.
annotData = annot_data_arr.GetAt(0)
// Activate the canvas to display the 3d annotation. Pass in a "window handle" to embed canvas.
annotData.ActivateCanvas(window handle)
csharp
using foxit.addon.pdf3d;

// Load PDF document.
...

PDF3DContext pdf_context = new PDF3DContext(pdf_doc);

// Get the 3d annotation instance array.
PDF3DAnnotInstanceArray annot_data_arr = pdf_context.GetPage3DAnnotArray(0);
if (annot_data_arr.GetSize() == 0) return;
// Class parameter.
PDF3DAnnotInstance annotData = annot_data_arr.GetAt(0);
// Activate the canvas to display the 3d annotation. Pass in a window handle to embed canvas.
annotData.ActivateCanvas(window handle);

Set Render Mode and Controller

c++
#include "include/addon/3d/fs_pdf3d.h"

// Rotate to view 3D annotations.
annotData.SetController(PDF3DAnnotInstance::e_ControllerRotate);

// Render 3D annotations as transparent.
annotData.SetRenderMode(PDF3DAnnotInstance::e_RenderModeTransparent);
c
#include "include/fs_pdf3d_c.h"

// Rotate to view 3D annotations.
FSDK_PDF3DAnnotInstance_SetController(FSPDF3DController::e_FSControllerRotate);

// Render 3D annotations as transparent.
FSDK_PDF3DAnnotInstance_SetRenderMode(FSPDF3DRenderMode::e_FSRenderModeTransparent);
java
import com.foxit.sdk.addon.pdf3d.*;

// Rotate to view 3D annotations.
annotData.setController(e_ControllerRotate);

// Render 3D annotations as transparent.
annotData.setRenderMode(e_RenderModeTransparent);
py
import os
import sys

// Rotate to view 3D annotations.
annotData.SetController(PDF3DAnnotInstance.e_ControllerRotate)
// Render 3D annotations as transparent.
annotData.SetRenderMode(PDF3DAnnotInstance.e_RenderModeTransparent)
csharp
using foxit.addon.pdf3d;

// Rotate to view 3D annotations.
annotData.SetController(PDF3DAnnotInstance.PDF3DController.e_ControllerRotate);

// Render 3D annotations as transparent.
annotData.SetRenderMode(PDF3DAnnotInstance.PDF3DRenderMode.e_RenderModeTransparent);