Close

Relief for ODA Team in Ukraine

Learn more
ODA Drawings SDK
PDF Import Process

To import PDF file content to a drawing database:

  1. Load the PDF import module:
    
    OdRxModulePtr pModule = ::odrxDynamicLinker()->loadModule(OdPdfImportModuleName, false);
            
  2. Create the PDF importer object and check whether it was successfully created:
    
    OdPdfImportPtr  pdfImporter = ((OdPdfImportModule*)pModule.get())->create();;
    if (pdfImporter.isNull())
      odPrintConsoleString(L"Pdf Importer object creation failed!\n");
            
  3. Set import parameters using the 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.

  4. Run the 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).

  5. Do not forget to unload the PDF import module after the import is finished:
    
    ::odrxDynamicLinker()->unloadModule(OdPdfImportModuleName);
            

See Also

PDF Import Parameters
Font Handling for PDF Import
PDF Import Usage Examples
Importing PDF Files
OdPdfImport Classes
Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.