-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jsPDF AMD version doesn't compile Adler32 dependancy correctly #122
Comments
Ye I am having same problem here! |
Same here. I get a TypeError: object is not a function |
Same problem, unable to use lib with Requirejs. |
How can I use jsPDF with RequireJS? The
In the newest commit however, the is no |
I was expecting to use jspdf with require js and I felt a bit disappointed not to be able to find the amd version of the module in dist folder |
I builded the library using the provided build script, but the newest commit does't seem to produce the AMD version anymore. I only got |
Hi there, I found the only difference between the AMD and MIN files/versions was a call to I'll try to fix that when i get a chance. |
Please test the new min file and let me know if that fixed the problem, which i think it should. However, i don't use requirejs so i can't be 100% sure... |
Thanks for your effort. There are two issue with your update. First, the global instance
This is the console output of the example.
The condition should be false and the the library should be injected directly. The correct output might just look like this then.
|
Ok, thanks for the info. I'm somewhat confused, though. On 0.9.0 the constructor was being returned as you suggest it needs to do, however... you reported that version as broken, too. Hmm, is there some conflict with Adler32? Ie, their call to define() misuses ours? How about if you submit a PR fixing that yourself? :) |
Okay, I'll try to come up with a fix. |
We use RequireJS, and our jsPDF fromHTML method fails most of the time, with one of two errors:
Is there a particular order in which we must load the jsPDF files? Currently, we're loading jspdf.js first, followed by jspdf.source.js and all plugins. |
@airandfingers It should be enough to load @diegocr What file should I edit for the fix? I think I could fix the distribution file, but the changes would be overwritten by the next build then. |
@danijar Since you're the one who first posted the error I'm having (#122 (comment)), I'm assuming you mean that it should be enough to load |
I'd like to point out that this wouldn't be much of an issue for us if other versions of jsPDF were available from Bower; as it is, only the latest version of jsPDF - 0.9.0 - is there, so that a downgrade using Bower is not possible. |
For those of you willing to use jspdf with require here is what I did w/o the AMD version of the library (replace ./frameworks/jspdf/ by the appropriate configuration path)
|
@pascalPimaia That's exactly what I tried; it didn't work, as with this code, jsPDF is set to the object @danijar printed above it #122 (comment):
Are you using the latest version of jsPDF, 0.9.0? |
First, it shouldn't be an issue to use prior versions since Git keeps them all. I built the library from source using the provided build script. It depends on two other scripts, but they should be easy to provide. This version works for me by including Maybe someone familiar with the source of this library can guide me to the internal file that I have to apply the changes to, so that further builds would properly work with Require.js. @MrRio, @diegocr? |
Our build process currently installs jsPDF from bower, from which only 0.9.0 is available. It sounds like we should stop using bower for jsPDF, and manually build from source, as @danijar described. I'll try this next. |
I use dist/jspdf.source.js but I haven't tried the minified version
|
I built from source:
...and had the same problem as above - jsPDF is an object, and "object is not a function". |
Did you use the shim feature of Require.js to export |
Yes, I'm using Require.js exactly as described above, including the shim feature. |
I've added a pull request which should fix this issue, it uses a powershell build script though. |
Good suggestion on the modules object, I'll revert the changes I made to It's easy to think you're going nuts when requirejs starts giving errors ;) On Mon, Mar 24, 2014 at 5:23 PM, Diego Casorran notifications@github.comwrote:
|
I've updated my pull request #218 and problem/solution demo page: http://cwohlman.github.io/jsPDF/examples/requirejs.html Does any see any more changes needed? |
@diegocr Thanks, I didn't see any build instructions, so I just ran build.sh without the --recursive option. The file you linked got rid of the saveAs error I pasted, but the PDFs being generated are all wrong, with pages of blank space, no text at all, and tables with rows that are each a page in height (despite having no text). What's going on here? Also, I still have the other error, only for some PDFs:
Any idea what might cause this error? It looks like this error only occurs when I create the PDF with certain HTML values, though all the values I'm trying are div elements with headers and multi-row tables. |
@airandfingers: The recursive option is for https://github.com/MrRio/jsPDF/blob/master/dist/jspdf.source.js#L3817 Are you sure you're using the correct jspdf.source.js file? :-/ @cwohlman i'll review next your PR replying there. |
@diegocr Hm sorry, I think I pasted my error from earlier, when I was using a different jspdf.source file.
As you can see at https://github.com/MrRio/jsPDF/blob/master/dist/jspdf.source.js#L3416, this line does have .length; the line[0].length part is the one throwing the Exception. |
@airandfingers: Yeah, i see. That is a bug in one of the plugins. Can you file a separate issue so that i can easily reference it when fixing it? thanks! |
Guys, I've just uploaded new dist files which hopefully should fix the Adler32 conflict by using the Tested using:
As you can see, i've changed it so that the https://github.com/MrRio/jsPDF/blob/master/dist/jspdf.min.js |
Thanks, great fix! |
@diegocr Thanks for pointing me to the right file and line. I think currently, the |
@danijar: The whole code is wrapped into a closure, hence i don't see how it should still leak. |
It didn't leak in my tests. |
Nice, then the issue is solved! I must have overseen that it was wrapped into an anonymous function. |
Yeah, the min file is that way since the inclusion of the |
Ahh, I knew it! Thanks for solving the issue. |
Thanks for the fix! Any idea when this will get pushed to Bower? |
@airandfingers: Probably when #184 gets done :) |
I have the same error in the latest build with bower : Object {Adler32: function, from: function, fromUtf8: function, fromBuffer: function} |
@throrin19 With RequireJS you have to use the min file, not the debug one. |
fromHTML is not working in any case with requireJS , I tried everything. if you have some example working example with requireJS for fromHTML method , please share.Thanks |
I'm using the min file, and am still getting jsPDF is undefined. Heres some snippets: require.config.js module.js var module = angular.module('kibana.panels.hits', []); module.controller('hits', function($scope, querySrv, dashboard, filterSrv) { Any ideas? I've tried putting it into the shim. Been all over the place and thought this thread would show me the answer, but where everyone else seems to have it fixed, I still don't...frustrating. Arg! |
Bower install, Without shim.
jsPDF is undefined. Shimmed, Shimmed, |
I am also getting undefined when requiring in the latest min version. The last working version I can determine is 1.0.178. It looks like the cause of the problem is the explicit naming of the require module: 'define('jsPDF', function() {' If you remove the module name then the latest seems to work as well. Not sure why this is causing an issue. |
When using requireJs to import jspdf.amd.min.js the imported object didn't look anything like jspdf.
It turns out that the build script must be simply wrapping the adler32 module inside of the jspdf module. The adler32 module contains a define call which gets called before the define call for jspdf and gets used in the place of the jspdf define call.
The text was updated successfully, but these errors were encountered: