Hi Micheal,
Can you be more specific about the error message.
Also in your code the below method call should be called before viewr.processHttprequest()
viewer.setPrintMode(CrPrintMode.PDF);
Also for better logging information, you can enable log4j in your application.
Thanks,
prithvi