Printing in Adobe AIR - Standalone PDF Generation
Asked Answered
A

4

6

Is it possible to generate PDF Documents in an Adobe AIR application without resorting to a round trip web service for generating the PDF? I've looked at the initial Flex Reports on GoogleCode but it requires a round trip for generating the actual PDF.

Given that AIR is supposed to be the Desktop end for RIAs is there a way to accomplish this? I suspect I am overlooking something but my searches through the documentation don't reveal too much and given the target for AIR I can't believe that it's just something they didn't include.

Angelynanger answered 10/9, 2008 at 3:18 Comment(0)
C
7

There's AlivePDF, which is a PDF generation library for ActionScript that should work, it was made just for the situation you describe.

Cupellation answered 10/9, 2008 at 10:9 Comment(0)
D
1

Just added a Adobe Air + Javascript + AlivePDF demo:

This demo doesn't require flex and is pretty straight forward.

http://www.drybydesign.com/2010/02/26/adobe-air-alivepdf-without-flex/

Dang answered 26/2, 2010 at 22:32 Comment(1)
Hi.. I am also looking for pdf option, I have to generate a long pdf of about 15 pages, in which I have to add number of mxml components on resulting pdf, I am trying to use alive pdf for the same, but my page is having vertical scroll and hidden part getting excluded from the pdf and also I am not getting good quality pdf I was trying to open your demo but link not working, it's been a long time..if you can help me a bit, then pl. Thanks in advance.Fovea
N
0

One of the other teams where I work is working on a Flex-based drawing application and they were totally surprised that AIR / Flex does not have PDF authoring built-in. They ended up rolling their own simple PDF creator based on the PDF specification.

Normalie answered 10/9, 2008 at 3:50 Comment(0)
F
0

Yes it is very easy to create PDF using AlivePDF, here is the sample code, first method create a pdf and second method save the pdf on disk and return the path, feel free to ask any question.

public function createFlexPdf() : String
{
    pdf = new PDF();
    pdf.setDisplayMode (Display.FULL_WIDTH,Layout.ONE_COLUMN,Mode.FIT_TO_PAGE,0.96);
    pdf.setViewerPreferences(ToolBar.SHOW,MenuBar.HIDE,WindowUI.SHOW,FitWindow.RESIZED,CenterWindow.CENTERED);
    pdf.addPage();
    var myFontStyle:IFont = new CoreFont ( FontFamily.COURIER );
    pdf.setFont(myFontStyle,10);
        pdf.addText('Kamran Aslam',10,20);//String, X-Coord, Y-Coord 
    return savePDF();
}
private function savePDF():String
{
    var fileStream:FileStream = new FileStream();
    var file:File = File.createTempDirectory();
    file = file.resolvePath("temp.pdf");
    fileStream.open(file, FileMode.WRITE);
    var bytes:ByteArray = pdf.save(Method.LOCAL);
    fileStream.writeBytes(bytes);
    fileStream.close();
    return file.url;
}
Footloose answered 7/1, 2012 at 2:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.