Alessandro Posted February 26, 2016 Posted February 26, 2016 Good Morning! I wonder how do (send to) print the contents of a UniHTMLFrame. I can export the contents of UniHTMLFrame to a PDF? How? Can someone help me? Grateful! Quote
fcarvalho4 Posted February 26, 2016 Posted February 26, 2016 See the demo FasReport (..\Demos\Desktop\FastReport) 1 Quote
Alessandro Posted February 26, 2016 Author Posted February 26, 2016 I have a procedure, and I create a run-time report using HTML and tags. When finish, I send into a uniHTMLFrame. I want print the result of this frame, just that. I know, can save HTML, but I want to print, and mainly export to PDF this content. Quote
Oliver Morsch Posted February 26, 2016 Posted February 26, 2016 Converting HTML to PDF: http://wkhtmltopdf.org/ 1 Quote
zilav Posted February 27, 2016 Posted February 27, 2016 Generate HTML code and write it into a temporary file inside ServerModule.LocalCache folder so UniGui will clear it out when session closes. Make sure to generate unique name if user are going to print several times during session. Then show user a link to the file with "target=_blank" parameter so it would open in a new browser tab. After that user can print html page himself, or you can insert javascript code inside generated html to call printing dialog automatically. 1 Quote
Hayri ASLAN Posted February 27, 2016 Posted February 27, 2016 Add this to mainform.Script function PrintMe(DivID) { var disp_setting="toolbar=yes,location=no,"; disp_setting+="directories=yes,menubar=yes,"; disp_setting+="scrollbars=yes,width=650, height=600, left=100, top=25"; var content_vlue = document.getElementById(DivID).innerHTML; var docprint=window.open("","",disp_setting); docprint.document.open(); docprint.document.write('<!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Strict/EN"'); docprint.document.write('"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'); docprint.document.write('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">'); docprint.document.write('<head><title>My Title</title>'); docprint.document.write('<style type="text/css">body{ margin:0px;'); docprint.document.write('font-family:verdana,Arial;color:#000;'); docprint.document.write('font-family:Verdana, Geneva, sans-serif; font-size:12px;}'); docprint.document.write('a{color:#000;text-decoration:none;} </style>'); docprint.document.write('</head><body onLoad="self.print()"><center>'); docprint.document.write(content_vlue); docprint.document.write('</center></body></html>'); docprint.document.close(); docprint.focus(); } To print execute this code UniSession.AddJS('PrintMe('''+unihtmlframe1.jsname+'_id'')'); 1 Quote
zilav Posted February 28, 2016 Posted February 28, 2016 "window.open" is blocked in a lot of browsers, it is very unreliable in the modern web from my experience of dealing with users and their systems. That's why I prefer to show them a link which they click to open a new tab, this always works regardless of browser and device. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.