<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
>
<fx:Script>
<![CDATA[
import org.alivepdf.colors.RGBColor;
import org.alivepdf.display.Display;
import org.alivepdf.fonts.CoreFont;
import org.alivepdf.fonts.FontFamily;
import org.alivepdf.fonts.unicodefonts.ArialUnicodeMS;
import org.alivepdf.fonts.unicodefonts.CidInfo;
import org.alivepdf.layout.Layout;
import org.alivepdf.layout.Orientation;
import org.alivepdf.layout.Size;
import org.alivepdf.layout.Unit;
import org.alivepdf.pdf.UnicodePDF;
import org.alivepdf.saving.Method;
private var pdf:UnicodePDF;
public var helvBold:CoreFont = new CoreFont ( FontFamily.HELVETICA_BOLD );
public var helvBoldItalic:CoreFont = new CoreFont ( FontFamily.HELVETICA_BOLDOBLIQUE);
public var helv:CoreFont = new CoreFont ( FontFamily.HELVETICA);
private function createPDF(fileName:String = "alivePDFTest.pdf"):void {
//pdf = new PDF(Orientation.PORTRAIT, Unit.MM, true, Size.LETTER);
pdf = new UnicodePDF(Orientation.PORTRAIT, Unit.MM, true, Size.A4);
pdf.setDisplayMode(Display.FULL_PAGE, Layout.SINGLE_PAGE);
pdf.setFont(new ArialUnicodeMS(CidInfo.KOREAN));
pdf.addPage();
pdf.setDisplayMode (Display.FULL_PAGE, Layout.SINGLE_PAGE);
pdf.setAuthor("Some Author");
pdf.setCreator("Some creator");
pdf.setTitle(fileName);
pdf.setMargins(10,40,10,10);
var reallyLongText:String = "아기곰푸우 만세";
for (var i:int = 0;i < 5;i++) {
pdf.setLeftMargin(20);
pdf.textStyle(new RGBColor(0x000000),1);
pdf.setFont(new ArialUnicodeMS(CidInfo.KOREAN));
//pdf.setFont(helvBold, 18);
pdf.addMultiCell(180,10,"Title " + i,0,"L");
pdf.textStyle(new RGBColor(0x000000),1);
//pdf.setFont(helvBoldItalic,11);
pdf.setFont(new ArialUnicodeMS(CidInfo.KOREAN));
var text:String = "Subheader " + i;
pdf.addMultiCell(180,10,text,0,"L");
//Add a "spacer"
pdf.addMultiCell(160,5,'');
//Add Description
//pdf.setFont(helv,12);
pdf.setFont(new ArialUnicodeMS(CidInfo.KOREAN));
pdf.setLeftMargin(10);
pdf.addMultiCell(170, 6, reallyLongText,0,"L");
//Add a "spacer" inbetween groups of text
pdf.addMultiCell(160,10,'');
}
pdf.end();
var ba:ByteArray = pdf.save(Method.LOCAL);
var fileReference:FileReference = new FileReference();
fileReference.save(ba, fileName);
}
private function sparkBtn_clickHandler(event:MouseEvent):void {
this.createPDF("test.pdf");
}
]]>
</fx:Script>
<s:layout>
<s:HorizontalLayout />
</s:layout>
<s:VGroup id="sparkGroup" horizontalAlign="center" >
<s:Button id="sparkBtn" label="Create PDF using addMultiCell" click="sparkBtn_clickHandler(event)"/>
</s:VGroup>
</s:WindowedApplication>