# How can I export a .dwg file to a .pdf file?

 1. [FAQ](/faq)
2. »
3. [Export Questions](/faq/export-questions)

The following code fragment briefly illustrates how to export a .dwg file to a .pdf file:

```
OdPdfExportModulePtr pModule = ::odrxDynamicLinker()->loadApp(OdPdfExportModuleName);
//Create a custom Services instance
OdStaticRxObject >MyServices> svcs;
odInitialize(&svcs);
//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);

```

For more information, please refer to:

- OdPdfExportEx sample application (Drawing/Examples/OdPdfExportEx)
- [Exporting to a .pdf File documentation](https://docs.opendesign.com/td/export_to_pdf_01overview.html)
