Close

Relief for ODA Team in Ukraine

Learn more
ODA BimRv SDK
Export to .pdf File Process

The export process consists of several stages:

  1. Loading the PDF export module.
  2. Creating a PDF export instance.
  3. Setting the PDF export parameters.
  4. Calling the exportPdf() method of the exporter object.
  5. Analyzing the result of the export process.

First, an OdPdfExportModulePtr should be created. To do this, use the loadApp() method of the ODA Platform global dynamic linker OdRxDynamicLinker:

OdPdfExportModulePtr pModule = ::odrxDynamicLinker()->loadApp(OdPdfExportModuleName);

Then create a database to be exported (for example, through loading a specified .rvt/.rfa file) and a PDF exporter instance by calling the create() method of the OdPdfExportModule class instance:


//Create a database and load the .rvt/.rfa file into it (assuming that the .rvt/.rfa file name is passed into main function through the second element of argv array).
OdBmDatabasePtr pDb = svcs.readFile(argv[1]); 

if (!pDb.isNull())
{
  //creating exporter instance
  OdPdfExportPtr exporter = pModule->create();
  ...
}
    

To set export parameters and flags, use the methods of the PDFExportParams class:


PDFExportParams params;

params.setDatabase(pDb);
params.setVersion(PDFExportParams::kPDFv1_5);

// Creating output stream for writing to PDF file and setting the output parameter
params.setOutput(odSystemServices()->createFile(argv[2], Oda::kFileWrite, Oda::kShareDenyNo, Oda::kCreateAlways));
    

For a detailed description, see Export to .pdf File Parameters and Flags.

Additional export options (flags) can be specified with the setExportFlags() method of the PDFExportParams class.


PDFExportParams params;
params.setExportFlags(PDFExportParams::kDefault);
    

The flags property is a bit mask where each of the bits indicates whether the option is on or off. Export flags are described in the corresponding table of the Export to .pdf File Parameters and Flags topic.

When all parameters are set, PDF export can be performed by calling the exportPdf() method of the PDF exporter instance:


OdUInt32 errCode = exporter->exportPdf(params);
    

The exportPdf() method returns an error code that can be used for checking whether the export process successfully finished. Also you can use the exportPdfErrorCode() method which returns error message text:


OdString errMes = exporter->exportPdfErrorCode(errCode);
printf("\nexportPdf error returned : 0x%x. \n%s", (unsigned)errCode, (const char*)errMes);
    

Export errors are described below.

Identifier Error description
exOk (0x00000000) Export finished successfully.
exInternalError (0x00010000) Export failed: Internal exception occurred.
exNullOutputStream Export failed: Output stream for writing PDF document is NULL or not initialized.
exNullDatabase Export failed: Invalid database pointer (input pointer to database is null).
exUnsupportedVersion Export failed: Specified version of PDF document is not supported by ODA Platform.
exCannotFillFontDescriptor Export failed: Cannot restore a font descriptor from the font.
exBadViewExtents Export failed: Cannot calculate view extents.
exInvalidImageDPI Export failed: Invalid resolution value (DPI).
exPdfExportServiceMissed Export failed: PdfExport service missed.
exOdError (0x00020000) Export failed: ODA Platform base class error occurred.

See Also

Export to .pdf File

Export to .pdf File Parameters and Flags

Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.