Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8483349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:04:42+00:00 2026-06-10T20:04:42+00:00

I have some values to be exported to PDF, how can i do this

  • 0

I have some values to be exported to PDF, how can i do this in struts?

I would like to do the following, have option button or link when the user clicks on the button or link than the user should get a download option to download the exported PDF file.

I have a resultset which needs to be exported to PDF.

Please help me how to go about.

Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:04:44+00:00Added an answer on June 10, 2026 at 8:04 pm

    Here is an example that may help you to do what you want:

    import java.io.*;
    import java.sql.*;
    import com.lowagie.text.*;
    import com.lowagie.text.pdf.*;
    
    public class CreatePDF{
        public static void main(String arg[])throws Exception{
            Document document = new Document();
            PdfWriter.getInstance(document, new FileOutputStream("C:/data.pdf"));
    
            document.open();
    
            PdfPTable table = new PdfPTable(2);
            table.addCell("Name");
            table.addCell("Address");
    
            Class.forName("com.mysql.jdbc.Driver");
            Connection con = DriverManager.getConnection(
                                            "jdbc:mysql://localhost:3306/test",
                                            "root", "root");
    
            Statement st = con.createStatement();
            ResultSet rs = st.executeQuery("Select * from data");
    
            while(rs.next()) {
                table.addCell(rs.getString("name"));
                table.addCell(rs.getString("address"));
            }
    
            document.add(table);
            document.close();
        }
    }
    

    But before implementing it you have to put itext.jar into your WEB-INF/lib folder.
    And you also found plenty of methods to manipulate your pdf file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some values in a configuration file (XML file) with some values like
I have some double values I want to convert to a string with this
I have an array in which I have some values like $errors[]=Invalid username; $errors[]=Invalid
I have some values in a dataframe called 'values' ie: Sam Ned Ted Ann
In my C++ application, I have some values that act as codes to represent
I have some default values for testing my code, but for security reasons those
I have some financial values stored as text in a mysql db. the significance
I have some code that sets up a dictionary with some defualt values for
I have to transfer some values to be used as commands over the network,
Introduction I have some sort of values that I might want to access several

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.