Reputation: 545
import { Plugins } from '@capacitor/core';
const { Browser } = Plugins;
Browser.open({ url: 'http://www.africau.edu/images/default/sample.pdf', windowName:'_self' });
When the url is specified as a link to a website, it works fine but doesnt when specified a PDF. Could someone please suggest if any changes required ? Do i need to specify the rel ? If yes how ? There is no such key to be passed in open call. Response received is 'NO enabled plugin supports this MIME type'.
Upvotes: 5
Views: 14951
Reputation: 2533
The Browser
plugin from Capacitor should work fine for this. Try without specifying windowName
.
// Capacitor v2
import { Plugins } from '@capacitor/core';
const { Browser } = Plugins;
Browser.open({ url: 'http://www.africau.edu/images/default/sample.pdf'});
// or for Capacitor v3
import { Browser } from '@capacitor/browser';
Browser.open({ url: 'http://www.africau.edu/images/default/sample.pdf'});
Upvotes: 5
Reputation: 729
InAppBrowser will not pdf files. you will have to use it in some other way,
first you can simply add a href this will open user default browser.. like for android it will open this link in android and for ios it will use safari.
<a href="http://www.africau.edu/images/default/sample.pdf">open pdf</a>
Second way is to use a plugin for document viewer .. i have added its link below
constructor(private document: DocumentViewer) { }
const options: DocumentViewerOptions = {
title: 'My PDF'
}
this.document.viewDocument('http://www.africau.edu/images/default/sample.pdf', 'application/pdf', options)
https://ionicframework.com/docs/native/document-viewer
Upvotes: -2