Chart to PDF...

I've posted a revision to my document describing how to create charts / graphs in PDF format using JFreeChart and iText, two popular free class libraries for Java. You can download the document from the JFreeChart project page on SourceForge:
http://sourceforge.net/projects/jfreechart
Regards,
Dave Gilbert
www.object-refinery.com

Thanks for this suggestion I hope it does the trick.

Similar Messages

  • Cannot generate chart in PDF using BI Publisher

    I have a java program to generate chart in PDF using BI publisher. In some platforms the chart cannot be generated. Get the following exception.
    [061812_075947838][][ERROR] java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at oracle.apps.xdo.template.rtf.img.RTFChartUtil.invokeMethod(Unknown Source)
    at oracle.apps.xdo.template.rtf.img.RTFChartUtil.generateChartAsBase64(Unknown Source)
    at oracle.apps.xdo.template.rtf.XSLTFunctions.chart_svg(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at oracle.xdo.parser.v2.XSLExtFunctions.callStaticMethod(XSLExtFunctions.java:111)
    at oracle.xdo.parser.v2.XPathExtFunction.evaluateMethod(XPathExtFunction.java:307)
    at oracle.xdo.parser.v2.XPathExtFunction.evaluate(XPathExtFunction.java:226)
    at oracle.xdo.parser.v2.XSLValueOf.processAction(XSLValueOf.java:101)
    at oracle.xdo.parser.v2.XSLNode.processChildren(XSLNode.java:417)
    at oracle.xdo.parser.v2.XSLResultElement.processAction(XSLResultElement.java:180)
    at oracle.xdo.parser.v2.XSLNode.processChildren(XSLNode.java:417)
    at oracle.xdo.parser.v2.XSLResultElement.processAction(XSLResultElement.java:180)
    at oracle.xdo.parser.v2.XSLNode.processChildren(XSLNode.java:417)
    at oracle.xdo.parser.v2.XSLResultElement.processAction(XSLResultElement.java:180)
    at oracle.xdo.parser.v2.XSLNode.processChildren(XSLNode.java:417)
    at oracle.xdo.parser.v2.XSLResultElement.processAction(XSLResultElement.java:180)
    at oracle.xdo.parser.v2.XSLNode.processChildren(XSLNode.java:417)
    at oracle.xdo.parser.v2.XSLTemplate.processAction(XSLTemplate.java:191)
    at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:512)
    at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:489)
    at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:271)
    at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:155)
    at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at oracle.apps.xdo.common.xml.XSLT10gR1.invokeProcessXSL(Unknown Source)
    at oracle.apps.xdo.common.xml.XSLT10gR1.transform(Unknown Source)
    at oracle.apps.xdo.common.xml.XSLT10gR1.transform(Unknown Source)
    at oracle.apps.xdo.common.xml.XSLTWrapper.transform(Unknown Source)
    at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(Unknown Source)
    at oracle.apps.xdo.template.fo.util.FOUtility.generateFO(Unknown Source)
    at oracle.apps.xdo.template.FOProcessor.createFO(Unknown Source)
    at oracle.apps.xdo.template.FOProcessor.generate(Unknown Source)
    at com.edocs.common.reporting.batch.BatchEventHandler.generatePDFFile(BatchEventHandler.java:327)
    at com.edocs.common.reporting.batch.BatchEventHandler.processBatchRequest(BatchEventHandler.java:252)
    at com.edocs.common.reporting.batch.BatchEventHandler.service(BatchEventHandler.java:136)
    at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask.executeInternal(BatchReportProcessorTask.java:126)
    at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask.doProcessTask(BatchReportProcessorTask.java:46)
    at com.edocs.pwc.tasks.CommonTask.processTask(CommonTask.java:166)
    at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl.__WL_invoke(Unknown Source)
    at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:40)
    at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl.processTask(Unknown Source)
    at com.edocs.common.reporting.tasks.batchprocessor.BatchReportProcessorTask_9qwgr6_EOImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.activation.ActivatableServerRef.invoke(ActivatableServerRef.java:85)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:522)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:518)
    at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    Caused by: java.lang.NoSuchMethodError: oracle.dss.util.CustomStyle.<init>(Ljava/io/InputStream;)V
    at oracle.dss.graph.CommonGraph.setStyleStream(CommonGraph.java:10774)
    at oracle.dss.graph.CommonGraph.setStylePath(CommonGraph.java:10743)
    at oracle.dss.graph.CommonGraph.setStylePathXML(CommonGraph.java:12138)
    at oracle.dss.graph.CommonGraph.setXML(CommonGraph.java:13348)
    at oracle.dss.graph.CommonGraph._setXML(CommonGraph.java:15821)
    at oracle.dss.graph.CommonGraph.setXML(CommonGraph.java:14751)
    at oracle.dss.graph.Graph.setXML(Graph.java:5243)
    ... 60 more
    In office word bi publisher plugin, load the xml, the chart can be generated.
    The above exception only occurs in some linux and solaris platforms, but never occurs in windows.
    The following plateform throws exception.
    Oracle Linux Server release 5.6 + java version "1.6.0_25"
    The following plateform doesn't throw exception.
    Enterprise Linux Enterprise Linux Server release 5.4 (Carthage) + java version "1.6.0_05"
    The strange thing is in those platforms which can throw exception, if the code is not running in EJB, the chart still can be generated.
    In other words, if the normal web or standalone app invokes that program; the chart can be generated.
    The java code is as below.
         public static void generate(String inputXML, String pdfTempPath, String outputPDF) {
              Reader reader = null;
              try {
                   File xmlFile = new File(inputXML);
         reader = new BufferedReader(new InputStreamReader(new FileInputStream(xmlFile), "UTF-8"));               
              ByteArrayOutputStream tmpXSL = new ByteArrayOutputStream();           
              RTFProcessor rtfProcessor = new RTFProcessor(pdfTempPath);
                   rtfProcessor.setOutput(tmpXSL);
                   rtfProcessor.process();           
              ByteArrayInputStream in = new ByteArrayInputStream(tmpXSL.toByteArray());
              FOProcessor processor = new FOProcessor();
              processor.setData(reader);
              processor.setTemplate(in);
              processor.setOutput(outputPDF);
              processor.setOutputFormat(FOProcessor.FORMAT_PDF);           
              processor.generate();
              catch(Exception e) {
                   e.printStackTrace();
              finally {
                   try {
                        if(reader!=null) {
                             reader.close();
                   } catch (Exception e) {
    Can anyone explain why this exception is thrown?
    Thanks a lot.

    Hello Tux Dueñas,
    I think you need to have ACL's setup in Oracle 11g in order to be able to connect to the BI Publisher server. Check the following link on how to setup ACL's in 11g...
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28300/afterup.htm#BABFCBJI
    Thanks,
    Machaan
    Edited by: Machaan on Jan 25, 2011 11:49 AM

  • How to export an entire model content (tables and charts) to pdf

    Hello,
    I would like to export a complete model, which includes tables and charts, to pdf.
    I am already familiar with [this|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/47fe4fef-0d01-0010-6f87-ed8ecb479123] tutorial but it explains how to do it for a single table and doesn't deal with charts. What I would like to do is take like a screenshot of the entire iView/model content to pdf.

    Hi, rbish-
    Not for the entire stage.  The only thing you could do is to highlight everything and convert it to a symbol, then ensure that you move your triggers and labels to the new symbol.  Then you could export an individual symbol, which will also package all of the dependent symbols.
    Hope that helps,
    -Elaine

  • Output Charts to PDF using FOP

    Does anybody know is it possible to output ones charts to PDF format using the FOP??

    Hello,
    You could use something like the Report to FOP howto and by posting the SVG source get a PDF. I have never done that but in theory it should work.
    I have taken the source by hand and rendered FOP and that works, the only issue was the styles and class's had to be all put into the custom CSS section of the Chart attributes.
    Carl

  • Report not rendering charts in pdf (A generic error occurred in GDI+)

    I've found the following exception stack trace in the Report Server log:
    ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.RenderingObjectModelException: , Microsoft.ReportingServices.ReportProcessing.RenderingObjectModelException: A generic error occurred in GDI+. ---> System.Runtime.InteropServices.ExternalException:
    A generic error occurred in GDI+.
       at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
       at Microsoft.Reporting.Chart.WebForms.Chart.Save(Stream imageStream, ChartImageFormat format)
       at Microsoft.ReportingServices.OnDemandReportRendering.ChartMapper.GetImage(ImageType imageType)
       --- End of inner exception stack trace ---;
    I've got no idea what this is, any help would be appreciated. I don't know what could potentially cause this, so I don't even know how to start looking for a fix.
    Other info:
    SSRS 2012 BI
    Win Server 2008 R2 (Running on Hyper-V)
    The pdf report(s) renders and is saved to the location it is meant to, but devoid of any charts. A data driven subscription controls the rendering.

    Hi,
    This is a known issue with Windows GDI+. To resolve the issue, please install the hotfix for youR Windows Server 2008 R2 from:
    http://support.microsoft.com/kb/2495074
    Regards,
    Mike Yin
    TechNet Community Support

  • There's no proper way to export charts to PDF in numbers 3

    In Numbers 09, there're at least two ways.
    1. copy the chart and paste to preview with `New from clipboard`, although this has some bugs on the chart format
    2. Copy to pages, export as RTFD, and extract the pdf in the package.
    However, when upgraded to the new iWork,
    these two ways are ruled out.
    1. Seems preview doesn't recognize the new format of the iwork content, so `New from clipboard` results in a blurry image instead of a vectorgraph like pdf.
    2. The exporting to RTFD functionality has been removed.
    I don't understand why apple is doing this, and I wonder is there any proper way to export to a high-resolution PDF from the charts?

    Print the page/sheet and select "Print PDF to Preview" instead of actually printing. 
    In Preview, use the rectangular selection tool to select the chart
    Copy
    New from Clipboard
    That will create a PDF vector image of the chart. It is a few more steps than in Numbers '09 but it does give you all the pieces of the chart (unlike Numbers '09),

  • Fonts Skewed on Excel Charts in PDF

    Copy/pasted Excel charts as a picture into Word 2007. Converted Word 2007 to pdf (Acrobat 8.1.2), but fonts within charts appear very heavy bold (unreadable), even when not bolded, whether printed or viewed on screen. Using Windows XP. Any ideas?

    Hi ,
    Since it is a workbook Copy and inset query Twice.  Use one result set as source for your Chart and hide this result  area. You can use the second result set for  navigation.
    Jaya

  • Embedding Fusion Charts in PDF?

    i want to embed fusion charts (swf) inside a PDF file. How can i do this?
    Also can i embed flash using LiveCycle?
    thanks
    Faraz

    I have tried using Flash tool inside Acrobat Professional but its not working? Getting error unable to load error!

  • Please help. How to create reports including charts in pdf format .

    Please help.
    I have two problems.
    Any help will be highly appreciated.
    1. I need to query database through JDBC (which is easy) using servlet or JSP and then create a report in pdf format (which I do not know how to). If anyone knows how to create a report in pdf format, I would highly appreciate.
    2. I need to generate charts and embed them in these reports. I do not know how to make charts. If anyone knows and helps me out, I would highly appreciate. I have to make charts and embed them in the pdf reports.
    Thanks a lot in advance.
    Indrasish.

    Ok ibasuroy, but i don�t speak ingles.
    first problem:
    http://sourceforge.net/projects/jfreereport/
    JFreeReport is a Java class library for generating reports. It provides a flexible printing functionality for Java applications and supports output to Printers and PDF, Excel, HTML and XHTML, PlainText, XML and CSV files.
    second problem:
    http://sourceforge.net/projects/jfreechart/
    JFreeChart is a class library, written in Java, for generating charts. Utilising the Java2D APIs, it currently supports bar charts, pie charts, line charts, XY-plots and time series plots.
    write my. I have a class JDBCAdpater and a BridgeJFreeReport
    [email protected]

  • Flex Charting - Generating PDF and Images

    Is there any way with Flex Charting (or some 3rd party tool
    integrated with Flex) to output a FlexChart as a PDF or an image
    for inclusion in a report?

    Yes there is.
    Adobe® LiveCycle® Data Services ES
    Developer’s Guide (PDF)
    lcds_dev_guide.pdf
    Chapter 17
    Page 275
    import mx.graphics.ImageSnapshot;
    [Bindable]
    public var balanceSheetImage:String;
    private function generatePDF():void {
    var snapshot:ImageSnapshot =
    ImageSnapshot.captureImage(balanceSheet);
    balanceSheetImage =
    ImageSnapshot.encodeImageAsBase64(snapshot);
    snapshot = ImageSnapshot.captureImage(earnings);
    earningsImage = ImageSnapshot.encodeImageAsBase64(snapshot);

  • Vector charts in PDF?

    I would like to have vector charts in my PDF, so that their quality doesn't change when zoomed.
    How do I create such charts?

    ~graffiti wrote:
    If you created the charts in a vector format before you PDF the document, they will be vector.
    When exporting from MS Office apps charts do are vector.
    What about exporting charts in vector format from a Flex web application?

  • Converting .docx with chart to .pdf does not work correctly

    I have a docx file with an excel chart and a hyperlink in it. The chart is a line chart with data makers on the lines. One set of data markers are circles. The chart is simply copied from excel and pasted into word. I am using word and excel 2007 and adobe acrobat 8 standard on windows XP SP2. all software is fully updated.
    When I convert this doxc file to pdf, the circle data markers from the chart are greatly enlarged and obscure the text and chart. The hyperlink works fine. This occurs when I use the acrobat plug-in within word to create a "quick and simple" pdf. this also occurs when I open adobe and choose create pdf from file. I cannot use the word plug-in to create a "fully functional" pdf. This feature simply does not work.
    When I convert the file to a pdf using the adobe printer/distiller, the circle data markers on the chart are fine, but the hyperlink no longer functions.
    I can copy the chart from excel and paste it into powerpoint and publisher and the conversion to pdf works fine. i can also create a pdf of the chart from excel to pdf without problems, so it appears to be a word to pdf issue.

    Thanks Bill
    Perhaps I was not clear enough though. I am not really concerned with the hyperlinks.
    The main problem is the excel chart. When I use PDF Maker the circle data markers from the chart are greatly enlarged and obscure the text and chart. The only way to make the chart look normal is to use the distiller, which kills the hyperlinks. I would rather use PDF Maker, keep the functionality of the hyperlinks, and have the excel chart look normal. The PDF Maker distorts the circle data markers on the chart and makes the page unreadable. That is what I need to fix.
    I realize the simple solution is to use something other that circles for data makers, but I have a lot of charts and don't want to spend the time remaking them all.

  • Converting MS Access Charts to PDF

    Hello,
    I am trying to convert my Microsoft Access report into pdf. i have adobe prof and I have the MC plugin from adobe. The report displays fine in print preview and prints fine,displaying the chart. But when I convert to pdf, all the charts are missing, only the border appears but all empty inside.
    I tried to print only one page in pdf from the report and still the same problem.
    Does anoyone know what I can do?
    Thanks in Advance!

    How did you convert? Try to just print to the Adobe PDF printer. If the graphics are large, you may have to turn on display large images in the Acrobat preferences.

  • Project 2013 - Gantt Chart Printing/PDF issues

    Hello,
    I will try and explain this strange issue best I can - I am having some issues with creating a PDF from Gantt Chart view. The main problem here is when printing to PDF it seems to modify my Gantt at will as soon as i hit print preview. When I return to the
    Gantt I created it is very much the same as before; here are the issues:
    When Linking tasks or summary tasks (marked as milestones) to the other summary tasks (also marked as milestones) with an FS task dependency: The Gantt in Project displays an arrow linking the finish of the predecessor to the start of the linked summary
    task as would make sense. Once I hit print preview this arrow is now moved to point from the finish of the predecessor to the milestone located at the end of the linked summary task. A simple work around has been to not mark the linked summary task as a milestone
    (the predecessor can be, this doesn't seemmatter); the print preview then matches the Gantt I created.
    When hitting print preview the task list stays in tact but the Gantt Chart displays very unusual colors (Deadline arrows become vibrant green), components of the legend become invisible, and task bars become invisible as well. The problem is very sporadic
    and comes and goes as it pleases. 
    Any thoughts?
    Regards,
    Chris

    Gentlemen,
    I am working with Project 2013 - I have the latest service pack installed.
    I found another way to accomplish what i needed/wanted with the milestone - that is not my main issue here.
    I have seen other forum posts with the same issue regarding Phantom Gantt bars and strange colour issues when creating a PDF. I can send you screen shots if you'd like of the results. The problem comes and goes and nobody seems to have any solution for it.
    I just need my print preview to match what I have created in the project, and then for my PDF to match the print preview.
    Regards,
    Chris

  • Problem After writing the Jfree chart into pdf

    Hi All,
    I am writing the Jfreechart object with my company logo into JSP and and setting the content type as "application/pdf". I am getting the error as
    java.lang.IllegalStateException: getOutputStream() has already been called for this response.
    I have searched for it in the google as well as sun forums for so many hours and i implements so many suggested solutions but i am unable to remove the exception.
    The problem might be using response.getOutputStream() to get the output stream to in the response.
    But while debugging the code I observed that I am getting the error after complete execution of the code ie. after displaying the pdf.
    I am using JSF with JBoss portlets.
    Could any one help me in solving this problem as soon as possible..
    Thanks in advance.

    I am using the fallowing code to write into response. After execution of all the code and after displaying pdf its throughing the exception
    *OutputStream outStream = response.getOutputStream()*
    //To get the logo path from propeties file
    ResourceBundle resourceBundle = ResourceBundle.getBundle("imagepath");
                      String imagePath = resourceBundle.getString("imagepath");
                      Image image2 = Image.getInstance(imagePath);
                        image2.scaleToFit(100, 100);
                        PdfPTable pdfPTable =  new PdfPTable(2);
                        pdfPTable.getDefaultCell().setBorder(0);
                        PdfPCell cell = new PdfPCell(image2);
                        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                        cell.setBorder(0);
                        pdfPTable.addCell(cell);
                        pdfPTable.addCell("");
                      //get the Pdf writer object
                   PdfWriter     writer = PdfWriter.getInstance(document, outStream);
                       document.open();
                   document.add(pdfPTable);
                      PdfContentByte contentByte = writer.getDirectContent();
                      PdfTemplate template = contentByte.createTemplate(1200, 750);
                      Graphics2D graphics2d = template.createGraphics(600, 750, new DefaultFontMapper());
                      Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 540, 700);
                      jfreechart.draw(graphics2d, rectangle2d);
                      graphics2d.dispose();
                      contentByte.addTemplate(template, 50, 25);
                      //setOldchartObject(chartInfoBean);
                      System.out.println("This is before closing th edocument.");
                      document.close();

Maybe you are looking for