}
public ActionForward printReceipt(ActionMapping mapping, ActionForm actionForm, HttpServletRequest request,
HttpServletResponse response) throws IOException {
final Receipt receipt = getRenderedObject("receipt");
try {
final ReceiptDocument original = new ReceiptDocument(receipt, getMessageResourceProvider(request), true);
final ReceiptDocument duplicate = new ReceiptDocument(receipt, getMessageResourceProvider(request), false);
final byte[] data = ReportsUtils.exportMultipleToPdfAsByteArray(original, duplicate);
ReceiptGeneratedDocument.store(receipt, original.getReportFileName() + ".pdf", data);
RegisterReceiptPrint.run(receipt, getUserView(request).getPerson());
response.setContentLength(data.length);
response.setContentType("application/pdf");
response.addHeader("Content-Disposition", String.format("attachment; filename=%s.pdf", original.getReportFileName()));
response.getOutputStream().write(data);
return null;
} catch (DomainException e) {
addActionMessage(request, e.getKey(), e.getArgs());
request.setAttribute("personId", receipt.getPerson().getExternalId());
request.setAttribute("receiptID", receipt.getExternalId());
return prepareShowReceipt(mapping, actionForm, request, response);
}
}