Render done activation improved

Included promise when done rendering, error when corrupted pdf is
recived. Function defined in function arg. (made link to code italic)