Testing the HellowWorld in AIR - problem with hashMap and flash.utils.IExternalizable

106 views
Skip to first unread message

Murrah

unread,
Jan 3, 2011, 8:41:03 PM1/3/11
to purepdf-discuss
Hi,

I am attempting to use purePDF in my AIR app. The app is a JavaScript
app, not a Flex app. However, in AIR it is possible to access
ActionScript classes from the HTML/JS app and I have tested that
successfully with small AS classes. I should state that my AS/Flex
knowledge is almost non existant! And I am learning fast!

What I have done is:

1. I added the following method to the HelloWorld class:
public function doMyPdf() : void {
execute();
}
since it seems I cant call the execute method since it is
protected.

2. I compiled the HelloWorld.as example using compc and including the
relevant swc files. So far so good - compiles ok.

3. I extracted the library.swf file from the swc file created in step
2 and renamed it mypdf.swf

4. In my AIR app I included the file: <script src="lib/mypdf.swf"
type="application/x-shockwave-flash"></script>

5. Finally, I execute it via JS:
var lib = new window.runtime.HelloWorld();
lib.doMyPdf();

And it runs. The debug window displays the following messages which
are being generated by the swf file so it is clear that it is starting
to run. However, I am getting the error below:

setting up as3_jpeg_wrapper library

Welcome to purepdf 0.74.20100527

Error: Error #2173: Unable to read object in stream. The class
it.sephiroth.utils::HashMap does not implement
flash.utils.IExternalizable but is aliased to an externalizable class.

When I visit the HashMap source code I see that
flash.utils.IExternalizable is imported as I expected.

So, what can this error mean?

If I can get this working I intend to make and share a wrapper class
for purePDF so other JS AIR developers can finally produce client side
PDF files! Yes! (I did a similar thing for iText in ColdFusion, but
havent released it yet - still working on it)

Thanks for your help,
Murray

Alessandro Crugnola

unread,
Jan 4, 2011, 2:46:06 AM1/4/11
to purepdf...@googlegroups.com
Did you read this post?

sometimes when you compile external swc projects with compc which will be dynamically loaded you can have those kind of problems. that's why usually i prefer to compile them directly in swf and no in swc.

Murrah

unread,
Jan 4, 2011, 6:09:58 AM1/4/11
to purepdf-discuss
Thanks Alessandro.

Yes, I did read that post and tried adding the suggested code to both
classes (HelloWorld and DefaultBasicExample) but it made no
difference. I also needed to import it.sephiroth.utils.HashMap because
the compiler choked on the private static var _link:Array =
[it.sephiroth.utils.HashMap]; line if I didnt. ie

import it.sephiroth.utils.HashMap;

public class HelloWorld extends DefaultBasicExample
{
private static var _link:Array = [it.sephiroth.utils.HashMap];
...

}

I also switched to using the mxmlc compiler as you suggested (but it
still hasnt solved the problem). ie

amxmlc -library-path+=pdflib HelloWorld.as

The folder pdflib contains:
as3_jpeg_wrapper.swc
as3commons-logging-1.1.swc
as3corelib.swc
purePDF.swc
purePDFont.swc

By process of elimination I find that the problem is with the
document.add() method. eg
var paragraph: Paragraph = new Paragraph("My line");
document.add(paragraph);

If I comment out the document.add(paragraph); then the process runs to
the end (and displays the "Document has no pages" error message as you
would expect since that is the only content I am adding). ie

setting up as3_jpeg_wrapper library
Welcome to purepdf 0.74.20100527
Error: The document has no pages


Thanks again for your help.
Regards,
Murray


On Jan 4, 6:46 pm, Alessandro Crugnola <alessandro.crugn...@gmail.com>
wrote:
> Did you read this post?http://www.flashsecrets.com/2009/04/argumenterror-error-2173-unable-t...

nino ekambi

unread,
Jan 6, 2011, 6:22:47 PM1/6/11
to purepdf...@googlegroups.com
Could you solve the problem ?
Regards,
Alain

2011/1/4 Murrah <mur...@murrah.com.au>

Murrah

unread,
Jan 7, 2011, 4:28:53 PM1/7/11
to purepdf-discuss
No, I gave up. No idea. I shifted to AlivePDF instead for now. I might
revisit this at some time. I know iText is a great package but maybe
AlivePDF will suffice for my needs.

Alain, I know you know about this post of my exploring this idea, but
for others:

http://murrayhopkins.wordpress.com/2011/01/07/using-alivepdf-to-print-from-air-javascript-via-actionscript3-part-1/

Cheers,
Murray

nino ekambi

unread,
Jan 7, 2011, 5:17:14 PM1/7/11
to purepdf...@googlegroups.com
Well i  founded a solution for the problem just can remenber  exactly  where that was cuz  the error is realy hidden though.
I ll hav a look at  it  and let u know. If you want to write  a  JS wrapper around AlivePDF maybe  you can look  in the source code  of Gwt4Air 1.1. I hav  a module for AlivePDF there.

Regards,

Alain

2011/1/7 Murrah <mur...@murrah.com.au>

Murrah

unread,
Jan 7, 2011, 5:29:09 PM1/7/11
to purepdf-discuss
Thanks Alain! I was thinking f doing that since I will proabably need
to replicate much of the API !

Cheers,
Murray

On Jan 8, 9:17 am, nino ekambi <jazzmatad...@googlemail.com> wrote:
> Well i  founded a solution for the problem just can remenber  exactly  where
> that was cuz  the error is realy hidden though.
> I ll hav a look at  it  and let u know. If you want to write  a  JS wrapper
> around AlivePDF maybe  you can look  in the source code  of Gwt4Air 1.1. I
> hav  a module for AlivePDF there.
>
> Regards,
>
> Alain
>
> 2011/1/7 Murrah <mur...@murrah.com.au>
>
> > No, I gave up. No idea. I shifted to AlivePDF instead for now. I might
> > revisit this at some time. I know iText is a great package but maybe
> > AlivePDF will suffice for my needs.
>
> > Alain, I know you know about this post of my exploring this idea, but
> > for others:
>
> >http://murrayhopkins.wordpress.com/2011/01/07/using-alivepdf-to-print...

nino ekambi

unread,
Jan 7, 2011, 6:14:32 PM1/7/11
to purepdf...@googlegroups.com
You welcome :).
Yeah you will hav to export about 90% of the API to JS, And this is a lot of work :). but the end result is always  a pleasure :)
The other thing is that  the user of  you library will probably hav to download the  hole JS library even if the  are just using a small part of it.
That s the reason why i decided to go the  Java and GWT  way. Since GWT just compile the JS you are actually using in your code.

If you hav any question feel free to  contact me 
Reply all
Reply to author
Forward
0 new messages