views:

399

answers:

2

hi friend, when i am showing some text it is going in 1 line only thats why whole text is not visible in pdf. if txt are more it should take automatically next line. please see code below

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

is any solution to show text in pdf, can we give font size also to our text ? thanks

+2  A: 

The addText doesn't wrap. Use writeText method instead.

From the docs:

The addText() method will put out text at a given coordinate. No word wrapping is done.

The linked page has code samples for both methods.

Amarghosh
A: 

var _pdf:PDF = new PDF(); var bytes:ByteArray = new ByteArray(); var displayObject:DisplayObject = Application.application.img; /* this is Application.application.img */

var bitmapDataBuffer:BitmapData = new BitmapData (displayObject.width, displayObject.height, false,0 );

bitmapDataBuffer.draw (displayObject, displayObject.transform.matrix );

bytes = PNGEncoder.encode ( bitmapDataBuffer, true );

var resize:Resize = new Resize( Mode.NONE, Position.RIGHT ); _pdf.addImageStream(bytes,ColorSpace.DEVICE_CMYK,resize,-3,10,0,0,0);

please provide me solution. addImaageStream is throwing Image format not supported for now this error

mahesh