Home Answers Viewqa JSP-Servlet How to generate pdf file on click of the links using jsp..

 
 


dhananjay dwivedi
How to generate pdf file on click of the links using jsp..
2 Answer(s)      8 months ago
Posted in : JSP-Servlet

How to generate the pdf file using jsp file. Generate table in pdf by using jsp.

View Answers

September 4, 2012 at 11:59 AM


Here is an example that will generate a pdf file into c drive.The pdf file consists of the data retrieved from database.You need itext api to run the given code.

<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page import="com.lowagie.text.*"%>
<%@page import="com.lowagie.text.pdf.*"%>

<%
        try {
            Document document = new Document();
            document.open();
            PdfReader reader = new PdfReader("C:/data.pdf");
            PdfDictionary dictionary = reader.getPageN(1);
            PRIndirectReference reference = (PRIndirectReference) dictionary.get(PdfName.CONTENTS);
            PRStream stream = (PRStream) PdfReader.getPdfObject(reference);
            byte[] bytes = PdfReader.getStreamBytes(stream);
            PRTokeniser tokenizer = new PRTokeniser(bytes);
            StringBuffer buffer = new StringBuffer();
            while (tokenizer.nextToken()) {
                if (tokenizer.getTokenType() == PRTokeniser.TK_STRING) {
                    buffer.append(tokenizer.getStringValue()+" ");
                }
            }
            String test = buffer.toString();
            out.println(test);
        } catch (Exception e) {
        }

%>

September 4, 2012 at 12:01 PM


Here is an example that will generate a pdf file into c drive.The pdf file consists of the data retrieved from database.You need itext api to run the given code.

1)link.jsp:

<a href="pdf.jsp">Click Here</a>

2)pdf.jsp:

<%@page import="java.io.*"%>
<%@page import="java.util.*"%>
<%@page import="com.lowagie.text.*"%>
<%@page import="com.lowagie.text.pdf.*"%>

<%
        try {
            Document document = new Document();
            document.open();
            PdfReader reader = new PdfReader("C:/data.pdf");
            PdfDictionary dictionary = reader.getPageN(1);
            PRIndirectReference reference = (PRIndirectReference) dictionary.get(PdfName.CONTENTS);
            PRStream stream = (PRStream) PdfReader.getPdfObject(reference);
            byte[] bytes = PdfReader.getStreamBytes(stream);
            PRTokeniser tokenizer = new PRTokeniser(bytes);
            StringBuffer buffer = new StringBuffer();
            while (tokenizer.nextToken()) {
                if (tokenizer.getTokenType() == PRTokeniser.TK_STRING) {
                    buffer.append(tokenizer.getStringValue()+" ");
                }
            }
            String test = buffer.toString();
            out.println(test);
        } catch (Exception e) {
        }

%>









