Cairo.onSave set the onSave callback which allows R code to be run when Cairo finalizes a page (either due to a new page being created or by the device being closed). The callback expects function(device, page) where device will be the device number and page is the currently finished page number (starting at 1).
Cairo initializes a new graphics device that uses the cairo graphics library for rendering. The current implementation produces high-quality PNG, JPEG, TIFF bitmap files, high resolution PDF files with embedded fonts, SVG graphics and PostScript files. It also provides X11 and Windows interactive graphics devices. Unlike other devices it supports all graphics features including alpha blending, anti-aliasing etc.
Cairo.serial returns an integer that is increased with every plotting operation on the device. This allows user code to determine whether any new content has been added to the device since it was last checked.