I am trying to use AlivePDF to save a chart into a .pdf file. However, when I try to save my chart, it ends up clipping half of the chart in the pdf so it isn't even fully visible. It seems that the screencapture that AlivePDF took to generate my pdf was too small.
I am trying to get a chart from a sample to work with sample code for using alivepdf that I picked off the web.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import org.alivepdf.pages.Page;
import org.alivepdf.layout.Resize;
import org.alivepdf.pdf.PDF;
import org.alivepdf.layout.Orientation;
import org.alivepdf.layout.Size;
import org.alivepdf.layout.Unit;
import org.alivepdf.display.Display;
import org.alivepdf.saving.Method;
import org.alivepdf.fonts.FontFamily;
import org.alivepdf.fonts.Style;
import org.alivepdf.colors.RGBColor;
private var myPDF:PDF;
function generatePDF ( e:MouseEvent )
{
myPDF = new PDF ( Orientation.LANDSCAPE, Unit.MM, Size.A4 );
myPDF.setDisplayMode ( Display.FULL_WIDTH );
myPDF.addPage();
myPDF.addImage (myChart);
myPDF.save( Method.REMOTE, "http://alivepdf.bytearray.org/wp-content/demos/create.php", "drawing.pdf");
}
]]>
</mx:Script>
<mx:XML xmlns="" id="myData">
<items>
<item year="1960" rain="92" />
<item year="1961" rain="192" />
<item year="1962" rain="32" />
<item year="1963" rain="52" />
<item year="1964" rain="112" />
<item year="1965" rain="52" />
<item year="1966" rain="88" />
<item year="1967" rain="52" />
<item year="1968" rain="66" 开发者_JAVA百科/>
<item year="1969" rain="39" />
<item year="1970" rain="192" />
<item year="1971" rain="182" />
<item year="1972" rain="177" />
<item year="1973" rain="179" />
<item year="1974" rain="198" />
<item year="1975" rain="207" />
</items>
</mx:XML>
<mx:XMLListCollection id="rainData" source="{myData.children()}" />
<mx:Button horizontalCenter="0" click="generatePDF(event)" label="Generate PDF" id="generate_btn" />
<mx:BarChart id="myChart"
width="100%" height="100%"
dataProvider="{rainData}">
<mx:verticalAxis>
<mx:CategoryAxis id="yearAxis" categoryField="@year" />
</mx:verticalAxis>
<mx:horizontalAxis>
<mx:LinearAxis id="linAxis" minimum="0" maximum="200" />
</mx:horizontalAxis>
<mx:series>
<mx:BarSeries yField="@year" xField="@rain" displayName="Rain"/>
</mx:series>
</mx:BarChart>
</mx:Application>
Any help on getting my entire chart to show in the .pdf file would be great. It's annoying that I can't figure out something this simple.
Instead of:
myPDF.addImage (myChart);
try:
myPDF.addImage(myChart,null,0,0,myPDF.getMargins().width,myPDF.getMargins().height);
-Deepak
精彩评论