skip to Main Content

My problem is that the inappbrowser from cordova doesn’t handle pdfs. However, in our reactjs app, we use an Iframe to display a pdf (It has it own header and branding so it’s not opened as a standalone pdf):

return <Iframe className="h-full " src={uri} style={style} />;

where:

export function Iframe({ ...props }: IframeProps) {
  return (
    <iframe
      {...props}
      width="100%"
      height="1080"
      title={props.src}
      allowFullScreen
    ></iframe>
  );
}

So, I wanted to do something like, if it’s being opened in cordova, do this instead:

<a href={Pdf} without rel="noopener noreferrer" target="_blank">

Any other suggestions would be welcome.

2

Answers


  1. You can render PDFs with a couple of different JS libraries

    https://viewerjs.org/

    https://mozilla.github.io/pdf.js/

    Login or Signup to reply.
  2. You can render different elements according to your platform which you can check with https://cordova.apache.org/docs/en/3.3.0/cordova/device/device.platform.html. If you’re using ionic it has too: https://ionicframework.com/docs/angular/platform

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search