use of org.kuali.kfs.fp.document.service.DisbursementVoucherCoverSheetService in project cu-kfs by CU-CommunityApps.
the class DisbursementVoucherAction method printDisbursementVoucherCoverSheet.
/**
* Calls service to generate the disbursement voucher cover sheet as a pdf.
*/
public ActionForward printDisbursementVoucherCoverSheet(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
DisbursementVoucherForm dvForm = (DisbursementVoucherForm) form;
// get directory of template
String directory = SpringContext.getBean(ConfigurationService.class).getPropertyValueAsString(KFSConstants.EXTERNALIZABLE_HELP_URL_KEY);
DisbursementVoucherDocument document = (DisbursementVoucherDocument) SpringContext.getBean(DocumentService.class).getByDocumentHeaderId(request.getParameter(KFSPropertyConstants.DOCUMENT_NUMBER));
// set workflow document back into form to prevent document authorizer "invalid (null)
// document.documentHeader.workflowDocument" since we are bypassing form submit and just linking directly to the action
dvForm.getDocument().getDocumentHeader().setWorkflowDocument(document.getDocumentHeader().getWorkflowDocument());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DisbursementVoucherCoverSheetService coverSheetService = SpringContext.getBean(DisbursementVoucherCoverSheetService.class);
coverSheetService.generateDisbursementVoucherCoverSheet(document, baos);
String fileName = document.getDocumentNumber() + "_cover_sheet.pdf";
WebUtils.saveMimeOutputStreamAsFile(response, "application/pdf", baos, fileName);
return (null);
}
Aggregations