3

I use Yahoo User Interface Library 3 to generate some charts. http://developer.yahoo.com/yui/3/

In my browser (FF,Chrome) it generates SVG structure with a JS include.

I would like to place these charts in a PDF, each PDF file will have it's own chart. I have root access to the server, so I can install tools to help me.

What possibilities I have.

Pentium10
  • 204,586
  • 122
  • 423
  • 502

3 Answers3

1

There is also the option to use Highcharts/Highstocks, which also have an export server, where it is possible to export the chart as PNG, SVG or even PDF. I use mPDF to generate PDFs, and with cURL I get my charts from the Highchart export server and embed the generated SVG directly into the PDF

UPDATE:

Check the export example on highcharts, if you build your request with the options given, the export server returns the image. So in your code you just have to get the content. Try this request (i made it easier to read)

    http://export.highcharts.com/?content=options&options=
    {
      xAxis: { 
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
      },
        series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]}] 
    };
    &type=image/png
    &width=
    &scale=
    &constr=Chart
    &callback=function(chart) {chart.renderer.arc(200, 150, 100, 50, -Math.PI, 0).attr({ fill : '%23FCFFC5', stroke : 'black', 'stroke-width' : 1}).add(); }  
Asped
  • 3,083
  • 4
  • 31
  • 52
  • @atjoshi Use the Ask Question button to ask a followup question if you have one. You can always add a link in it back to this question/answer. – Robert Longson Jul 02 '14 at 12:47
0

iText will let you draw via Java's Graphics2D interface to a PDF. There are at least two Free SVG->Graphics2D Java libs out there.

  • Batique
  • Some other thing whose name I can't remember.

I don't know of any SVG->PDF converters that run in PHP.

Mark Storer
  • 15,672
  • 3
  • 42
  • 80
-1

Check out the fPDF library. It is capable of generating PDFs, which you can then store, or you could generate them on the fly, on demand.

http://www.fpdf.org/

Chris Baker
  • 49,926
  • 12
  • 96
  • 115
  • 1
    How can I add a SVG chart to the PDF built with the YUI3? – Pentium10 Feb 14 '11 at 16:57
  • Refer to this answer: http://stackoverflow.com/questions/923885/capture-html-canvas-as-gif-jpg-png-pdf/3514404#3514404, you will have to 1) render the chart using YUI, 2) convert the chart to an image and get it on your sever, 3) use fPDF to create the PDF file and place the image within. I guess it goes without saying: this isn't going to be easy. :) – Chris Baker Feb 14 '11 at 17:04