Skip to content

Output Preview

Starting in version 7.4, Foxit PDF SDK introduced output preview, giving developers precise color management tools. The feature supports separation preview and lets you simulate and test different color profiles to ensure accurate color on different output devices.

Key benefits:

  • Separation preview: View each separation in the document one by one to verify print color accuracy.
  • Color profile testing: Simulate different color profiles and preview how the document will look under different output conditions to avoid color shifts.
  • Better print quality: Accurate color preview helps reduce color issues during printing and improves final print quality.

This feature is widely used in printing, publishing, design, and other industries that require high color accuracy.

See the detailed Output Preview example configuration and run guide for setup steps and sample code.

The code below shows how to use the OutputPreview class in Foxit PDF SDK to generate a color-simulation preview bitmap for a PDF page by setting ICC profiles and separation display. This is useful for printing, publishing, and other scenarios that require precise color management.

Output preview with the OutputPreview class

c++
#include "include/common/fs_common.h"
#include "include/pdf/fs_outputpreview.h"

// Make sure that SDK has already been initialized successfully.

// Set folder path which contains default icc profile files.
Library::SetDefaultICCProfilesPath(default_icc_folder_path);

// Load a PDF document; Get a PDF page and parse it.
// Prepare a Renderer object and the matrix for rendering.

OutputPreview output_preview(pdf_doc);
WString simulation_icc_file_path = input_path + L"icc_profile/USWebCoatedSWOP.icc";
output_preview.SetSimulationProfile(simulation_icc_file_path);
output_preview.SetShowType(OutputPreview::e_ShowAll);
StringArray process_plates = output_preview.GetPlates(OutputPreview::e_ColorantTypeProcess);
StringArray spot_plates = output_preview.GetPlates(OutputPreview::e_ColorantTypeSpot);
// Set check status of process plate to be true, if there's any process plate.
for (int i = 0; i < (int)process_plates.GetSize(); i++) {
	output_preview.SetCheckStatus(process_plates[i], true);
}
// Set check status of spot plate to be true, if there's any spot plate.
for (int i = 0; i < (int)spot_plates.GetSize(); i++) {
	output_preview.SetCheckStatus(spot_plates[i], true);
}

// Generate preview bitmap
Bitmap preview_bitmap = output_preview.GeneratePreviewBitmap(pdf_page, display_matrix, renderer);
C
#include "include/fs_common_c.h"
#include "include/fs_outputpreview_c.h"

// Make sure that SDK has already been initialized successfully.

// Set folder path which contains default icc profile files.
FSErrorCode error_code = FSDK_Library_SetDefaultICCProfilesPath(default_icc_folder_path);

// Load a PDF document; Get a PDF page and parse it.
// Prepare a Renderer object and the matrix for rendering.

FS_OUTPUTPREVIEW_HANDLE output_preview;
FSDK_OutputPreview_Create(pdf_doc, &output_preview);
wchar_t simulation_icc_file_path[MAX_FILE_PATH] = { 0 };
swprintf_s(simulation_icc_file_path, MAX_FILE_PATH, L"%lsicc_profile/USWebCoatedSWOP.icc", input_path);
FSDK_OutputPreview_SetSimulationProfile(output_preview, simulation_icc_file_path);
FSDK_OutputPreview_SetShowType(output_preview, e_FSShowAll);

FS_UINT32 process_plates_length = 0;
FSDK_OutputPreview_GetPlates(output_preview, e_FSColorantTypeProcess, NULL, &process_plates_length);
process_plates = (FS_BSTR*)malloc(sizeof(FS_BSTR) * process_plates_length);
FSDK_OutputPreview_GetPlates(output_preview, e_FSColorantTypeProcess, process_plates, process_plates_length);

FS_UINT32 spot_plates_length = 0;
FSDK_OutputPreview_GetPlates(output_preview, e_FSColorantTypeSpot, NULL, &spot_plates_length);
spot_plates = (FS_BSTR*)malloc(sizeof(FS_BSTR) * spot_plates_length);
FSDK_OutputPreview_GetPlates(output_preview, e_FSColorantTypeSpot, spot_plates, &spot_plates_length);

// Set check status of process plate to be true, if there's any process plate.
for (int i = 0; i < (int)process_plates_length; i++) {
	error_code = FSDK_OutputPreview_SetCheckStatus(output_preview, process_plates[i], true);
}
free(process_plates);

// Set check status of spot plate to be true, if there's any spot plate.
for (int i = 0; i < (int)spot_plates_length; i++) {
	error_code = FSDK_OutputPreview_SetCheckStatus(output_preview, spot_plates[i], true);
}
free(spot_plates);

