The export process consists of several stages:
exportPdf()
method of the exporter object.
First, an OdPdfExportModulePtr
should be created.
To do this, use the method loadApp()
of the ODA global dynamic linker
(OdRxDynamicLinker
):
OdPdfExportModulePtr pModule = ::odrxDynamicLinker()->loadApp(OdPdfExportModuleName);
Then create a database to be exported (for example, through loading a drawing
from a specified file) and a PDF exporter instance by calling the
create()
method
of the PdfExportModule
class instance:
//Create a custom Services instance
OdStaticRxObject >MyServices> svcs;
odInitialize(&svcs);
//Create a database and load the drawing into it (assuming that the drawing file name is passed into main function through the second element of argv array).
OdDbDatabasePtr 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 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.
Also see PDFExportParams
class documentation in the API Reference for additional
information about specifying export parameters and flag values.
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. |
exHugeShxFont | Export failed: Cannot convert a SHX font to PDF font format. |
exInvalidPageParams | Export failed: Paper size or margins are invalid. |
exNullOutputStream | Export failed: Output stream for writing the PDF document is NULL or not initialized. |
exLayoutNotFound | Export failed: Database doesn't specify a layout name. |
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. |
exWrongNumberOfPages | Export failed: Invalid PDF document page counter value; number of layouts is not equal to number of pages. |
exCannotRestorePaperFromLayout | Export failed: Error occurred while getting paper parameters from the specified layout. |
exCannotFillFontDescriptor | Export failed: Cannot restore a font descriptor from the font. |
exCannotOpenOverallVport | Export failed: Layout with overall viewport is invalid. |
exBadViewExtents | Export failed: Cannot calculate view extents. |
exLayersRequired_v15 | Export failed: Layer support requires version 1.5 or higher for correct processing. |
exInvalidImageDPI | Export failed: Invalid resolution value (DPI). |
exCannotStartPrcEngine | Export failed: Missing PdfExport service. |
exUseHLRConflictedWithEnablePRC | Export failed: PRC support can be used only when hidden-line removal algorithm is not used during the export. |
exPrcRequired_v16 | Export failed: Version 1.6 or higher required for processing 3D entities. |
exPdfExportServiceMissed | Export failed: PdfExport service missed. |
exOdError (0x00020000) | Export failed: ODA base class error occurred. |
Export to PDF Parameters and Flags
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|