To import PDF file content to a drawing database:
OdRxModulePtr pModule = ::odrxDynamicLinker()->loadModule(OdPdfImportModuleName, false);
OdPdfImportPtr pdfImporter = ((OdPdfImportModule*)pModule.get())->create();;
if (pdfImporter.isNull())
odPrintConsoleString(L"Pdf Importer object creation failed!\n");
properties()
method of the importer object:
OdDbDatabasePtr pDb = pHostApp->createDatabase();
pdfImporter->properties()->putAt(OD_T("Database"), db);
OdString path = pHostApp->findFile(file_name);
pdfImporter->properties()->putAt(OD_T("PdfPath"), OdRxVariantValue(path));
It is assumed that pHostApp
is a raw pointer to an instance of the OdDbHostAppServices
class
which provides platform-dependent functionality for ODA software.
To see the full list of import parameters, refer to PDF Import Parameters.
import()
method of the importer object and analyze the returned value:
OdPdfImport::ImportResult importResult = pdfImporter->import();
if (importResult != OdPdfImport::success)
odPrintConsoleString(L"PdfImportResult = %d\n", (int) importResult);
The table below illustrates results of the import operation.
Value | Description |
---|---|
success
|
The import process successfully finished. |
fail
|
The import process failed. |
bad_password
|
The import process failed because of an incorrect password. |
bad_file
|
The import process failed because of an incorrect input PDF file. |
bad_database
|
The import process failed because of an incorrect destination database object. |
encrypted_file
|
The import process failed because of an encrypted input PDF file. |
invalid_page_number
|
The import process failed because of an invalid page number in the input PDF file. |
image_file_error
|
The import process failed because of an error while saving the image file (the possible reason is an invalid directory for saving). |
::odrxDynamicLinker()->unloadModule(OdPdfImportModuleName);
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|