0

I am trying to create PDF file using flex.

There are some problem which i am facing..

when i have less text to display it's working fine. but when there are lots of text which have to display it's overlap.

is there any PDF component which is expand according to the display text.

Thanks in advance

Nidhi
  • 755
  • 3
  • 11
  • 25

2 Answers2

1

Enjoy creating .pdf file using this code

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.*; 

private var pdf:PDF;  
private var file:File; 
[Embed( source="bg.jpg", mimeType="application/octet-stream" )]  
private var pngBytes:Class; 

public function generate ():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.setFont(FontFamily.ARIAL , Style.NORMAL, 12);
    pdf.addText("This is a sample text",5,15);
    pdf.drawCircle(25,35,15);
    pdf.addPage();
    pdf.addImageStream( new pngBytes() as ByteArray );
    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();
}
Jason Sturges
  • 15,855
  • 14
  • 59
  • 80
Attiq Rao
  • 51
  • 3
0

We can use "AlivePDF" to generate PDF from Flex.

AlivePDF is a client side AS3 PDF generation library for Adobe Flash, Flex and AIR. It is a Open source library.

Library File and Documentation

http://code.google.com/p/alivepdf/
http://code.google.com/p/alivepdf/downloads/list

Reference

http://alivepdf.bytearray.org/

Ganesh Gandhi K
  • 187
  • 1
  • 4
  • I am using same process..but whenever my text content is more than a page. i am not able to add page exactly when one page text is finish and add another page. – Nidhi Sep 26 '11 at 07:02
  • You can try this code : var myPDF:PDF = new PDF( Orientation.LANDSCAPE, Unit.MM, Size.A4); myPDF.setDisplayMode ( Display.DEFAULT); myPDF.addPage(); myPDF.setMargins(10,10,10,10); – Ganesh Gandhi K Oct 11 '11 at 17:55