Reputation: 795
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
Upvotes: 0
Views: 6922
Reputation: 51
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();
}
Upvotes: 1
Reputation: 187
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.
http://code.google.com/p/alivepdf/
http://code.google.com/p/alivepdf/downloads/list
http://alivepdf.bytearray.org/
Upvotes: 0