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)
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.
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:
> 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.
> On 04/gen/2011, at 02.41, Murrah wrote:
> > does not implement
> > flash.utils.IExternalizable but is aliased to an externalizable clas
> 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
> 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
> > 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.
> > On 04/gen/2011, at 02.41, Murrah wrote:
> > > does not implement > > > flash.utils.IExternalizable but is aliased to an externalizable clas
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:
> > 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
> > 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
> > > 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.
> > > On 04/gen/2011, at 02.41, Murrah wrote:
> > > > does not implement
> > > > flash.utils.IExternalizable but is aliased to an externalizable clas
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.
> 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:
> > > 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
> > > 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
> > > > 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.
> > > > On 04/gen/2011, at 02.41, Murrah wrote:
> > > > > does not implement > > > > > flash.utils.IExternalizable but is aliased to an externalizable > clas
> 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.
> > 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:
> > > > 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
> > > > 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
> > > > > 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.
> > > > > On 04/gen/2011, at 02.41, Murrah wrote:
> > > > > > does not implement
> > > > > > flash.utils.IExternalizable but is aliased to an externalizable
> > clas
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.
> 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.
> > > 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:
> > > > > 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
> > > > > 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?
> > > > > > 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.
> > > > > > On 04/gen/2011, at 02.41, Murrah wrote:
> > > > > > > does not implement > > > > > > > flash.utils.IExternalizable but is aliased to an externalizable > > > clas