Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Open Source Projects
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Other Open Source Projects
Need to Charts on same PDF Output
Steve Dyke
Ranch Hand
Posts: 2206
2
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am using the following code in my
servlet
but I only get the first chart and it is as big as page.
MOR8dChart dashboardChart8d = new MOR8dChart(); dashboardChart8d.setIssued8ds(gConn.getAs400Conn(), edSource, dArray.getDateArray(), rOwnerGroupString, rLocationString, userid, rStatusString); request.getSession().setAttribute("chart1",dashboardChart8d.getChart()); JFreeChart chart = (JFreeChart) request.getSession().getAttribute( "chart1" ); MOR8dChartb dashboardChart8db = new MOR8dChartb(); dashboardChart8db.setIssued8ds(gConn.getAs400Conn(), edSource, rOwnerGroupString, rLocationString, userid, rStatusString); request.getSession().setAttribute("chart1b",dashboardChart8db.getChart()); JFreeChart chartb = (JFreeChart) request.getSession().getAttribute( "chart1b" ); if(new Boolean(new Boolean(request.getSession().getAttribute("localServer").toString()).booleanValue()).booleanValue()){ pdffilePath = "//qgvas400/home/FAIManagement/ReportsAndCharts/MOR8dChart"+edSource+userid+".pdf"; } else{ pdffilePath = "/home/FAIManagement/ReportsAndCharts/MOR8dChart"+edSource+userid+".pdf"; } FileIndexerConnection fiConn = new FileIndexerConnection(); fiConn.setSaveUserFile(gConn.getAs400Conn(), userid, "/home/FAIManagement/ReportsAndCharts/RejectionsByDispositionChart" + edSource+userid+".pdf"); response.setContentType( "application/pdf" ); int width = 320; int height = 240; Rectangle pagesize = new Rectangle( width, height ); try{ Document document = new Document( pagesize, 50, 50, 50, 50 ); PdfWriter writer = PdfWriter.getInstance( document, new FileOutputStream(pdffilePath) ); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate( width, height ); Graphics2D g2 = tp.createGraphics( width, height, new DefaultFontMapper() ); Rectangle2D r2D = new Rectangle2D.Double(0, 0, width, height ); chart.draw(g2, r2D); g2.dispose(); cb.addTemplate(tp, 0, 0); PdfContentByte cbb = writer.getDirectContent(); PdfTemplate tpb = cbb.createTemplate( width, height ); Graphics2D g2b = tpb.createGraphics( width, height, new DefaultFontMapper() ); Rectangle2D r2Db = new Rectangle2D.Double(320, 240, width, height ); chartb.draw(g2b, r2Db); g2b.dispose(); cbb.addTemplate(tpb, 0, 0); document.close();
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
What to Replace Deprecated Method With
2D inconsistencies
Images in PDF files problem for ServletOutputStream
iText PDF export
Display a Chart from a Servlet to JSP
More...