Bonjour,

Je viens de récupérer un code où l'on ajoute une annotation contenant un fichier son, un label, et l'image de l'annotation (l'épingle).
Le but de ma modification est "juste" d'ajouter une seconde annotation, mais la seconde annotation est soit déformée (l'épingle est diforme), soit la 1ère annotation n'est pas présente.

Voici le code de base :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
PdfReader reader = null;
PdfStamper stamp = null;
PdfWriter writer = null;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
reader = new PdfReader(bosTemplate.toByteArray());  
stamp = new PdfStamper(reader,bos);
 
writer = stamp.getWriter();
 
PdfAction ac = PdfAction.gotoLocalPage(1, new PdfDestination(PdfDestination.XYZ, 0, 10000, 0f), writer);
writer.setOpenAction(ac);
writer.setEncryption(PdfWriter.STRENGTH128BITS,  "" , "", PdfWriter.AllowCopy | PdfWriter.AllowPrinting);
 
try{
/** intégration du son **/
    ByteArrayOutputStream bosSon = new ByteArrayOutputStream();
    Long id = client.getId();
    bosSon = (ByteArrayOutputStream)serviceDocument.getSonClient("CLIENT",id);
    InputStream bisSon = new ByteArrayInputStream(bosSon.toByteArray());
    final int lengthSon;
    lengthSon = bisSon.available();
    byte[] bytearraySon = new byte[lengthSon];
 
    bisSon.read(bytearraySon);
    bisSon.reset();
    bisSon.close();
 
    PdfFileSpecification fsSon = PdfFileSpecification.fileEmbedded(writer,null, "son.wav", bytearraySon);
    stamp.addAnnotation(PdfAnnotation.createFileAttachment(writer,new Rectangle(360f, 260f, 380f, 280f), "fichier son", fsSon),2);
 
}catch(Exception e){
    cat.error("Son Client Exception bosSon : " + e.getMessage());
}
 
stamp.close();
 
return bos;
Merci d'avance.