Flash Player 10, will be THE player for handling local files.
Here is a tiny demo of the new FileReference feature added in Astro.
Browse for any images (PNG or JPG) and save the PDF to any location. The images are directly embedded into the PDF with no "server upload trick" to access the binary image stream.
The PDF is generated 100% client, with no server involved. As I told you the other day, the create.php script is no longer used here as Astro allows us to output the file with a save-as dialog box
Warning : Flash Player 10 required
Alpha channel PNG images are not supported for now. I will add this feature later this week
When the file is selected and loaded the onFileLoaded function is executed. The addImageStream allows us to inject the image the image stream into the PDF :
{
myPDF.addPage ();
myPDF.addImageStream ( evt.target.data, 0, 0, 0, 0, 1, ResizeMode.RESIZE_PAGE );
}
When the generate button is clicked, we just call the save method and pass the PDF bytes :
{
saving.save ( myPDF.save ( Method.LOCAL ), "generated.pdf" );
}
Easy, isn't it ?
Comments 30
Hi Thibault
I’m really excited at how quickly things are developing this week.
It would be great if you could add a download for a basic starter / template file for flash to the download list, like you had in the first few releases. The last .fla file I can see is in 0.1.3 which doesn’t work any more. Just errors and flashing buttons. I’m struggling at the moment to convert create something that anything to work in the latest versions.
Thanks
Posted 28 May 2008 at 10:11 pm ¶David
Hi David,
That’s true, I totally forgot to update the FLA file in the downloads. I will include some starting templates in the next release so that everybody can discover the different features and how to use them.
kind regards,
Thibault
Posted 28 May 2008 at 10:55 pm ¶hi, dear Hi Thibault,it’s nice to see your new demo.
I made a mistake for the last two posts,really sorry.
I want to make a screen recorder by flex/flash, that means record the screen as video and then save both in the local file system and the server end ,would you please show me the way or the possibility ?
thank you very much !
Posted 29 May 2008 at 3:38 am ¶Cool !! Thanks Thibault.
Posted 29 May 2008 at 9:16 am ¶Bravo Thibault !
Posted 30 May 2008 at 6:27 am ¶Et c’est vrai qu’elle est bien utile cette nouvelle feature save dans File Reference:)
Very impressive!
Posted 02 Jun 2008 at 6:18 am ¶The current beta of flash player 10 has a bug.
It can’t replace file on local disk.
More details on my article.
http://www.tan66.com/flash-player-10-filereference-save-cant-overwrite-local-file-bug/
It’s abviously this ‘generate pdf’ shows the same bug.
Did anyone else encounter it?
Hi efish,
Yes, this is a very annoying bug. I submitted it.
This should be fixed before the final release of Astro.
kind regards,
Thibault
Posted 02 Jun 2008 at 9:28 am ¶It’s really a good news! It’s a proof that Adobe is in the the good move.
Posted 02 Jun 2008 at 9:51 am ¶This example is cool, because I have been looking for solution where I could download pdf from pure flex application, without the need to send to server. However, I have a question regarding your sample code, where is the “saving” variable comes from in the line “saving.save ( myPDF.save ( Method.LOCAL ), “generated.pdf” );” ?
Posted 20 Jun 2008 at 7:59 pm ¶Sorry, ignore my last post, I didn’t read the article carefully. It’s the FileReference class with save() call, however, when I use the newer flex sdk and flash 10 library, it has a error “access undefined property method”.
Posted 20 Jun 2008 at 11:52 pm ¶Great feature from Adobe but:
1) I tried to use a Loader to get an image, AVM1, … before to save.
It raise a security error #2176.
2) Method.REMOTE seems to fail with FP10 when you insert an image into the PDF. The raw posted seems to be corrupted (stream image not closed, no more trailer, etc…)
Probably FP10 beta bugs but is there someone who encounter this?…
Thanks
Posted 25 Jun 2008 at 1:05 pm ¶Leo
Hi,
Posted 14 Jul 2008 at 1:40 pm ¶I can chose an image when I click on “Browse Images” but nothing happens when I click on “Generate PDF”. I have installed Flash Player 10. Anybody with the same problem?
Greets Isa
It seems not work! My flash player is flashplayer10_install_plugin_081108. What should I do to make it work?
Posted 13 Aug 2008 at 4:17 am ¶Hi Joeshae,
This SWF had to be recompiled for the latest FP10 Beta, can you clean your cache and reload the app and let me know if it works well ?
cheers,
Thibault
Posted 13 Aug 2008 at 10:18 am ¶It works!
Posted 13 Aug 2008 at 7:30 pm ¶Thank you very much for the great job!
Salut, Thibault!
I’d been hunting for a Flash-compatible client-side pdf generator for a good 5 years now. So I was thrilled to find alivepdf.
I’m still hoping for a basic .fla demo as requested by the first poster on this thread.
Any progress?
Merci bien,
pm
Posted 21 Aug 2008 at 3:07 pm ¶It would be great to be able to open up an existing PDF, and at the very least, insert pages.. is this something that is on the horizon by any chance?
Posted 21 Aug 2008 at 9:07 pm ¶Hi Stuart,
It is not planned for the moment, but right after the 0.1.5 release I will start working on a PDF Reader class which will be able to bring such features.
Hope you will like it
best,
Thibault
Posted 22 Aug 2008 at 10:45 am ¶Hello.
As for me, a problem same as Isa occurs.
>I can chose an image when I click on “Browse Images” but nothing happens when I click on “Generate PDF.”
When I use Vista+InternetExplorer7(protected mode), a problem occurs.
When I use Vista+Firefox or Xp, a problem does not occur.
Probably I think whether protected mode of InternetExplorer7 is a cause.
My English is sorry in unskillfulness.
Posted 26 Aug 2008 at 8:50 am ¶When my sentence comes precisely, I am glad.
Hi Kj,
Make sure you have the latest Flash Player 10 release and try again. You can download it here :
http://labs.adobe.com/downloads/flashplayer10.html
let me know !
best,
Thibault
Posted 26 Aug 2008 at 8:56 am ¶Hi Thibault
I tried some FlashPlayer10.
It is 2 of the next that I tried.
(1) flashplayer10_install_activex_081108.exe(The latest edition)
(2) FlashPlayer10.0.0.576(DebugVersion) which is attached to flex_sdk_3.2.0.2944.zip
These results become same as the result that they wrote a while ago.
Posted 26 Aug 2008 at 10:05 am ¶These results become same as the result that they wrote a while ago.
Posted 26 Aug 2008 at 3:46 pm ¶↓
These results become same as the result that I wrote a while ago.
I’m looking forward to the pdf reader class you mentioned
it would be great to be able to add notes and highlight text and then save the pdf file.
Posted 08 Sep 2008 at 7:08 pm ¶I have a problem I can’t use the code like this in fp10…why?
private var myPDF:PDF;
public function generatePDF(pEvt:MouseEvent ):void{
myPDF= new PDF(Orientation.PORTRAIT, Unit.MM, Size.A4);
myPDF.addPage();
//saving
myPDF.save( Method.LOCAL , “generated.pdf” );
}
it looks like nothing and it isn’t saving…would you give me a hand?
Posted 04 Nov 2008 at 7:34 pm ¶Hey, I am still a bit confused about what the ’saving.save’ property and method is. Is this some sort of Flex or Air only method/object.
“This example is cool, because I have been looking for solution where I could download pdf from pure flex application, without the need to send to server. However, I have a question regarding your sample code, where is the ?saving? variable comes from in the line ?saving.save ( myPDF.save ( Method.LOCAL ), ?generated.pdf? );? ?”
Posted 02 Jul 2009 at 9:24 pm ¶Greetings:
I would like to just upload the PDF document to the server after it is complete. I dont need it displayed in its own window like the default behavior is. Do I just need to extend the class, call finish() and then send the raw byte array to upload like a standard file?
Posted 19 Aug 2009 at 7:03 pm ¶Also, is there a method to clear out / make empty all the internal stores of the PDF class? Dont want to kill on the memory on large PDF documents that once it is done, I can flush out the document to its initial state.
thanks.
Posted 20 Aug 2009 at 1:40 am ¶Having had the same trouble as many of the posters here’s what I found:
- YES this does work with flash (i.e. from browser not in AIR)
- YES this does work with CS3 but you DO need flash player 10
- NO I have no clue what the saving.save syntax is all about, but something like this works:
var f:FileReference = new FileReference();
var bytes:ByteArray = this.pdf.save(Method.LOCAL);
f.save(bytes, “drawing.pdf”);
- YES you do get an error in flash UNLESS you compile specifically for flashplayer 10
- In Flex Builder you can use Project Properties >> Flex Compiler, and set “Required Flash Player Version” to 10.0.00
- if you use the SDK you can either:
> add the option “-target-player=10.0.00″ to the mxmlc options line OR:
> modify the flex_sdk_3/frameworks/flex-config.xml file to change that same option
Note that the compiler option trumps the config file.
then… you may get another error: in flash this function is only allowed for an interactively initiated function. In other words if you have this save() as part of a file completion handler it will not work since it is called from a non interactively invoked method. It will work from, for example, a mouseclick handler.
Posted 03 Sep 2009 at 12:57 am ¶Is the full source available for this example?
Merci d’avance!
Posted 20 Jan 2010 at 1:35 pm ¶How can you use
f.save(bytes, “drawing.pdf”);
I dont fine anything like that for FileReference class.
Kindly please help.
Posted 24 Jun 2010 at 8:34 am ¶Trackbacks & Pingbacks 1
[...] DEMO [...]
Post a Comment