Metamask Mobile window.print

We want to allow our users to print pdf within MetaMask mobile browser.

Using window.print does not appear to be working in the MetaMask mobile browser.

How can we allow users to print pdf within the MetaMask mobile browser?

Thanks in advance for any suggestions/guidance.

Here is the code we are using:
"
const Print = () =>{

let printContents = document.getElementById(‘page’).innerHTML;
let originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print
document.body.innerHTML = originalContents;
}"

“ Print ”

1 Like

Hello @mick456, welcome to MetaMask community!

Keep in mind, MetaMask’s browser within the mobile app is not as fully featured as a standalone browser like Chrome or Firefox.

2 Likes

I know but I am sure that we will find a solution… let’s see what the community think :wink:

1 Like

A solution please?? a download or print button is a simple service that all browsers allow… It is surprising that it is impossible to download a document in the mobile browser MetaMask…?

1 Like

@mick456

If your code is not working properly, is there probably some kind of error in the console?
Can you provide screenshots? Thanks

1 Like

There is no error in the console…simply nothing is happening… But on desktop browser like chrome or firefox it’s working… The issue come from MetaMask Mobile Browser and despite the code we tried (JS, JQ, React) nothing is working. Ok we have at the end a screen and we want to allow user simply to download this screen as a pdf or in a click of the button open the native print dialog on their mobile. It’s like something in the code of the MetaMask mobile browser something blocked all script to download or print.

@mick456
Is this problem present on both platforms (iOS, Android) ?
Did you run the application in an emulator to have access to the console, which is likely to display any error logs?

1 Like

I tried only on IOS; The question is: is it possible to open the native IOS print dialog within the MetaMask mobile browser ? If yes can someone provide at least 1 code example?

What do you mean? I don’t understand. Thank you

I wanna see error logs output when clicking on a button that triggers the window.print event.

Test and debug your web3 site using MetaMask Mobile on any iOS or Android device with ease.

iOS

  1. Open Safari PreferencesAdvanced → enable the Show Develop menu in menu bar checkbox

  2. Open MetaMask Mobile in an iOS simulator or iOS device

  3. In the Safari menu bar → Develop[device name][app name][url - title]

When debugging on a physical device, you must enable Web Inspector in your device’s settings:
SettingsSafariAdvancedWeb Inspector

You can also refer to the MetaMask Docs for more information.

2 Likes

Hello, following your request I made the tests in the console and as I said before no error appears.

Here is the link to CodeSandbox : codesandbox io/embed/047jjpv400

If you open this link on Safari desktop, IOS Safari mobile, Chrome Desktop or Chrome mobile and you press the print button it works perfectly!

But when you open the same link in the MetaMask mobile browser and press the print button nothing happens and no error is displayed in the console.

You can open this link yourself with the MetaMask mobile browser and see the console at the bottom of the page which does not show any error but still the print button does not work: codesandbox io/embed/047jjpv400 ( Insert a dot between codesandbox and io because here we can’t post link)

Any help please ? :pensive: :sleepy:

1 Like

Please open an issue in the official MetaMask repository on github

4 Likes

This is the link to it.

2 Likes

In conclusion: MetaMask mobile browser download pdf is not possible and MetaMask mobile browser print pdf is not possible.

Finally after hours and days of work I found the solution myself with a home made code.

2 Likes

Great !
Can you briefly describe what solved the problem? I will be extremely grateful

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.