Changing the default output file name jasper_report.PDF when using Jasper report Connector
Hello,
I found how it's possible to rename a jasper_report.pdf file.
Indeed, you have to modify the Document Filename.
In the same step I created my Jasper PDF, I added an output Operation on my pdf document with the code :
import org.bonitasoft.engine.bpm.document.Document;
import org.bonitasoft.engine.bpm.document.DocumentValue;//New filename is set here
String **collaboratorName **= assignmentChangeBDM.getCollaboratorName().trim().replace(" ", "");
String **filename **= "MouvementPersonnel" + collaboratorName + ".pdf";//We're looking for the previously created document
long docId = apiAccessor.getProcessAPI().getLastDocument(processInstanceId, "pdf").getId();Document doc = apiAccessor.getProcessAPI().getDocument(docId);
DocumentValue docValue = new DocumentValue(apiAccessor.getProcessAPI().getDocumentContent(doc.getContentStorageId()), doc.getContentMimeType(), filename);
return docValue;
Hi. You can change the document name and path in the Documents tab of your process.
Comments
Where do you want to save the document?
I think the only way to do what you want at the moment is to have a spare document in your process (tempDocHolder) (or create one using java/groovy) and copy the document saved from the jasper report connector to it and back, renaming it along the way.
You should open the jasper document as a byteArray and write it to the new documentValue giving it the new name...
See here for a possible starting point.
regards Seán