liskior
liskior

Reputation: 67

how to show local pdf file in browser(not mobile) ionic

I can't find plugin that works for browser pdf. Maybe can I do it with HTML5 or what? I've tried this, but seems it works only in mobile device:

@Component({
    selector: 'page-home',
    templateUrl: 'home.html'
}) 
export class HomePage {
    page2 = Page2;
    ionViewDidLoad() {
    }
    pdfUrl : string;
    pins = PINS;
    str : string; 
    constructor(public navCtrl: NavController, private fileOpener: FileOpener) { 
    }
    onSelect(pin: Pin): void {
        this.fileOpener.open('assets/helloworld.pdf', 'application/pdf')
        .then(() => console.log('File is opened'))
        .catch(e => console.log('Error openening file', e));
    }
};

Upvotes: 0

Views: 348

Answers (1)

Missak Boyajian
Missak Boyajian

Reputation: 2245

Try Putting it in an Iframe

    <iframe [src]='.../test.pdf' width="85%" height="100%">

    </iframe>

Upvotes: 1

Related Questions