0
votes

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

2
Do you want to create a PDF? Or display one? Can you share any code? - JeffryHouser
I want to create pdf,But Text will be display in pdf file - Nidhi
How is your PDF created? Which library do you use? Is it created server-side? - Kodiak
i am using AlivePDF.swc for desktop application. i did not use any server side technology. - Nidhi

2 Answers

1
votes

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();
}
0
votes

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/