Set the abort-check callback.
void pdfSetAbortCheckCbk(PDFHandle pdf, int (*cbk)(void *data), void *cbkData)
This function sets a callback which will be called periodically during rasterization.

If, at any point, the abort check callback returns true (non-zero), the rasterization will be aborted, and the rasterization function will return.

The cbkData argument is passed to the callback function.

int abortCheck(void *data) { if (... some abort condition ...) { return 1; } return 0; } ... pdfSetAbortCheckCbk(pdf, &abortCheck, data); // The abortCheck function will be called periodically while // pdfWritePageBitmap is running. If abortCheck returns 1, // then writePageBitmap will return immediately. pdfWritePageBitmap(...);