// Generate preview bitmap
FS_BITMAP_HANDLE preview_bitmap;
error_code = FSDK_OutputPreview_GeneratePreviewBitmap(output_preview, pdf_page, display_matrix, renderer, &preview_bitmap);
java
import com.foxit.sdk.common.Library;
import com.foxit.sdk.common.Renderer;
import com.foxit.sdk.common.fxcrt.Matrix2D;
import com.foxit.sdk.pdf.OutputPreview;
 
// Make sure that SDK has already been initialized successfully.
 
// Set folder path which contains default icc profile files.
Library.setDefaultICCProfilesPath(default_icc_folder_path);
 
// Load a PDF document; Get a PDF page and parse it.
// Prepare a Renderer object and the matrix for rendering.
 
OutputPreview output_preview = new OutputPreview(pdf_doc);
String simulation_icc_file_path = input_path + "icc_profile/USWebCoatedSWOP.icc";
output_preview.setSimulationProfile(simulation_icc_file_path);
output_preview.setShowType(OutputPreview.e_ShowAll);
ArrayList<String> process_plates = output_preview.getPlates(OutputPreview.e_ColorantTypeProcess);
ArrayList<String> spot_plates = output_preview.getPlates(OutputPreview.e_ColorantTypeSpot);
 
// Set check status of process plate to be true, if there's any process plate.
for (int i = 0; i < (int)process_plates.size(); i++) {
    output_preview.setCheckStatus(process_plates.get(i), true);
}
 
// Set check status of spot plate to be true, if there's any spot plate.
for (int i = 0; i < (int)spot_plates.size(); i++) {
    output_preview.setCheckStatus(spot_plates.get(i), true);
}
 
Bitmap preview_bitmap = output_preview.generatePreviewBitmap(pdf_page, display_matrix, renderer);
py
import sys
import site

if sys.version_info.major == 2:
    _PYTHON2_ = True
else:
    _PYTHON2_ = False

if _PYTHON2_:
    # replace with the python2 lib path
    site.addsitedir(‘../../../’)
    from FoxitPDFSDKPython2 import *
else:
    from FoxitPDFSDKPython3 import *

...
# Make sure that SDK has already been initialized successfully.

# Set folder path which contains default icc profile files.
Library.SetDefaultICCProfilesPath(default_icc_folder_path)

# Load a PDF document; Get a PDF page and parse it.
# Prepare a Renderer object and the matrix for rendering.

output_preview = OutputPreview(pdf_doc)
simulation_icc_file_path = input_path + "icc_profile/USWebCoatedSWOP.icc"
output_preview.SetSimulationProfile(simulation_icc_file_path)
output_preview.SetShowType(OutputPreview.e_ShowAll)
process_plates = output_preview.GetPlates(OutputPreview.e_ColorantTypeProcess)
spot_plates = output_preview.GetPlates(OutputPreview.e_ColorantTypeSpot)
process_size = int(process_plates.GetSize())
# Set check status of process plate to be true, if there's any process plate.
for i in range(0, process_size):
    output_preview.SetCheckStatus(process_plates[i], True)

spot_size = int(spot_plates.GetSize())
# Set check status of spot plate to be true, if there's any spot plate.
for i in range(0, spot_size):
    output_preview.SetCheckStatus(spot_plates[i], True)

# Generate preview bitmap
preview_bitmap = output_preview.GeneratePreviewBitmap(pdf_page, display_matrix, renderer)
objc
#include "include/FSPDFObjC.h"
 
// Make sure that SDK has already been initialized successfully.
 
// Set folder path which contains default icc profile files.
[FSLibrary setDefaultICCProfilesPath:default_icc_folder_path];
 
// Load a PDF document; Get a PDF page and parse it.
// Prepare a Renderer object and the matrix for rendering.
 
FSOutputPreview* output_preview = [[FSOutputPreview alloc] initWithPdf_doc:pdf_doc];
NSString* simulation_icc_file_path = [input_path stringByAppendingPathComponent:@"icc_profile/USWebCoatedSWOP.icc"];
[output_preview setSimulationProfile:simulation_icc_file_path];
[output_preview setShowType:FSOutputPreviewShowAll];
NSArray<NSString *>* process_plates = [output_preview getPlates:FSOutputPreviewColorantTypeProcess];
NSArray<NSString *>* spot_plates = [output_preview getPlates:FSOutputPreviewColorantTypeSpot];
 
// Set check status of process plate to be true, if there's any process plate.
for (int i = 0; i < [process_plates count]; i++) {
    [output_preview setCheckStatus:[process_plates objectAtIndex:i] to_check:true];
}
 
// Set check status of spot plate to be true, if there's any spot plate.
for (int i = 0; i < [spot_plates count]; i++) {
    [output_preview setCheckStatus:[spot_plates objectAtIndex:i] to_check:true];
}
 
