apache-flexpdf-generationflash-builderportfolioalivepdf

The SDK Portfolio actually replaces the AlivePDF? How to create a .pdf file using this new library in Flash Builder?


The SDK Portfolio actually replaces the AlivePDF? How to create a .pdf file using this new library in Flash Builder?

I Flex time of the experiments that made using the AlivePDF component, unfortunately due to new Restriction of navigateToURL and sendToURL methods, this legacy component no longer works to generate the files.

From what I researched, the SDK Portfolio (within the Adobe) offers a more complete library for Acrobat platform, however, by integrating with Flash Builder 4.7, the simple file creation features that existed in AlivePDF are not found in the Portfolio (API or framework).

I will post here a simple example with AlivePDF and would like to know if there is corresponding to the Portfolio:

         import org.alivepdf.pdf.PDF;
         // ...
         var pdfTab: PDF PDF = new (Orientation.LANDSCAPE, Unit.MM, Size.A4);
         // ...
         pdfTab.addPage ();
         pdfTab.setFont (myfont.family, myfont.style, myfont.height);
         pdfTab.textStyle (mycolor.text);
         pdfTab.beginFill (mycolor.background);
         pdfTab.addText (text, xposition, yposition);
         pdfTab.endFill ();
         pdfTab.newLine (HEIGHT * 1.5);
         pdfTab.setDisplayMode (Display.FULL_WIDTH, Layout.ONE_COLUMN,
          PageMode.USE_THUMBS);
         pdfTab.save (Method.LOCAL, urlService, Download.INLINE, fileName
          + "& Ext = pdf & mime = application / pdf");

Solution

  • AlivePDF still works for me. You can use it with FileReference like this:

    var bytes:ByteArray = pdf.save(Method.LOCAL);
    saveData(bytes, fileName);
    
    public static function saveData(data:*, filename: String, parent: Sprite): Alert
    {
        function closeHandler(event: CloseEvent): void
        {
            if (event.detail == Alert.YES)
            {
                // due to security restrictions FileReference.save()
                // can only be invoked upon user interaction
                var fileRef: FileReference = new FileReference();
                fileRef.save(data, filename);
            }
        }        
        var alert: Alert = Alert.show(
            'Are you sure you want to save the file ' + filename + ' ?', 
            'Confirmation', Alert.YES | Alert.NO, parent, closeHandler);
        return alert;
    }