Since version 21.2 Drawings SDK provides the possibility to export more than one different drawings into one output .pdf file through the native export interface. The topic describes how to use this functionality in your custom applications.
It is assumed that you have two drawings (it can be more than two): Test.dwg and Test2.dwg and you want to export their contents into a .pdf file.
The export routine is detailed below.
OdDbDatabasePtr pDb1 = pHostApp->readFile("Test1.dwg");
OdDbDatabasePtr pDb2 = pHostApp->readFile("Test2.dwg");
OdArray < OdString > layoutsArray;
layoutsArray.push_back(L"Layout1");
layoutsArray.push_back(L"Layout1");
OdRxObjectPtrArray dbArray;
dbArray.push_back(pDb1);
dbArray.push_back(pDb2);
Now you have to corresponding arrays: the array of layouts and the array of drawings database. The array of layouts contains two similar names ("Layout1"), but these layouts belong to different databases. Such an approach allows mixing layouts from different databases.
PDFExportParams
class and associate the layouts and the databases with it through calling
the setLayouts()
method:
PDFExportParams params;
params.setLayouts(layoutsArray, &dbArray);
kZoomToExtentsMode
flag:
params.setExportFlags(PDFExportParams::PDFExportFlags(PDFExportParams::kFlateCompression | PDFExportParams::kZoomToExtentsMode));
OdGsPageParams pageParams;
pageParams.set(210, 297);
params.pageParams().resize(nPages, pageParams);
exportPdf()
method:
OdPdfExportModulePtr pModule = ::odrxDynamicLinker()->loadApp(OdPdfExportModuleName, false);
OdPdfExportPtr exporter = pModule->create();
OdUInt32 errorCode = exporter->exportPdf(params);
The output .pdf file is illustrated in the picture below:
Another advantage of multi-database export: databases of different formats can be exported into one output .pdf file. To use this advantage, it is enough to load libraries, which implements the reading functionality of an appropriate format; then read the database content. For example, it is possible to export a BimRv database:
OdStaticRxObject < OdExBimHostAppServices > bimSvc;
::odrxDynamicLinker()->loadModule(OdBmBaseModuleName, false);
::odrxDynamicLinker()->loadModule(OdBmLoaderModuleName, false);
::odrxDynamicLinker()->loadModule(OdBmLabelUtils, false);
OdDbBaseDatabasePtr pDb3 = bimSvc.readFile(L"bim_file.rfa");
After that, we can export the loaded database using the ordinary routine described earlier.
Export to .pdf File Parameters and Flags
Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.
|