Bonjour
je chercher de l'aide sur un petit project que j'ai commencer un site pour lire les pdf et bien les classer sens utiliser un backend
j'ai fait le site en angular et un serveur node pour l'embarquer :
j'ai problème pour l'ouverture de pdf avec les navigateur safari sur les Mac comme sur les mobiles le lien deviens nulle
alors que sa marche sur tout les autres navigateurs
j'ai utiliser cette fonction qui marche partout sauf safari
tout les codes
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 downloadOpenPdf(downloadOrOpen: string): void { this.httpCall.getPdf(this.fileName, this.category).subscribe( (data: any) => { const newBlob = new Blob([data], { type: 'application/pdf' }); const downloadURL = window.URL.createObjectURL(data); const link = document.createElement('a'); link.href = downloadURL; if(downloadOrOpen == 'open') { link.target = this.fileName + '.pdf'; } else { link.download = this.fileName + '.pdf'; } link.click(); setTimeout(() => { // For Firefox it is necessary to delay revoking the ObjectURL window.URL.revokeObjectURL(data); link.remove(); }, 100); }, (err: any) => console.log(err) ); } }
pouvez m'aider
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
39
40
41
42
43
44
45
46
47
48
49 import { Component, Input, OnInit } from '@angular/core'; import { HttpCallService } from '../services/http-call.service'; @Component({ selector: 'app-book-tile', templateUrl: './book-tile.component.html', styleUrls: ['./book-tile.component.scss'] }) export class BookTileComponent implements OnInit { public fileName = ''; public category = ''; @Input() set filename(filename: string) { this.fileName = filename; } @Input() set categoryname(categoryName: string) { this.category = categoryName; } constructor(private httpCall: HttpCallService) { } ngOnInit(): void { } downloadOpenPdf(downloadOrOpen: string): void { this.httpCall.getPdf(this.fileName, this.category).subscribe( (data: any) => { const newBlob = new Blob([data], { type: 'application/pdf' }); const downloadURL = window.URL.createObjectURL(data); const link = document.createElement('a'); link.href = downloadURL; if(downloadOrOpen == 'open') { link.target = this.fileName + '.pdf'; } else { link.download = this.fileName + '.pdf'; } link.click(); setTimeout(() => { // For Firefox it is necessary to delay revoking the ObjectURL window.URL.revokeObjectURL(data); link.remove(); }, 100); }, (err: any) => console.log(err) ); } }
Partager