我有一个被编码为base64字符串的pdf。我需要使用此字符串并在我的angular 2仪表板上显示pdf。
import {Component} from '@angular/core';
import { NgUploaderOptions } from 'ngx-uploader';
import { PdfReaderService } from './pdfReader.service';
@Component({
templateUrl: './pdfReader.html'
})
export class PdfReader {
pdfSrc: string = 'file:///Users/appgram/Desktop/git/InvoiceSimple.pdf';
public pdfData;
constructor(private _objService: PdfReaderService) {
this._objService
.getPdf()
.subscribe(res => {
this.pdfData = new Buffer(res.file.buffer.data,
'binary').toString('base64');
}, error => {
});
}
}