Printing a wix web page

Hi, I want to add a button which allows the user to print the page (essentially simulate the CTRL+P functionality)

Any suggestions?

2 Likes

Use the javascript function window.print.

I get this error ReferenceError: window is not defined

Can you paste in your code.

The window.printf() doesn’t work due to the structure of a WixCode website. The code is sandboxed and the use of HTML and Javascript is strictly limited.

Any other option?

Hi Admin, is there a way to connect a PDF api?

Hi mustafa. Are you any good in js? You can use a html element, pass data to it, make it show a button, and in it add something like jspdf. With that you can make a pdf in a html page, so in the html element it should funtion too.

Hey Mustafa, did you end up finding a solution for this?

Hi Everyone

Any one found way? otherwise help us vote for this feature as it is very useful.
Link here .

Hi
any solution ?

I understand that there is now no possibility of building a Wicks print button. The only option is by pressing ctrl p. I would be happy to know if anyone knows how I set a button to click on it and call the keyboard as if I clicked ctrl p? Thanks!

Any update so far?

Hi Gentlemen

it is possible to print webpage through html component with combination of window print and html postmessage event.

Good thing is you can design/ customize the outcome as you like.

DA

Do you want to print from html component at also send a message back to Wix Code using the postMessage code?

Then use the code to print from iframe and then after or before that

window.parent.postMessage("Page has been printed", "*");

And that message will be sent back to the code part of your page.

@darken-angel Yes it’s possible for wix code to print the wix page

I have used in this example
Basically you need code in three region this only work for premium site cause we need a custom code (Under tracking and analytic section in wix dashboard)

I have coded in a way that the wix code trigger > html component code then > it will trigger the custom code
But you need a premium site to do this
You can also check this blog to create a customization PDF

For the meanwhile do the following:
Click “Add”>“More”>click on “HTML iframe”> and paste this code.

Print

This code will help to print a blank page, just the html window but not all the background and content found on the site.

You can’t trick the HtmlComponent by using parent, window, top, etc. Same goes with the Javascript evaluate() function. It is sandboxed and does not allow access to the DOM.

Like @salman-hammed said, you can only do this by entering custom JavaScript in the Tracking and Analytics section of a custom site, but it’s very possible. That’s the only set of custom code which has the scope of the webpage itself.

@ben Do you have a premium site to test it on? You can only put code into the tracking and analytics section of a premium site witha domain