FSBitmap* preview_bitmap = [output_preview generatePreviewBitmap:pdf_page matrix:display_matrix renderer:renderer];
js
const FSDK = require("@fuxinsoft/foxit-pdf-sdk-node");

...
// Make sure that SDK has already been initialized successfully.

// Set folder path which contains default icc profile files.
FSDK.Library.SetDefaultICCProfilesPath(default_icc_folder_path);

// Load a PDF document; Get a PDF page and parse it.
// Prepare a Renderer object and the matrix for rendering.
let output_preview = new FSDK.OutputPreview(pdf_doc);
let simulation_icc_file_path = input_path + "icc_profile/USWebCoatedSWOP.icc";
output_preview.SetSimulationProfile(simulation_icc_file_path);
output_preview.SetShowType(FSDK.OutputPreview.e_ShowAll);
let process_plates = output_preview.GetPlates(FSDK.OutputPreview.e_ColorantTypeProcess);
let spot_plates = output_preview.GetPlates(FSDK.OutputPreview.e_ColorantTypeSpot);
// Set check status of spot plate to be true, if there's any spot plate.
for (let i = 0; i < spot_plates.GetSize(); i++) {
  output_preview.SetCheckStatus(spot_plates.GetAt(i), true);
}

// Generate preview bitmap
// Only set one process plate to be checked each time and generate the preview bitmap.
for (let i = 0; i < process_plates.GetSize(); i++) {
  if (0 != i)
    output_preview.SetCheckStatus(process_plates.GetAt(i-1), false);
  output_preview.SetCheckStatus(process_plates.GetAt(i), true);
let preview_bitmap = output_preview.GeneratePreviewBitmap(pdf_page, display_matrix, renderer);
}
csharp
using foxit.common;
using foxit.pdf;
 
// Make sure that SDK has already been initialized successfully.
 
// Set folder path which contains default icc profile files.
Library.SetDefaultICCProfilesPath(default_icc_folder_path);
 
// Load a PDF document; Get a PDF page and parse it.
// Prepare a Renderer object and the matrix for rendering.

using (OutputPreview output_preview = new OutputPreview(pdf_doc))
{
string simulation_icc_file_path = input_path + "icc_profile/USWebCoatedSWOP.icc";
    output_preview.SetSimulationProfile(simulation_icc_file_path);
    output_preview.SetShowType(OutputPreview.ShowType.e_ShowAll);
    StringArray process_plates = output_preview.GetPlates(OutputPreview.ColorantType.e_ColorantTypeProcess);
    StringArray spot_plates = output_preview.GetPlates(OutputPreview.ColorantType.e_ColorantTypeSpot);
 
    / Set check status of process plate to be true, if there's any process plate.
    for (uint i = 0; i<process_plates.GetSize(); i++)
    {
        output_preview.SetCheckStatus(process_plates.GetAt(i), true);
    }
 
    / Set check status of spot plate to be true, if there's any spot plate.
    for (uint i = 0; i<spot_plates.GetSize(); i++)
    {
        output_preview.SetCheckStatus(spot_plates.GetAt(i), true);
}
 
    using (foxit.common.Bitmap preview_bitmap = output_preview.GeneratePreviewBitmap(pdf_page, display_matrix, renderer))
    {
        .../ Use preview bitmap or save it.
    }
}
go
import (
. "foxit.com/fsdk"
“fmt”
) 
...
# Make sure that SDK has already been initialized successfully.

# Set folder path which contains default icc profile files.
LibrarySetDefaultICCProfilesPath(default_icc_folder_path)

# Load a PDF document; Get a PDF page and parse it.
# Prepare a Renderer object and the matrix for rendering.

output_preview := NewOutputPreview(pdf_doc)
simulation_icc_file_path := input_path + "icc_profile/USWebCoatedSWOP.icc"
output_preview.SetSimulationProfile(simulation_icc_file_path)
output_preview.SetShowType(OutputPreviewE_ShowAll)
process_plates := output_preview.GetPlates(OutputPreviewE_ColorantTypeProcess)
spot_plates := output_preview.GetPlates(OutputPreviewE_ColorantTypeSpot)
process_size := int(process_plates.GetSize())
# Set check status of process plate to be true, if there's any process plate.
for i :=0; i<process_size;i++{
    output_preview.SetCheckStatus(process_plates.GetAt(i), true)
}
spot_size = int(spot_plates.GetSize())
# Set check status of spot plate to be true, if there's any spot plate.
for i :=0; i<spot_size; i++{
    output_preview.SetCheckStatus(spot_plates.GetAt(i), true)
}
# Generate preview bitmap
preview_bitmap := output_preview.GeneratePreviewBitmap(pdf_page, display_matrix, renderer)