My guess is that the problem is in the stream being passed to HTML2PDF. The first thing that comes to mind is to trace the agent to confirm that it is seeing your custom rules/rulesets. If it is, I'd look into the stream that's being passed into the HTML2PDF code. Does it include your styles? I'd compare that to running it interactively. Do you see your styles in the stream there?