0

I'm using the Web Share API to share pdf files generated with jspdf. It works as expected for browsers such as Chrome and Edge (Desktop and Mobile) but I can't get it working on Opera for Android. When calling the navigator.share() method, the share options hub is being displayed, but there seems to be no file to be shared. On WhatsApp I get an error saying that I can't send an empty message and on other apps it just shares the title, but I'm not getting any console error.

Here's my code:

var pdf = new File([doc.output('blob')], doc_name + ".pdf", { type: "application/pdf" });    //Blob generated with jspdf
var filesToShare = [pdf];

if (navigator.canShare && navigator.canShare({ files: filesToShare })) {
    try {
        if (filesToShare != null)
            navigator.share({ title: doc_name + ".pdf", files: filesToShare });
    } catch (error) {
        console.error(error.message);
    }
}

I've tried sharing just text and it is working fine, I'm only facing this problem when sharing files.

As per CanIUse and MDN the feature is supported on Opera Android since v54, and I'm using v73 so I must be missing something.

ariverof
  • 27
  • 1
  • 7
  • It seems to be working just fine on Opera for iOS. Will raise a ticket on Opera forums and keep the question updated – ariverof Feb 22 '23 at 17:55

0 Answers0