onfly conversion of jsp to pdf (urgent)

onfly conversion of jsp to pdf (urgent)

View Answers

September 29, 2008 at 6:37 PM

Hi,


"test.jsp"

In this code having a button "Create Pdf" onClick this button call
method showEmp(); then it send to the url on the proccess page
var url="getuser.jsp?emp_id=E01";

it passes emp_id to "getuser.jsp" and on this page create a Pdf file on th
c:drive with "hello.pdf".


<%@ page import="java.sql.*" %>
<html>
<head>
<style>
A:hover {text-decoration: none;

border: 0px;
font-size:14pt;
color: #2d2b2b; }
</style>

<link rel="stylesheet" type="text/css" href="datepicker.css"/>


<script type="text/javascript">
function trim(str) {
if(!str || typeof str != 'string')
return null;
return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}
function showEmp()
{

xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="getuser.jsp?emp_id=E01";
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)


}

function stateChanged()
{

if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{

var showdata = xmlHttp.responseText;
if(trim(showdata) =="ok")
{
alert("You are successful create the pdf");
}


}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</script>

</head>
<body >
<table>
<tr><td><input type="button" name="result" id="result" value="Create Pdf" onclick="showEmp();"></td></tr>

</table>
</form>


</body>
</html>

"getuser.jsp"
<%@ page import="java.sql.*,java.io.*,com.lowagie.text.pdf.*,com.lowagie.text.*,com.lowagie.text.Document
" %>
<%
String emp_id = request.getParameter("emp_id").toString();
String data ="";

Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "user_register";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";

int sumcount=0;
Statement st;
try {
Class.forName(driver).newInstance();

conn = DriverManager.getConnection(url+dbName,userName,password);
String query = "select * from employee_details where eid='"+emp_id+"'";

st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next())
{
data = rs.getString(2) + " " + rs.getString(3);
}

Document document=new Document();
PdfWriter.getInstance(document,new FileOutputStream("c:\\hello.pdf"));
document.open();
document.add(new Paragraph(data));
document.close();

out.println("ok");
}
catch (Exception e) {
e.printStackTrace();
}
%>

Thanks











