Probably, loading the PdfModule is missing from the beginning of your code:
::odrxDynamicLinker()->loadModule(OdPdfModuleVIModuleName);
Without this module, PdfUnderlay is invisible and the export saves nothing or saves just an extents rectangle.