Related Pages:
How to generate pdf file on click of the links using jsp..
How to generate pdf file on click of the links using jsp..  How to generate the pdf file using jsp file. Generate table in pdf by using jsp.   Here is an example that will generate a pdf file into c drive.The pdf file
How to generate the pdf file using jsp - JSP-Servlet
How to generate the pdf file using jsp  Hi how to generate the pdf file in jsp  Hi Friend, Try the following code: Thanks
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
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
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
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...: Compiling 1 source file to C:\Documents and Settings\Administrator\My Documents
how to generate the pdf report from jsp
){} finally{ document.close();} %> </body> I am using netbeans.I 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
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
how to generate pdf file in struts
how to generate pdf file in struts  I am developing a struts application.I am having one registration form when i am submitting the form the values... be shown as pdf or excel format
how to generate pdf file in struts
how to generate pdf file in struts  I am developing a struts application.I am having one registration form when i am submitting the form the values... be shown as pdf or excel format
generate pdf in spring
generate pdf in spring  HOw do i generate pdf in a spring application, so that my click should query the database and a pdf should be generated and downloaded to the client side
generate pdf in spring
generate pdf in spring  HOw do i generate pdf in a spring application, so that my click should query the database and a pdf should be generated and downloaded to the client side
Generate unicode malayalam PDF from JSP
the same report to be saved as PDF in unicode malayalam font.I have tried to generate PDF reports using IText,but I dont know how to generate unicode malayalam...Generate unicode malayalam PDF from JSP   Hi, I want to generate
pdf file is having the 0 KB when generate the pdf file from jsp - JSP-Servlet
pdf file is having the 0 KB when generate the pdf file from jsp  Hi Friend, I am getting OKB pdf file .if i inserting the image into pdf file , i am getting the OKB pdf file now and also not able to open the pdf
JSP Tutorials Resource - Useful Jsp Tutorials Links and Resources
(JSP) using Dreamweaver MX 2004 and a MySQL database.    ... servlet and JSP code: Learning how to develop Java servlets and JavaServer... using JAVA servlets, JAVA Server Pages (JSP and JASPER page compiler), Jakarta
Struts PDF Generating Example
in struts How to insert image in PDF file in struts2 How to set pdf...Struts PDF Generating Example To generate a PDF in struts you need to use...;/param> </result> An example of PDF Generating is given below
How to create pdf file in struts2.
How to create pdf file in struts2. In this example, you will see the how to create PDF in struts, and how to write message in generated PDF file in struts2...;Generate_PDF_in_Struts</title> </head> <body><h1>
Open a .doc file by click on the link using struts - Struts
Open a .doc file by click on the link using struts   I want to open a doc extension file when i click a link on jsp page .I know only about which is write in web.xml but not exactly know how i do this.Plz any one can help me
how to dispaly pdf file on browser
how to dispaly pdf file on browser  In my project i have created one pdf file(by pdfwriter) into my local mechine . after that it need to display in browser as a pdf file . but in jsp i can't display by tag can anyone give me
In pagination how to hilight the links - JSP-Servlet
In pagination how to hilight the links  Dear Sir, In pagination how to highlight the links or how to change the color of that link when i... { color:red; padding-top: 2px; padding-bottom:2px;} Click Hope
How to generate xml file using xpath
How to generate xml file using xpath  Hi, I have a requirement... to make a xml using that,. It would be great is you can help me out with how to make a xml using xpath. Thanks in Advance, Sanjay   Hi Friend, Please
In pagination how to hilight the links - JSP-Servlet
In pagination how to hilight the links  Dear Sir, Thanks... pagination ,in that if i click on a number only that number color will be changed like that i want in my code.So how to do this sir please help me . Thanks and Regards
Generating PDF reports - JSP-Servlet
Question I am try to generate a pdf report using jsp .... i want to export.../itext/helloServletPDF.shtml http://www.roseindia.net/jsp/file_upload...Generating PDF reports  Hello everyone i have submitted several
how to display pdf file on browser
how to display pdf file on browser   In my project i have created one pdf file(by pdfwriter) into my local mechine . after that it need to display in browser as a pdf file . but in jsp i can't display by iframe tag can anyone
How to Make a Pdf and inserting data
a pdf file and how we can insert a data into the pdf file. This all be done by using... How to Make a Pdf and inserting data   ... which will help us to make a pdf file.  The logic of the program
How to insert a single page PDF file into another multipage PDF file using iText? - Java Beginners
How to insert a single page PDF file into another multipage PDF file using iText?  Hi ALL: I have two PDF files. PDF-A.pdf is a multipage PDF file. PDF-B.pdf is a single page PDF file. I want to insert PDF-B into PDF-A only
Open Source PDF
Open Source PDF Open Source PDF Libraries in Java iText is a library that allows you to generate PDF files on the fly... to create pdf files and print using subclasses of java.awt.Graphics
generate file
generate file  How to generate file(.doc or .xls or .txt ) with containing data in it.By clicking on a link
Java code to convert pdf file to word file
Java code to convert pdf file to word file  How to convert pdf file to word file using Java
Javascript generate textbox
Javascript generate textbox In this tutorial, you will learn how to generate a textbox on button click using javascript. Here is a javascript example...;script> function generate() { var no = document.getElementById("text"
form field mapping with pdf file using java
form field mapping with pdf file using java   Hai all, I have one... file. means, if click on text field according that perticular field .the data related to the field in pdf file should marked with a color. can any one give
To Generate Excel
is as follows in a jsp there will be a link where if you click on that a dialog box With EXCEL in it has to open up how can i achieve this pls explain...To Generate Excel  hi First of all my application uses Struts2
convert an pdf file to html in Java
convert an pdf file to html in Java  Hi all, How to convert an pdf file to html in Java? Currently all my data is generated into a report in pdf and i want to be able to generate it to html page as well. How to go about
How I can filling pdf file that crated by livecycle using itext
How I can filling pdf file that crated by livecycle using itext  I have pdf file that already done by livecycle.. I read it then I used the pdfstamber class to manipolute and filling file.... the result it will be a new pdf file
pdf to text
pdf to text  how to covert pdf file (which contain table and text) into word or excel file using itext api
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
generate charts using JSP
generate charts using JSP  any one know coding for generate bar chart or pie chart using JSP
how to generate automatic bill based on selected values using jsp/javascript?
how to generate automatic bill based on selected values using jsp/javascript?  how to generate automatic bill based on selected values using jsp/javascript
how do i provide down a pdf document fecility on my web page using jsp and servlets?
how do i provide down a pdf document fecility on my web page using jsp and servlets?  Hai, I need a program to provide download option for pdf file on my web page,the pdf file contains retrieved data from mysql table. I need
PDF Comparator
. Also, i need to write the generate a new pdf file which should highlight... is not matching. I am able to generate the pdf file, bt not able to highlight... is to match a pdf file with another pdf file, and it should generate a pdf file
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
how to add the scrollbar to the pdf page when generating the pdf file from jsp - JSP-Servlet
how to add the scrollbar to the pdf page when generating the pdf file from jsp  I am not able to see all the columns when i generated the pdf file from jsp.i have 12 colums so how to add the scrollbar
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
Add Content of an iText PDF File using java code
Add Content of an iText PDF File using java code  ... to generate pdf file dynamically. The iText library can be used to generate PDF... facility to create pdf file from java application. iText is a freely available Java
how to generate a bar chart on a JSP PAGE using the arraylist object passed form the servlet.(using jfreechart)
how to generate a bar chart on a JSP PAGE using the arraylist object passed form the servlet.(using jfreechart)  I have created a servlet.In this,i... the database.now i have to pass this arraylist object to a jsp page and on that jsp page
Struts Links - Links to Many Struts Resources
you how to develop Struts applications using ant and deploy on the JBoss... Struts Links - Links to Many Struts Resources Jakarta... will create JSP page for entering the address and use the functionality provided
How to adjust a size of a pdf file
How to adjust a size of a pdf file   ... adjust the size of a pdf file irrespective of the fact whether it exists or not. If it exists then its fine, otherwise a pdf file will be created. 
how to get the image path when inserting the image into pdf file in jsp - JSP-Servlet
how to get the image path when inserting the image into pdf file in jsp  I am using the below code but i am getting the error at .getInstance. i am using the itext.jar now.Plz help to me <% Document document=new
onfly conversion of jsp to pdf (urgent) - Development process
(in PDF form) on a button click event all the text in jsp is dynamic comes from...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
How to wrap image in the pdf file
How to wrap image in the pdf file   ... insert a image  and wrap it according to your own style in a pdf file...*, and com.lowagie.text.*. These two package will help us to make and use pdf file in our

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.