25
25
import java .time .format .DateTimeFormatter ;
26
26
import java .time .temporal .Temporal ;
27
27
import java .util .ArrayList ;
28
+ import java .util .Calendar ;
28
29
import java .util .List ;
29
30
import java .util .Locale ;
30
31
import java .util .Optional ;
38
39
import org .apache .pdfbox .io .MemoryUsageSetting ;
39
40
import org .apache .pdfbox .multipdf .PDFMergerUtility ;
40
41
import org .apache .pdfbox .pdmodel .PDDocument ;
42
+ import org .apache .pdfbox .pdmodel .PDDocumentInformation ;
41
43
import org .apache .pdfbox .pdmodel .PDPage ;
42
44
import org .apache .pdfbox .pdmodel .PDPageContentStream ;
43
45
import org .apache .pdfbox .pdmodel .common .PDRectangle ;
@@ -1389,18 +1391,30 @@ private OnDemandFile downlaodMultipleDossierPdf(final List<Candidature> liste, f
1389
1391
*/
1390
1392
public OnDemandFile downloadDossier (final Candidature candidature , final List <SimpleTablePresentation > listePresentation , final List <SimpleTablePresentation > listeDatePresentation ,
1391
1393
final List <PjPresentation > listePj , final List <FormulairePresentation > listeForm , final Boolean addPj ) {
1392
- String fileName = applicationContext .getMessage ("candidature.download.file" , new Object [] {candidature .getCandidat ().getCompteMinima ().getNumDossierOpiCptMin (),
1393
- candidature .getCandidat ().getNomPatCandidat (), candidature .getCandidat ().getPrenomCandidat (), candidature .getFormation ().getCodForm ()}, UI .getCurrent ().getLocale ());
1394
+
1395
+ /*Variables utiles*/
1396
+ String numDossier = candidature .getCandidat ().getCompteMinima ().getNumDossierOpiCptMin ();
1397
+ String nom = candidature .getCandidat ().getNomPatCandidat ();
1398
+ String prenom = candidature .getCandidat ().getPrenomCandidat ();
1399
+ String codForm = candidature .getFormation ().getCodForm ();
1400
+ String libForm = candidature .getFormation ().getLibForm ();
1401
+
1402
+ /*Nom du fichier*/
1403
+ String fileName = applicationContext .getMessage ("candidature.download.file" , new Object [] {numDossier , nom , prenom , codForm }, UI .getCurrent ().getLocale ());
1394
1404
1395
1405
// Les parametres des PJ
1396
1406
Boolean enableAddApogeePJDossier = parametreController .getIsAddApogeePJDossier ();
1397
1407
1398
1408
// Font
1399
1409
PDFont font = PDType1Font .HELVETICA_BOLD ;
1410
+
1400
1411
// le dossier outStream
1401
1412
ByteArrayInputStream bisDossier = null ;
1413
+
1402
1414
// liste des InputStream à fermer
1403
1415
List <InputStream > listeInputStreamToClose = new ArrayList <>();
1416
+
1417
+ /*Génération du dossier principal*/
1404
1418
try {
1405
1419
bisDossier = generateDossier (candidature , listePresentation , listeDatePresentation , listePj , listeForm );
1406
1420
if (bisDossier == null ) {
@@ -1415,10 +1429,27 @@ public OnDemandFile downloadDossier(final Candidature candidature, final List<Si
1415
1429
ByteArrayInOutStream out = new ByteArrayInOutStream ();
1416
1430
InputStream is = null ;
1417
1431
try {
1432
+ /*Merger*/
1418
1433
PDFMergerUtility ut = new PDFMergerUtility ();
1434
+
1435
+ /*Propriétés du document*/
1436
+ PDDocumentInformation info = new PDDocumentInformation ();
1437
+ info .setTitle (numDossier + "_" + nom + "_" + prenom + "_" + codForm );
1438
+ info .setAuthor (ConstanteUtils .APP_NAME );
1439
+ info .setSubject (nom + " " + prenom + " (" + numDossier + ") / " + libForm + " (" + codForm + ")" );
1440
+ Calendar calendar = Calendar .getInstance (UI .getCurrent ().getLocale ());
1441
+ info .setCreationDate (calendar );
1442
+ info .setModificationDate (calendar );
1443
+ ut .setDestinationDocumentInformation (info );
1444
+
1445
+ /*Ajout du dossier*/
1419
1446
ut .addSource (bisDossier );
1447
+
1448
+ /*Gestion des erreurs de pj*/
1420
1449
Boolean errorAddPj = false ;
1421
1450
List <String > fileNameError = new ArrayList <>();
1451
+
1452
+ /*Calcul si besoin d'ajouter les pj*/
1422
1453
Integer nbFilePJ = 0 ;
1423
1454
for (PjPresentation pj : listePj ) {
1424
1455
if (pj .getFilePj () != null ) {
0 commit comments