}
public ActionForward printCreditNote(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException {
final CreditNote creditNote = getCreditNoteFromViewState();
try {
final CreditNoteDocument original = new CreditNoteDocument(creditNote, getMessageResourceProvider(request), true);
final CreditNoteDocument duplicate = new CreditNoteDocument(creditNote, getMessageResourceProvider(request), false);
final byte[] data = ReportsUtils.exportMultipleToPdfAsByteArray(original, duplicate);
CreditNoteGeneratedDocument.store(creditNote, original.getReportFileName() + ".pdf", data);
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("creditNoteId", creditNote.getExternalId());
return showCreditNote(mapping, form, request, response);
}
}