How to read a pdf and convert it to an image (bmp, jpeg, png) and then save it?

  1. FAQ
  2. »
  3. Raster Image Questions

To rasterize a page of a .pdf file, see the getThumbnail function in Drawing/Extensions/PdfiumModule/PdfiumWrapperImpl.cpp.

To write the resulting OdGiRasterImage to a file, use the RxRasterServices module:

OdRxRasterServicesPtr pRasSvcs = odrxDynamicLinker()->loadApp(RX_RASTER_SERVICES_APPNAME);
pRasSvcs->saveRasterImage(pImage, L"out.png");   // type taken from the extension

A complete example of setting up the device and saving the result is Kernel/Exports/RasterExport (see RasterExportCmd.cpp).