analiaf21 / alivepdf

Automatically exported from code.google.com/p/alivepdf
0 stars 0 forks source link

alivepdf + air + javascript: can't addImage #239

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm trying to add an image to a pdf (I'm working with air and javascript)
Here is the code:

function loaderCompleteHandler(e) {
    var PDF = new alivePDF.PDF(alivePDF.Orientation.PORTRAIT,
alivePDF.Unit.MM, alivePDF.Size.A4);
    PDF.setMargins(8, 8, 8, 8);

    PDF.addPage();

    var loader = e.target;
    PDF.setXY(0, 0);
    PDF.addImage(loader.content, alivePDF.Layout.FIT_TO_PAGE, 0, 0, 190,
27, 0, 1, false, alivePDF.Images.ImageFormat.JPG, 100);

    PDF.setFontSize(14);
    PDF.setXY(0, 40);
    PDF.addMultiCell(150, 4, "My PDF title", 1, 'C');

    var dump = PDF.save(alivePDF.Method.LOCAL);
    try {
        var f = air.File.applicationStorageDirectory.resolvePath("Test.pdf");
        var fs = new air.FileStream();
        fs.open(f, air.FileMode.WRITE);
        fs.writeUTFBytes(dump);
        fs.close(); 
    } catch (e) {
            alert("There was an error writing the PDF file.");
    }

    f.openWithDefaultApplication();
}

var loader = new air.Loader();
loader.contentLoaderInfo.addEventListener(air.Event.COMPLETE,
loaderCompleteHandler);
var request = new air.URLRequest("app:/ui/images/header.jpg");
loader.load(request);

What is the expected output? What do you see instead?
I can't see my image on the pdf. The text is visible.

What version of the product are you using? On what operating system?
Air beta 2 on Ubuntu Linux 9.10

Thanks for any help!

Original issue reported on code.google.com by antonino...@gmail.com on 2 May 2010 at 7:29