Since Drawings SDK version 21.2, you can export more than one drawing to one output PDF file through the native export interface. This topic describes how to use this functionality in your custom applications.
For the following example, there are two (or more) drawings: Test.dwg and Test2.dwg.
To export the two drawings to PDF.
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 two corresponding arrays: the array of layouts and the array of drawing databases. The array of layouts contains two similar names ("Layout1"), but these layouts belong to different databases. This approach allows mixing layouts from different databases.
PDFExportParams
class
and associate the layouts and databases with it by 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:
You can also get access to the list of drawing databases that store the layouts you want to export.
Use the databases()
method of the
PDFExportParams
class for this purpose.
To clear all settings related to exporting layouts from multiple databases, call the
clearMultipleDbSettings()
method of the
PDFExportParams
class.
There is another advantage of multi-database export: databases of different formats can be exported to one output PDF file. Simply load the libraries that implement read functionality for the appropriate file 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");
Then you can export the loaded database using the same routine described earlier.
Export Layouts and Set Page Parameters for PDF
Export to PDF Parameters and Flags
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|