Rendering devices can display the color components of materials differently, and the PDF export process uses an ambient color behavior option to get the best-looking exported drawing.
The picture below illustrates the difference between rendering a material with a texture using the OpenGL ES2 and OpenGL devices.
Each rendering device uses a different interpretation of a material's ambient color component for a material with texture.
When exporting the drawing above to the 3D PDF (PDF with integrated PRC) format, you can get different rendering results in the output PDF document.
As in the case with rendering devices, the difference is caused by the interpretation of the material's ambient color component for a material with texture in the PDF viewer application (for example, Adobe® Reader®).
The PDF Export module provides a special option in the PDFExportParams class that controls the ambient color rendering within the PDF export,PrcExportColorComponentBehavior:
- kExportAsIs — The ambient color component is exported as is. The model rendering in Adobe Reader may differ from the original drawing rendering in ODA Software.
- kExportWhite — The ambient color component is exported as white. The model rendering in Adobe Reader is closest to the original drawing rendering in ODA Software using the OpenGL device.
- kExportNotInited — The ambient color component is exported as a united color. The model rendering in Adobe Reader is closest to the original drawing rendering in ODA Software using the GLES2 device.
To get the current setting of the ambient color option, use the getPrcExportAmbientColorBehavior() method of the PDFExportParams class. To set the ambient color option, call the setPrcExportAmbientColorBehavior() method.
The source fragment below demonstrates how to use the ambient color option when exporting a .dwg drawing to a 3D PDF document:
OdPdfExportModulePtr pModule = ::odrxDynamicLinker()->loadApp(OdPdfExportModuleName, false);
::odrxDynamicLinker()->loadApp(OdPrcModuleName, false);
::odrxDynamicLinker()->loadApp(OdDwg2PrcExportModuleName, false);
OdPdfExportPtr exporter = pModule->create();
params.setDatabase(db);
params.setVersion(PDFExportParams::kPDFv1_6);
params.setOutput(odSystemServices()->createFile(outPdfFile, Oda::kFileWrite, Oda::kShareDenyNo, Oda::kCreateAlways));
params.setExportFlags(PDFExportParams::kDefault);
params.setPRCMode(PDFExportParams::kAsMesh);
pContext = odCreatePrcAllInSingleViewContextForTD();
params.setPRCContext(pContext);
// Sets prc behaviour when exporting ambient color components to PRC in the texture case
params.setPrcExportAmbientColorBehavior(PDF3D_ENUMS::kExportAsIs);
// initialize the conversion parameters: Layouts
OdDbBlockTableRecordPtr pLayoutBlock = db->getActiveLayoutBTRId().safeOpenObject();
OdDbLayoutPtr pLayout = pLayoutBlock->getLayoutId().safeOpenObject();
params.layouts().push_back(pLayout->getLayoutName());
params.pageParams().resize(1, OdGsPageParams());
OdUInt32 errCode = exporter->exportPdf(params);