Related Tutorials/Questions & Answers:
onfly conversion of jsp to pdf (urgent) - Development process
onfly conversion of jsp to pdf (urgent)  Hi, i m facing problem to convert jsp to pdf on on fly, i have an application in which there is some... (in PDF form) on a button click event all the text in jsp is dynamic comes from
Reports to pdf conversion
Reports to pdf conversion  I need to convert reports into pdf format using java.. Will i get any sample code
Advertisements
pdf to xml conversion
pdf to xml conversion  i want to convert pdf file into xml file.. where i am having a table in pdf file with some headers and some data into it. i want the headers to be the tag of xml file. how can i do that using java? please
Byte array to PDF Conversion
Byte array to PDF Conversion  Hi, Am getting a letter Format in Byte array and i have to display that in PDF.Is that possible in PHP ? If so please let me knw how should i ? I can able to display that in a word Document but i
PDF to Word Conversion - Java Beginners
PDF to Word Conversion  Hello, Can we convert a PDF document to Microsoft word document thru Java. If its not possible in Java, is it possible in any other language
Program urgent - JSP-Servlet
Please please its very urgent.. Thanks/Regards...://www.roseindia.net/jsp/implement-javascript-with-jsp.shtml Thanks
Program Urgent - JSP-Servlet
in urgent need of the coding. My requirement is as follows: Beside Enter Employee ID... automatically with the selected Employee ID and Name. Its Very Urgent.. Please send me... for more information. http://www.roseindia.net/jsp Thanks. Amardeep
urgent - JSP-Servlet
Simple Jsp and Java Example  Simple Jsp and Java Example
Download.jsp Urgent - JSP-Servlet
Download.jsp Urgent  Respected Sir/Madam, I am R.Ragavendran.. I am having a simple doubt when downloading the files through JSP..... Please send me the modified code ASAP as this goes very urgent in my case
pdf generate from jsp
pdf generate from jsp  how do i generate a pdf using jsp that should query the data from the database and write it into a pdf and download the same
pdf file in jsp
pdf file in jsp  i have a pdf, which has to be displayed in a jsp page along with some html tags, the pdf which is to be displayed shold be readonly and wont allow the uer to save too
generate pdf using jsp
generate pdf using jsp  how do i generate a pdf using jsp that should query the data from the database and write it into a pdf and download the same
Urgent: HttpRequest - JSP-Servlet
Urgent: HttpRequest  Hi, I want to send a http Request. Their will be another program which will receice the request process it and send back the response. Example: I have one page in which I am giving 2 numbers as input
Generating PDF reports - JSP-Servlet
Question I am try to generate a pdf report using jsp .... i want to export values stored in sql server DB on to a pdf files so please do reply its very...Generating PDF reports  Hello everyone i have submitted several
how to generate the pdf file with scroolbar from jsp age - JSP-Servlet
how to generate the pdf file with scroolbar from jsp age  How to generate the pdf file with scroolbar from jsp.i am not able to see the all the columns in pdf file now .it is very urgent for me plz help
Program Very Urgent.. - JSP-Servlet
Program Very Urgent..  Respected Sir/Madam, I am R.Ragavendran.... reference. http://www.roseindia.net/jsp/popup-window-using-ajax-in-jsp.shtml... its most urgent.. Thanks/Regards, R.Ragavendran..   Hi friend
Programming Help URGENT - JSP-Servlet
R.Ragavendran. I am in urgent need of the coding. My requirement is as follows: Beside... URGENT...://www.roseindia.net/jsp/implement-javascript-with-jsp.shtml Thanks
JSP and AJAX- very urgent - Ajax
JSP and AJAX- very urgent  Respected Sir/Madam, I am Ragavendran.. I have a simple doubt.. At present, I am in a module of the project... Plz its very very Urgent.. Regards, Ragavendran
pdf format - JSP-Servlet
pdf format  hi Sir, how to convert text format into PDF format. thanks & regards, vijayababu.m
Download.jsp Urgent plz - JSP-Servlet
Download.jsp Urgent plz  Respected Sir/Madam, I am R.Ragavendran.. I got your coding for download.jsp.. A lot of Thanks... reference: Download.JSP: file download in jsp File
JSP and AJAX very urgent - Ajax
JSP and AJAX very urgent  Hi Team, This is Ragavendran.R.. I..., there will be tag involved in JSP page. But in my current project, I am using too many tags in my JSP page and as a result, I am getting only the last div tag updated
JSP,JDBC and HTML(Very Urgent) - JSP-Servlet
JSP,JDBC and HTML(Very Urgent)  Respected Sir/Madam, Thanks... details from database using JDBC and JSP. The home page i.e HTML Page must contain... to ROSEINDIA team.. This is Very Urgent. Plz Plz send me the coding ASAP
how to generate the pdf report from jsp
want to generate the pdf file from jsp page.I add the itext.jar to the libraries...how to generate the pdf report from jsp  <%@page import... not getting the pdf file.Any one please help me asap.Its very important
Image Program Urgent - JSP-Servlet
Excel / Doc to PDF conversion using Acrobat9 - Development process
Excel / Doc to PDF conversion using Acrobat9  Hi, I need to convert .xls / .doc files to .pdf files using Acrobat9. Please suggest the possible... and POI library to convert doc file into pdf file. import java.io.*; import
Generate pdf file - JSP-Servlet
Generate pdf file   Hi Friends, How to generate the pdf file for the jsp page or in servets  Hi Friend, You need to download itext api. After that set the classpath and try the following code
File Upload And download JSP Urgent - JSP-Servlet
File Upload And download JSP Urgent  Respected Sir/Madam, I... Download in JSP.. In the Admin window, There must be "Upload" provision where admin... Ragavendran, i am sending code of file download in jsp. Plz implement this code
jsp to struts 2 action conversion problem - Struts
jsp to struts 2 action conversion problem  i have one jsp page that includes 3 other jsp pages(using RequestDispactcher).how to convert that jsp page to a struts2 action?among that one jsp page is wrritten using jpivot,wct tags
Basic problem but very urgent - JSP-Servlet
kind reference. http://www.roseindia.net/jsp/popup-window-using-ajax... me the cause of the problem asap because its most urgent.. Thanks/Regards
Programming help Very Urgent - JSP-Servlet
Please please its very urgent.. Thanks/Regards, R.Ragavendran..  Hi friend, Read for more information, http://www.roseindia.net/jsp
Show pdf's in web browser by using jsp?
Show pdf's in web browser by using jsp?  Hi, I want to display pdf file in browser by clicking the link, available in JSP page. When am trying... status - 404. How can i resolve it in JSP
Very Very Urgent -Image - JSP-Servlet
Very Very Urgent -Image  Respected Sir/Madam, I am R.Ragavendran.. I am working with JSP and JDBC.. In the home JSP page, there is a button... ID) inside the text box of my home JSP page.. How to check whether
Popup very urgent plz - JSP-Servlet
Popup very urgent plz  Respected Sir/Madam, I am R.Ragavendran.. I...='' Its Very Urgent.. Please send me the coding asap.. Thanks/Regards... http://www.roseindia.net/jsp
Radio Buttons in DB Very Urgent - JSP-Servlet
the code.. Here When I click "View Database" Button,a JSP Page containing... Very Urgent.. Please send... for more information. http://www.roseindia.net/jsp
PDF creation in JAVA - JSP-Servlet
PDF creation in JAVA  HI! Good morning.... I want to create pdf file and i want to write something into pdf file....before creation. Upto creation i have done but how to write data into pdf. File Writer is not working
openning the pdf or doc file in same jsp
openning the pdf or doc file in same jsp   **how to open the pdf and doc file in same jsp after clicking the link or button (which is with out moving to the next page). will some body help me on this @simple format please
Help Very Very Urgent - JSP-Servlet
requirements.. Please please Its Very very very very very urgent... Thanks.../jsp/ Thanks.   function trim(stringToTrim... for more information, http://www.roseindia.net/jsp
To save table format data in pdf/excel in jsp
To save table format data in pdf/excel in jsp  Hello, I am doing web application project in jsp. In webform ,I am displaying database data in html table. So my question is ,I want so save this html format data in pdf/excel format
Simple Program Very Urgent.. - JSP-Servlet
Simple Program Very Urgent..  Respected Sir/Madam, I am... coding asap because its most urgent.. Thanks/Regards, R.Ragavendran..  ... information. http://www.roseindia.net/jsp/popup-window-using-ajax
Pop up Very Very Urgent - JSP-Servlet
='' Its Very Urgent.. Please send me the coding asap.. Thanks
Image Selection Reply Urgent.. - JSP-Servlet
Image Selection Reply Urgent..  Respected Sir/Madam, I am R.Ragavendran.. Thanks for yuor fast response.. Sir actually I will be much more convenient if you provide me with coding.. I dont know to work with images as i
Validating Number Very Urgent - JSP-Servlet
Urgent.. Please send me the coding asap.. Thanks/Regards, R.Ragavendran.. 
Very urgent Image Selection - JSP-Servlet
Very urgent Image Selection  Respected Sir/Madam, I am R.Ragavendran.. If you are telling that your coding works fine, then can u plz tell me or send me the output of the following code asap? var imageURL
urgent need in two days - JSP-Servlet
understand the Mysql and Jdbc database connectivity code  understand the Mysql and Jdbc database connectivity code through example.  See the Given JSP Example Code-------------------------------Servletform.html<
How to set the pdfptable as pdf page header when generating the pdf from jsp page. - JSP-Servlet
How to set the pdfptable as pdf page header when generating the pdf from jsp page.  how to set the pdfptable column headers as a header of the documet.i need to display the column headers for every pdf page if pdf documt is 20
Probem while creating PDF through JSP-Servlet - JSP-Servlet
Probem while creating PDF through JSP-Servlet  Hi, I have a web-app in which I want to convert MS-Office documents to PDF online. I'm using... a batch file, I get the required PDF file. But if I cll the same standalone
Generate unicode malayalam PDF from JSP
Generate unicode malayalam PDF from JSP   Hi, I want to generate a malayalam report in PDF format.I have generated a report in jsp.Now I want the same report to be saved as PDF in unicode malayalam font.I have tried to generate
open pdf file in same jsp page and the pdf file should retrieved from database
open pdf file in same jsp page and the pdf file should retrieved from database  Hai all, I need code to open a pdf file in same jsp page(browser) while click on hyperlink And the file was located in database table. Can any
how to generate PDF file using JSP with net beans
how to generate PDF file using JSP with net beans  I am trying to generate PDF file using JSP. I even added itext5.0.6 jar file in library. It shows the following errors... PLz anyone help me. Its urgent.... compile-jsps
urgent need for jsp code with mysql query for uploading and downloading file - JSP-Servlet
urgent need for jsp code with mysql query for uploading and downloading file  can anyone tell me how to upload and download a doc file using jsp with mysql as the back end... and kindly help me to create the table too

Ads