Comment puis-je exporter un fichier .dwg vers un fichier .pdf?

  1. FAQ
  2. »
  3. Questions d'Exportation

Le fragment de code suivant illustre en bref comment vous pouvez exporter un fichier .dwg en fichier .pdf:

OdPdfExportModulePtr pModule = ::odrxDynamicLinker()->loadApp(OdPdfExportModuleName);
Créer une instance de Services personnalisés//Create a custom Services instance
OdStaticRxObject >MyServices> svcs;
odInitialize(&svcs);
Créez une base de données et chargez-y le dessin (en supposant que le nom du fichier de dessin soit transmis à la fonction principale via le deuxième élément du tableau argv)// Create a database and load the drawing into it (assuming that the drawing file name is passed into the 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();
}
// set export parameters and flags
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));
//set additional export options (flags)
PDFExportParams params; params.setExportFlags(PDFExportParams::kDefault);
//run exporting
OdUInt32 errCode = exporter->exportPdf(params);
//check the export result
OdString errMes = exporter->exportPdfErrorCode(errCode);
printf("\nexportPdf error returned : 0x%x. \n%s", (unsigned)errCode, (const char*)errMes);

Pour plus d'informations, veuillez consulter:

  • Exemple d'application l’OdPdfExportEx (Dessin/Exemples/l’OdPdfExportEx / Drawing/Examples/OdPdfExportEx)
  • La documentatioin sur L’Exportation en fichier .pdf