Skip to main content

Hi, I have a k2 smartform and I would like to provide the print functionality to print the form. Please suggest some inputs. Note: I don't want to use browser print option.

 

Regards,

Ram

Dear,

 

1- Add Button and give it Tooltip "Action Button".

2- Add Datalable and set an expression to it:

 

"<script type="text/javascript">$(document).ready(function() { $("(title='Action Button']").click(function() {window.print()});});</script>"

 

** when you click on the button it will show the print pop up.


Hi Mustafa, Thank you for your reply, I know it is very simple to implement, and I followed the steps you explained but I dont where does it get fail.

Attached are the screenshots of Button, Data Lebal, Data Lebal Expression and finally Prinit button on form that is unresponsive. Could you please tell me where I am getting wrong.

 

Regards,

Ram


17045i680349EA35ECF7C9.jpg
12502i15C0A2F0110EBBA4.jpg
13406i00BFF3BC0A7DB838.jpg
17173iF0009183560BDFBE.jpg

Dear,

 

you're missing the opening < at the beginning of the expression and please note that you're wrapping it with double quotes "" , remove the wrapping quotes.

 

it should look exactly like this :

 

<script type="text/javascript">$(document).ready(function() { $("$title='Action Button']").click(function() {window.print()});});</script>


Thank you Mustafa, it worked like charm for me. Thnx again


Not Working for me :(

 

we need any javascript referance please guide me.


Hi,

 

What version of K2 are you using? 

Can you please show me how you implemented it just to make sure you're not missing anything?

 

 


If I understand you correctly, you want to have a print button and that will give the print functionality, then follow below steps-

 

1. Create a button on Form and in button properties do following-

     17166i15F8FBD16C455F6B.png

 

Hope this helps. Let me know if you face any issues.


Below are the snapshpot of Data label expression.

 

11375iB2811CDB684FED04.png

 

 


we are using K2 Installation Package 4.6.11 (4.12060.1735.1)  this version..

 

still not working :(

 

Thanks for rply.


Please find  the below snapshot of form.

 

 

13965i9F439AAAD43894A8.png


Hi,

 

Please check "Literal" property on the data label 


yipeeeeeeeeeeeeeeeeee!!!

 

I resolved the  thanks to all .

 

actually the problem was with one data lable literal property.

 


 11882iCB6A2494C74F66F2.png

literal checkbox must be checked if we use javascript or html tag :)

 

 

Regards 

Karan Bajaj


 

 

Thanks  Mustafa :)


I tried this and it works really well.  Thank you.


Hi ,

 

How do I avoid printing instructions in the form ? I have instructions added as labels but when I want to print the form , then I would like to avoid printing those labels.

 

How to do this ?

 

Thanks and Regards,

Satya


I have used this print button on my k2 form and it works fine in a browser but is it possible to use this in the k2 app for ipad? at present if you hit the print button when using a form in the app nothing happens.


what if I want to set the frame's width to 100% and then print the page?


This worked great for printing everything on the form.  I added the print button and data label to the view - is there any way to just print the view?  I'm using a list view to select the detail on the item view.


Thanks this works 100%.

 

Now I want to hide all the buttons on the form being printed so that the buttons don't show on the printed pdf file, please help.


Hi,


 


I am aware of one way to do this.


 


you will need to hide any view or controls that you don't want to print before triggering the print function


You can configure the print button to hid the view as below:


 


16093i55EF1A62ADE57D20.png


Add two transfer actions as shown above to do the following:


 


1- Clear data label


2- transfer the following script to the data label


 


<script>window.print();</script>

HTH


Thanks a lot Mustafa. This is awesome.

Hi 
I have tried exactly as you told but when button is clicked nothing happens (its like a button that is not configured ).Please helpm to resolve this issue

@Mustafa wrote:

Dear,

 

you're missing the opening < at the beginning of the expression and please note that you're wrapping it with double quotes "" , remove the wrapping quotes.

 

it should look exactly like this :

 

<script type="text/javascript">$(document).ready(function() { $("{title='Action Button']").click(function() {window.print()});});</script>




15947iB16B6E6B448B63B5.png


Hi   @DeepakChacko


 


Can you make sure you have the data label property 'literal' checked and if you are using k2 Five, make sure to uncheck 'prevent XSS' property


 


HTH


I am trying to print but the Checkboxes are not being displayed. 


Reply