1 11 package org.eclipse.birt.chart.examples.api.pdf; 12 13 import org.eclipse.birt.chart.device.IDeviceRenderer; 14 import org.eclipse.birt.chart.device.pdf.PDFRendererImpl; 15 import org.eclipse.birt.chart.exception.ChartException; 16 import org.eclipse.birt.chart.factory.GeneratedChartState; 17 import org.eclipse.birt.chart.factory.Generator; 18 import org.eclipse.birt.chart.factory.RunTimeContext; 19 import org.eclipse.birt.chart.model.Chart; 20 import org.eclipse.birt.chart.model.attribute.Bounds; 21 import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl; 22 23 import com.ibm.icu.util.ULocale; 24 25 29 public class PDFChartGenerator { 30 31 34 public static void generateChart(){ 35 System.setProperty("STANDALONE", "true"); 38 Chart cm = ChartModels.createHSChart( ); 40 41 IDeviceRenderer idr = new PDFRendererImpl(); 43 44 try 45 { 46 RunTimeContext rtc = new RunTimeContext( ); 47 rtc.setULocale( ULocale.getDefault( ) ); 48 49 final Generator gr = Generator.instance( ); 50 GeneratedChartState gcs = null; 51 Bounds bo = BoundsImpl.create( 0, 0, 450, 300 ); 53 gcs = gr.build( idr.getDisplayServer( ), cm, bo, null, rtc, null ); 54 55 idr.setProperty( IDeviceRenderer.FILE_IDENTIFIER, "test.pdf" ); 58 gr.render( idr, gcs ); 60 } 61 catch ( ChartException ce ) 62 { 63 ce.printStackTrace( ); 64 } 65 } 66 67 public static final void main(String argv[]){ 68 generateChart(); 69 } 70 } 71 | Popular Tags |