2013-01-31 7 views
0

ADOBE AIR 응용 프로그램을 만들고 있습니다.ADOBE AIR의 PDF 파일

내 Hbox에 텍스트 상자와 레이블이 있습니다. 나는 pdf를 생성하고 그 hbox를 그 pdf에 추가해야한다. 사람들의 대략적인 말은 alivepdf이다. 검색했지만 데모를 보지 못했습니다 .. 아이디어가 있으면 제게 나에게 조언 해주세요. 고마워요

+1

참조 // 소스 http://blog.unthinkmedia.com/2008/09/05/exporting-pdfs-in-flex-using- alivepdf/데모. 플래시에서 PDF를 생성하는 것은 매우 쉽지만,보기가 불가능합니다. –

+0

@ Apocalyptic0n3 PDF를 보는 것이 실제로 불가능합니까? 최근에 사용자가 PDF를 볼 수있는 기능이있는 앱에 관련없는 작업을했습니다. PDF 뷰어는 상당히 멋진 기능을 갖춘 구성 요소였습니다. 아마도 AIR 응용 프로그램에서 사용 되었기 때문에 가능했을 것입니다. –

+1

@ Sun Di. 어떻게했는지 말해 줄 수 있니? StageWebView (iOS 전용) 또는 HTMLLoader (데스크톱 만, 성능이 좋지 않아 Acrobat이 필요함)를 사용하지 않은 모든 경로를 통해 성공적으로 시도했습니다. 가능합니다. 플렉스 페이퍼처럼 SWF를 SWF로 변환하지 않는 한 네이티브 응용 프로그램을 사용해야합니다. –

답변

0

도움이 될 것 같아요.

이것은 Air 응용 프로그램 및 PDF 파일입니다.

enter image description here

enter image description here

<?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>