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 8886877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:39:56+00:00 2026-06-14T21:39:56+00:00

Hi All Iam using itextpdf-5.1.0.jar, displaying Table(the values in this table are fetched from

  • 0

Hi All Iam using itextpdf-5.1.0.jar, displaying Table(the values in this table are fetched from the database based on start date and end date in the input screen) and bar chart for the values in the above table.

The problem is I want to position the bar chart below the table, values that iam fetching from the database may vary depending upon start date and end date, now Iam positioning table and bar chart by giving some static values(234,567) , if there are large no of values table values and bar chart are getting overrided. Is there any other way to position table and bar chart dynamically.

Document document = new Document(PageSize.A4_LANDSCAPE, 10, 10, 10, 10);
document.open();
document.add(new Paragraph("Batch Report:", FontFactory.getFont(FontFactory.COURIER, 10, Font.BOLD, new CMYKColor(255, 255, 255, 255))));
Paragraph paragraph1 = new Paragraph();
paragraph1.setSpacingBefore(4);
document.add(paragraph1);
PdfPTable table = new PdfPTable(5);
table.setWidthPercentage(100);
PdfPCell c1;

for (BoardBean bean : listHeader) {
addColumn(bean.getID(),c1,table,myColor,btableheadercolor);   
}

Add Column values to table

private void addColumn(String text,PdfPCell c1,PdfPTable dataTable,BaseColor   myColor,BaseColor btablecolumncolor) {
  try {
  final Font tabletdcolor = new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL, BaseColor.BLACK);
  c1 = new PdfPCell(new Paragraph(text, tabletdcolor));
  cellStyle(c1, myColor, btablecolumncolor);
  dataTable.addCell(c1);
  } catch (Exception ex) {
ex.printStackTrace();
  }
}

Generating bar chart

JFreeChart reportBarChart = genBatchReportBarChart(listHeader);
PdfTemplate reportTemplate = contentByte.createTemplate(280, 230);
        Graphics2D reportGraphics = reportTemplate.createGraphics(280, 230, new DefaultFontMapper());
Rectangle2D reportRectangle = new Rectangle2D.Double(0, 0, 280, 230);
reportBarChart.draw(reportGraphics, reportRectangle);
reportGraphics.dispose();
contentByte.addTemplate(reportTemplate, 10, height+150);

Now in the above code iam fixing the position of bar chart and if the values are low in number its good but if they are large in number bar chart is overriding the table values.Depending upon the table values the bar chart need to be aligned how can I achieve that.

  • 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-14T21:39:57+00:00Added an answer on June 14, 2026 at 9:39 pm

    You can ask the table for its total height after you’ve added the table to the document, and use that table height to decide where to put the chart.

    Or (even easier to achieve): you can wrap the PdfTemplate inside an Image object:

    Image img = Image.getInstance(reportTemplate);
    

    Add that image with document.add() right after you’ve added the table (assuming that you’re adding the table with document.add()).

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

Sidebar

Related Questions

iam using a simple insert script function to pass the values from registration html
Iam using windows forms. How can I query all child controls of a Form
HI all, Iam using VS2008 and SQL2008 i want to access my stored procedures
i want to submit a form using Ext.Direct and iam following all the guidelines
Dear all i am using this function to get the GMT time, i am
This is all in C#: I am using this code to resize an image:
All, For all of this I am using Mac OSX Snow Leopard. I have
I build dynamically my HTML table from database like that: for (i = 0;
Hi all I am using this function to get name's of the input fields
all I need to change the position of a ImageView dynamically and iam using

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.