Jump to content

Print the content of URLFrame


gm3h
 Share

Recommended Posts

Can somebody tell me how to print the content of TUniURLFrame ?

I've used window.print() in the onClick() event of ClientEvents.ExtEvents, but it print the whole webpage of course.

I've tried Form1.urlFrame1.print(), also nothing happen.

 

Also, if possible, is there any way I can just print directly to printer without the Print Dialog ??

Link to comment
Share on other sites

I found this code on the netz maybe it will work:

 

<script type="text/javascript">
function zPrint(oTgt)
{
oTgt.focus();
oTgt.print();
}
</script>

.
.
.
<body>
<iframe name="myFrame" id="myFrame" width="600" height="400" src="about:mozilla></iframe>
<input type="button" value="Print IFRAME" onclick="zPrint(myFrame);" />
</body>

 

URLFrames are iframes, so maybe you can modify the idea used here somehow. I am no expert in javascript, so I can't really say if it will work or not.

Link to comment
Share on other sites

I found this code on the netz maybe it will work:

 

<script type="text/javascript">
function zPrint(oTgt)
{
oTgt.focus();
oTgt.print();
}
</script>

.
.
.
<body>
<iframe name="myFrame" id="myFrame" width="600" height="400" src="about:mozilla></iframe>
<input type="button" value="Print IFRAME" onclick="zPrint(myFrame);" />
</body>

 

URLFrames are iframes, so maybe you can modify the idea used here somehow. I am no expert in javascript, so I can't really say if it will work or not.

 

thank you for your reply. But, I don't know what the id of URLFrame after uniGUI compiled the code into javascript.

Link to comment
Share on other sites

Id of UrlFrame is defined as:

 

"iframe_"+ComponentName

 

for exampe:

 

"iframe_UniURLFrame1"

 

Thank you Farshad and Anders.. Now it works.

Here's what I do.

 

1. in the Form1.Script i put:

function zPrint(oTgt)
{
oTgt.focus();
oTgt.print();
}

 

2. in the button.ExtEvents.OnClick() i put:

zPrint(iframe_UniURLFrame1); /* without the quotation mark */

 

Now, how about print dialog? I don't want to show the print dialog, just directly print to the default printer.

Link to comment
Share on other sites

  • 6 months later...

Working now.

 

 

zPrint function in the Form.Script.

 

 

And this in the extevents of the button:

 

function OnClick(sender, e)

{

var frm = document.getElementById("iframe_UniURL1_O20");

 

if (frm) {

zPrint(frm.contentWindow);

}

}

 

 

Why is the "_O20" added to the end of the iframe id?

 

Will this change after some page reloadings?

 

Bye!

 

Bruno

Link to comment
Share on other sites

  • Administrators

Working now.

 

 

zPrint function in the Form.Script.

 

 

And this in the extevents of the button:

 

function OnClick(sender, e)

{

var frm = document.getElementById("iframe_UniURL1_O20");

 

if (frm) {

zPrint(frm.contentWindow);

}

}

 

 

 

 

Why is the "_O20" added to the end of the iframe id?

 

Will this change after some page reloadings?

 

Bye!

 

Bruno

 

 

In 0.89 use can use:

 

var frm = MainForm.UniURLFrame1.iframe;

Link to comment
Share on other sites

The code was not working in Firefox and Chrome.

 

I did some changes and now it's working that browsers too.

 

 

 

In the Form.Script:

 

function zPrint(oTgt){

oTgt.focus();

oTgt.print();

}

 

function printIframe(id)

{

var iframe = id;

var ifWin = iframe.contentWindow || iframe; // the change

zPrint(ifWin);

return false;

}

 

 

 

In the button.ExtEvents.OnClick:

 

function OnClick(sender, e)

{

var frm = UniFormShowLink.UniURL1.iframe;

 

if (frm) {

printIframe(frm);

}

}

 

 

Bye!

 

 

Bruno

Link to comment
Share on other sites

  • 4 years later...

In the Form.Script:

function zPrint(oTgt){
oTgt.focus();
oTgt.print();
}

function printIframe(id)
{
var iframe = id;
var ifWin = iframe.contentWindow || iframe; // the change
zPrint(ifWin);
return false;
}



In the button.ExtEvents.OnClick:

function OnClick(sender, e)
{
var frm = UniFormShowLink.UniURL1.iframe;

if (frm) {
printIframe(frm);
}
}

 

Bu Kodu Çalıştıramadım.

UniURLFrame1 içerisindeki HTML Kodunu Print etmek istiyorum

Yardımcı olursanız sevinirim.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...