3

I am using a base64 to display my PDF in a new window in the browser:

let pdfCall$ = this._sdkService.getSDK().api.invPdf.get({ query: { invId: inv.invId }});
let pdfDisposable = pdfCall$.subscribe((invPdf: InvPdf) => {
    window.open('data:application/pdf;base64,' + invPdf.pdfString);
}, 

InvoicePDF class:

export class InvoicePdf {

    public pdfString: string;

    constructor(pdfString: string) {
        this.pdfString = pdfString;
    }
}

This is working for all browsers needed except IE11 and Edge.

We are using Angular2 so I am wondering what's the best library to make this work on all browser, I have take a look at PDF.JS and ViewerJS, but there is not enough documentation to make it work on Angular2. Do I need an external library or can this be done natively, maybe use a decorder and embedded to the HTML?

The response needs to be in a key/value pair, JSON format.

Guillermo Sánchez
  • 143
  • 1
  • 3
  • 15
  • 1
    I wrote about this few days ago, check it out: http://stackoverflow.com/questions/40300252/angular2-displaying-pdf/40300966#40300966 – Stefan Svrkota Oct 31 '16 at 21:50
  • I can't access to the response type, is there any other way to do this completely in the front end? Maybe using a decoder for base64? Thank you – Guillermo Sánchez Oct 31 '16 at 23:05

0 Answers0