tag:blogger.com,1999:blog-641292013364990945.post1919875398594704921..comments2023-07-06T16:13:27.969+05:30Comments on Techy Shyarmal: Printing example with Java EEAnonymoushttp://www.blogger.com/profile/04856914369109888245noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-641292013364990945.post-35496573446089209772015-06-11T01:19:37.286+05:302015-06-11T01:19:37.286+05:30Okay thanks for your help ShyarmalOkay thanks for your help ShyarmalRomeohttps://www.blogger.com/profile/14887366128179808869noreply@blogger.comtag:blogger.com,1999:blog-641292013364990945.post-70753950024382069842015-06-10T12:22:21.340+05:302015-06-10T12:22:21.340+05:30I haven't tried it. But I think it would work....I haven't tried it. But I think it would work. :)Anonymoushttps://www.blogger.com/profile/04856914369109888245noreply@blogger.comtag:blogger.com,1999:blog-641292013364990945.post-68867659630167422332015-06-10T03:42:32.044+05:302015-06-10T03:42:32.044+05:30Yes i do not want it to show. But the only way i s...Yes i do not want it to show. But the only way i see fit to use the iframes is to send it to the jsp and then put it in the iframe like the example and then print it onload with javascript. I believe it will be put in the iframe on the jsp page and not the servlet. Do you think it will show this way?Romeohttps://www.blogger.com/profile/14887366128179808869noreply@blogger.comtag:blogger.com,1999:blog-641292013364990945.post-17879406124048152172015-06-09T09:38:57.400+05:302015-06-09T09:38:57.400+05:30You have to bring the string content to the jsp an...You have to bring the string content to the jsp and do the printing with javascript. Javascript runs on the browser (client side).<br /><br />What you suggest is fine too. It all depends on your requirement. However I thought you did not want to show the page before it prints, which is why I suggested iframes.Anonymoushttps://www.blogger.com/profile/04856914369109888245noreply@blogger.comtag:blogger.com,1999:blog-641292013364990945.post-49300096813691513792015-06-08T21:12:48.102+05:302015-06-08T21:12:48.102+05:30Yes I am using the string buffer in the servlet. I...Yes I am using the string buffer in the servlet. I need to make it as seamless as possible so the user does not click too much. will it be a good idea to pass it to the jsp and then use javscript onload function to generate the page preview by giving it the jsp urlRomeohttps://www.blogger.com/profile/14887366128179808869noreply@blogger.comtag:blogger.com,1999:blog-641292013364990945.post-89408148292396002292015-06-08T21:08:27.803+05:302015-06-08T21:08:27.803+05:30This comment has been removed by the author.Romeohttps://www.blogger.com/profile/14887366128179808869noreply@blogger.comtag:blogger.com,1999:blog-641292013364990945.post-74334981500928222892015-06-08T21:07:49.294+05:302015-06-08T21:07:49.294+05:30This comment has been removed by the author.Romeohttps://www.blogger.com/profile/14887366128179808869noreply@blogger.comtag:blogger.com,1999:blog-641292013364990945.post-52403353260483821322015-06-06T11:32:07.166+05:302015-06-06T11:32:07.166+05:30I assume that you are having the StringBuffer in y...I assume that you are having the StringBuffer in your servlet. In that case, you'll have to send your html to your jsp before using it in your javascript code.Anonymoushttps://www.blogger.com/profile/04856914369109888245noreply@blogger.comtag:blogger.com,1999:blog-641292013364990945.post-1024729555723415252015-06-06T11:26:59.037+05:302015-06-06T11:26:59.037+05:30No. If you have multiple lines, the content of the...No. If you have multiple lines, the content of the iframe would be that you set from the last line. The first gets overwritten by the second.<br /><br />You'll have to set the whole content once.Anonymoushttps://www.blogger.com/profile/04856914369109888245noreply@blogger.comtag:blogger.com,1999:blog-641292013364990945.post-87962094560486251182015-06-06T04:28:47.030+05:302015-06-06T04:28:47.030+05:30The function print page in that link takes in a UR...The function print page in that link takes in a URL. I am still trying to figure out how to give it the html code which I had to append with a string bufferRomeohttps://www.blogger.com/profile/14887366128179808869noreply@blogger.comtag:blogger.com,1999:blog-641292013364990945.post-85632494443885475672015-06-06T01:00:38.402+05:302015-06-06T01:00:38.402+05:30Thanks so far Shyarmal, Looking at my html code ab...Thanks so far Shyarmal, Looking at my html code above, would i have multiple lines of the document.getElemet. For example <br />document.getElementById('iframe').contentDocument.write(buf.append(html);<br />document.getElementById('iframe').contentDocument.write(buf.append(body); etc.<br />I am a bit new to this. ThanksRomeohttps://www.blogger.com/profile/14887366128179808869noreply@blogger.comtag:blogger.com,1999:blog-641292013364990945.post-37981710121836901382015-06-05T14:18:01.417+05:302015-06-05T14:18:01.417+05:30hi Romeo,
You may set your content as innerHTML o...hi Romeo,<br /><br />You may set your content as innerHTML of the iframe instead of giving a url to an html page.<br /><br />document.getElementById('iframe').contentDocument.write("your content");Anonymoushttps://www.blogger.com/profile/04856914369109888245noreply@blogger.comtag:blogger.com,1999:blog-641292013364990945.post-13300855036940146812015-06-05T04:58:04.064+05:302015-06-05T04:58:04.064+05:30Hi Shyarmal, I took a look at it and it says if yo...Hi Shyarmal, I took a look at it and it says if you are printing a html page. how about if i have html code for example<br />StringBuffer buf = new StringBuffer();<br /> buf.append(html);<br />buf.append(body);<br /> buf.append(body);<br /> buf.append(html);<br />How would i put this in the iframe. At the moment, I am appending my html to a string buffer because I had it rendered to pdf using itext before printing. Now I want it to print directly without opening the pdf preview. <br />Romeohttps://www.blogger.com/profile/14887366128179808869noreply@blogger.comtag:blogger.com,1999:blog-641292013364990945.post-43363810915111580012015-06-04T12:06:40.647+05:302015-06-04T12:06:40.647+05:30hi Romeo,
You can try using 'iframe' elem...hi Romeo, <br />You can try using 'iframe' element in HTML. Set your printing content as its inner html. Further you'll have to set CSS properties as appropriate to make it invisible and print on load.<br /><br />please refer: https://developer.mozilla.org/en-US/docs/Printing<br />Hope this would help you. Anonymoushttps://www.blogger.com/profile/04856914369109888245noreply@blogger.comtag:blogger.com,1999:blog-641292013364990945.post-25450768543549416022015-06-04T03:43:23.100+05:302015-06-04T03:43:23.100+05:30Hi Shyarmal, I am using a jsp page and passing the...Hi Shyarmal, I am using a jsp page and passing the information to the servlet using requet.getparam and embedding it in html in the servlet. I am required to send the information directly to the printer. It is an invoice how do i call the printer without generating a preview of the page. Kindly assist with sample code. You can email me at romeoebube@gmail.comRomeohttps://www.blogger.com/profile/14887366128179808869noreply@blogger.com