1 pièce(s) jointe(s)
Affichage d'un pdf dans google chrome
Bonsoir à tous.
Je suis en train de vouloir afficher un pdf dans google chrome avec spring boot et angular. mais chaque fois cette erreur là:
Citation:
echec de chargement du fichier PDF:
Pièce jointe 608244
Je voudrais avoir des pistes pour pouvoir corriger cette erreur.
voici le code de mon front-end:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| impriRecu() {
const httpOptions = {
responseType: 'arraybuffer' as 'json',
};
return this.httpClient.get<any>('http://localhost:8080/adherants/report',httpOptions);
}
imprimerRecu(){
this.impriRecu().subscribe((response) => {
const file = new Blob([response], { type: 'application/pdf' });
const fileURL = URL.createObjectURL(file);
console.log(fileURL);
window.open(fileURL,'_blank');
}); |
voici le code de mon back-end:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| @GetMapping("adherants/report")
public String generateReport() throws FileNotFoundException, JRException
{
return service.generateReport();
}
public String generateReport() throws FileNotFoundException, JRException
{
String path="E:\\report";
List<Adherant> adherants = repository.findAll();
File file= ResourceUtils.getFile("classpath:recu.jrxml");
JasperReport jasperReport= JasperCompileManager.compileReport(file.getAbsolutePath());
JRBeanCollectionDataSource dataSource=new JRBeanCollectionDataSource(adherants);
Map<String,Object> parameters=new HashMap<>();
parameters.put("Created","My self");
JasperPrint print = JasperFillManager.fillReport(jasperReport,parameters,dataSource);
JasperExportManager.exportReportToPdfFile(print,path+"\\recu.pdf");
return "edition reussie";
} |
le fichier pdf est bien généré dans l'emplacement indiqué.
Merci d'avance