AlivePDF not writing out text using addText(). Nothign I'm trying is working. What am I missing?

265 views Asked by At

No matter what I try I can't write anything to a PDF that can be seen, although the text is there when viewing the resultant PDF in Notepad. What am I not doing? Here's a code snippet. the variable tf is a TextField defined in the class. This works in the SWF, just not with PDF.

    private function onButtonClick(e:MouseEvent):void {
        tf.text = "Hey, you clicked the button!";

        myPDF = new PDF(Orientation.PORTRAIT, Unit.INCHES, Size.A4);
        myPDF.setDisplayMode(Display.FULL_PAGE, Layout.SINGLE_PAGE)
        myPDF.addPage();
        myPDF.addText(tf.text, 20, 20 );

        var filename:String = "Test-file.pdf";
        var f:FileStream = new FileStream();
        var file:File = File.userDirectory.resolvePath(filename);
        f.open(file, FileMode.WRITE);
        var bytes:ByteArray = myPDF.save(Method.LOCAL);
        f.writeBytes(bytes);
        f.close();
    }
0

There are 0 answers