2017-08-18 22 views
18

मैं कोणीय 2 का उपयोग कर रहा हूं। मुझे बैकएंड एपीआई से बीएलओबी के रूप में पीडीएफ प्रतिक्रिया मिल रही है। पीडीएफ आईफ्रेम में ठीक दिख रहा है लेकिन यह शीर्षक को 'अज्ञात' के रूप में दिखा रहा है। क्या कोई मार्गदर्शन कर सकता है?आईफ़्रेम में पीडीएफ शीर्षक को 'बेनामी' के रूप में दिखा रहा है

एचटीएमएल कोड:

<iframe id="showPDFIframe" allowtransparency="false" title="TestPDF" width="100%" height="800" [attr.src]="dataLocalUrl" type="application/pdf"></iframe> 

pdf.component.ts

pdfDownload: any; 
    protected dataLocalUrl: SafeResourceUrl; 

    ngOnInit() { 
    this.requestOptions = this.createRequestOptions(); 
    this.requestOptions.responseType = ResponseContentType.Blob; 
    this._pdfModelService.showPDF(this.requestOptions) 
    .subscribe((res) => { 
     this.pdfDownload = res; 
     this.dataLocalUrl = this.domSanitizer.bypassSecurityTrustResourceUrl(window.URL.createObjectURL(res)); 
    }, err => { 
     console.log(err); 
    }) 
    } 

pdfModelService.ts

showPDF(options?: RequestOptions): any { 
    return this._http.get(this.endpoints.showPDF.uri, options) 
     .map((res) => { 
     return new Blob([res], { type: 'application/pdf' }) 
     }); 
    } 

छवि 'बेनामी' नीचे देखें enter image description here

दिखा रहा है 10

नोट: बैकएंड एपीआई बाइट्स देता है जिसे हमने बीएलओबी में डाला था।

+1

आप अपनी प्रतिक्रिया हेडर दिखाने सकते हैं? –

उत्तर

4

आप विकल्पों में शीर्षक प्रदान करने की कोशिश की है:

showPDF(options?: RequestOptions): any { 
return this._http.get(this.endpoints.showPDF.uri, options) 
    .map((res) => { 
    return new Blob([res], { type: 'application/pdf', title: 'testpdf' }) 
    }); 
} 
+0

बीएलओबी की कोई संपत्ति 'शीर्षक' नहीं है –

2

हालांकि मैं क्यों निर्दिष्ट शीर्षक क्षेत्र "TestPDF" कोड में पृष्ठ पर दिखाई दे रहा है कुछ नहीं कर रहा हूँ, "(अनाम)" मूल्य जो प्रदर्शित हो रहा है वह केवल पीडीएफ फ़ाइल से मेटा डेटा खींच सकता है। शीर्षक शीर्षक सेट करने के लिए पीडीएफ दस्तावेज़ गुणों में शीर्षक फ़ील्ड को जांचना एक संभावित समाधान होगा। एडोब एक्रोबैट में, फ़ाइल मेनू से शीर्षक फ़ील्ड को चेक/अपडेट करने के लिए गुण> विवरण चुनें। W3.org से

संदर्भ लेख: https://www.w3.org/TR/WCAG20-TECHS/PDF18.html

संबंधित मुद्दे