2010-02-15 5 views
1

일부 텍스트가 1 행만 표시 될 때전체 텍스트가 pdf에 표시되지 않는 이유는 무엇입니까? txt가 더 많은 경우 자동으로 다음 줄을 가져와야합니다. 우리는 글꼴 크기는 우리의 텍스트도 줄 수AlivePDF의 단어 랩

<?xml version="1.0" encoding="utf-8"?> 
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" 
layout="horizontal" > 
    <mx:Script> 
     <![CDATA[ 
      import org.alivepdf.pdf.PDF; 
      import org.alivepdf.saving.Method; 
      import org.alivepdf.fonts.*; 
      import org.alivepdf.pages.Page; 
      import org.alivepdf.display.Display; 
      import org.alivepdf.layout.*; 

    [Bindable] private var message:String; 
    private var pdf:PDF; 
      private var file:File; 
      private function submitData():void { 
      message+='The Text Value is ' + t1.text + ' The second 
text value is' + t2.text + 
         'it is testing message it is testing message it is 
testing message '+ 
         'The Text Value is ' + t1.text + ' The second text value 
is' + t2.text+ 
         'it is testing message it is testing message it is 
testing message '; 
      } 

      public function generate():void 
      { 
       submitData(); 

      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.setFont(IFont,12); 
       pdf.addText(message,5,15); 
       pdf.addPage(); 
       var fs:FileStream = new FileStream(); 
       file = 
File.desktopDirectory.resolvePath("testPage.pdf"); 
       fs.open(file, FileMode.WRITE); 
       var bytes:ByteArray = pdf.save(Method.LOCAL); 
           fs.writeBytes(bytes); 
       fs.close(); 
      } 
     ]]> 
    </mx:Script> 

    <mx:TextInput id="t1" text="txt111" /> 
    <mx:TextInput id="t2" text="txt222"/> 
    <mx:Button click="generate()" label="Generate PDF" 
horizontalCenter="0" verticalCenter="0"/> 

    </mx:WindowedApplication> 

아래 코드에서는 PDF 파일로 텍스트를 표시 할 수있는 솔루션을 참조하십시오? 감사합니다.

답변

2

addText은 포장하지 않습니다. 대신 writeText 메서드를 사용하십시오. docs에서

:

addText() 방법은 좌표 주어진에 텍스트를 넣어 것입니다. 단어 줄 바꿈이 수행되지 않습니다..

링크 된 페이지에는 두 가지 방법에 대한 코드 샘플이 있습니다.