0

我正在创建一个 ADOBE AIR 应用程序。

我的 Hbox 中有一些文本框和标签。我想生成一个 pdf 并且必须将该 hbox 添加到该 pdf 中。很多人都在谈论alivepdf。我搜索了,但没有看到演示..如果您有任何想法,请分享我,或建议我..谢谢

4

1 回答 1

0

I think it could help you.

This are my Air-application and the PDF-file.

enter image description here

enter image description here

//source

<?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.display.Display;
        import org.alivepdf.fonts.*;
        import org.alivepdf.layout.*;
        import org.alivepdf.pages.Page;
        import org.alivepdf.pdf.PDF;
        import org.alivepdf.saving.Method;

        protected function onBtnGeneratePDF(event:MouseEvent):void
        {
            var pdf:PDF = new PDF( Orientation.PORTRAIT, Unit.MM, Size.A4 ); 
            pdf.setDisplayMode( Display.FULL_PAGE, Layout.SINGLE_PAGE );

            var newPage:Page = new Page ( Orientation.PORTRAIT, Unit.MM, Size.A4 );
            pdf.addPage( newPage );

            pdf.addText("This is my PDF from AdobeFlex", 5, 10);

            pdf.addImage(hgMain, null, 5, 10);

            var fs:FileStream = new FileStream();  
            var file:File = File.desktopDirectory.resolvePath("testPage.pdf");   
            fs.open(file, FileMode.WRITE);   
            var bytes:ByteArray = pdf.save(Method.LOCAL);   
            fs.writeBytes(bytes);   
            fs.close();
        }
    ]]>
</fx:Script>

<s:HGroup id="hgMain" x="10" y="10" width="439" height="161">
    <s:Label text="MyLabel_01"/>
    <s:TextArea width="133" height="116" contentBackgroundColor="#E6B3B3" fontStyle="italic"
                text="MyTextArea"/>
    <s:Label fontWeight="bold" text="MyLabel_02"/>
    <s:TextArea width="127" height="69" contentBackgroundColor="#CED4F2" fontSize="15"
                fontWeight="bold" text="MyTextArea"/>
</s:HGroup>
<s:Button x="10" y="179" label="Generate PDF" click="onBtnGeneratePDF(event)"/>

</s:WindowedApplication>
于 2013-02-01T19:37:03.103 回答