[plugin] jsPDF

Post your work in progress addons and get feedback

Post » Tue Mar 04, 2014 7:14 pm

JsPDF
Generate PDF files in client-side JavaScript.


I've exposed jsPDF to C2 users, you can find more info here

Let's you create multiple pdfs with different sizes and orientations containing multiple pages. Please test if it's possible on multiple platforms and send feedback. Initial test are ok on Chrome, Firefox and Node-Webkit .

After feedback from the forum users and hopefully some improvements, i'll push this to Git for everybody to use .



API

Actions

Set Font Size (size)

Add text (X,Y,Angle,String)

Add Image (X,Y,width,height,DataUri Type, DataUri string )

Draw a line (x1,y1,x2,y2)

Draw a rectangle (X,Y,width,height, style)

Draw an ellipse (X,Y,rx,ry,style)

Set text font (font name, font size)

Save pdf (filename)

Add page

Set properties (title,subject,author,keywords,creator)

Set text color (r,g,b)

Set stroke color (r,g,b)

Set fill color (r,g,b)

New (orientation, unit, format)


Expressions

Pdf as DataURL


plugin

html test

pdf_test.capx


Changelog 03.07.2014:

Upped plugin version to 1.1
Updated jsPDF libray to 1.0.178
Added support for PNG, JPG and JPEG DataURI types,
Two new formats available; d1, credit-card


Changelog 13.07.2014:

Upped plugin version to 1.2
Draw ellipse implemented
Set text colour implemented
Set fill colour implemented
Set stroke colour implemented
Added style parameter when drawing objects (Valid styles include: 'S' [default] - stroke, 'F' - fill, and 'DF' (or 'FD') - fill then stroke)

Changelog 05.1.2014:

Minification support thanks to @Noncentz705.
Plugin is now available on the repo (search for the "download zip" to download plugin)
Last edited by JohnnySheffield on Wed Nov 05, 2014 1:12 pm, edited 8 times in total.
Be nice until it's time to not be nice
B
36
S
10
G
9
Posts: 293
Reputation: 6,712

Post » Sat Jun 28, 2014 2:42 pm

Hello, i was testing you plugin. It seems a good alternative to PodePDF. But unfortunately it's giving me an error:

Javascript error!
Uncaught SyntaxError: Unexpected token var http://localhost:50001/jsPDF_plugin.js, line 17 (col 2)

I'm using r173 Stable.
B
36
S
5
G
2
Posts: 28
Reputation: 2,448

Post » Sun Jun 29, 2014 8:15 pm

Ahh, yes, it seems i've uploaded old version! I'll update tommorow and post here!

Thanks for trying out the plugin!

Cheers!
Be nice until it's time to not be nice
B
36
S
10
G
9
Posts: 293
Reputation: 6,712

Post » Mon Jun 30, 2014 10:41 am

@drzanuff

I've updated the link in the first post, it should be fixed now.

Cheers!
Be nice until it's time to not be nice
B
36
S
10
G
9
Posts: 293
Reputation: 6,712

Post » Tue Jul 01, 2014 1:29 pm

Thanks! The Plugin is working now. I will test the functionalities and i will report back later. But, for what i saw until now, it's a pretty good Plugin.
B
36
S
5
G
2
Posts: 28
Reputation: 2,448

Post » Wed Jul 02, 2014 2:01 am

Hey, i've been experimenting with your plugin. And i got a new error. When i try to draw a image on the PDF, from a DropBox Public link image or a Base64 String image using Pode's Behavior:

https://www.scirra.com/forum/viewtopic.php?t=68494&start=0

i receive this error:

Javascript error!
Uncaught Error: getJpegSize could not find the size of the image
http://localhost:50001/jspdf.source.js, line 1926 (col 10)


And i'm specifying the image Width and Height in the parameters. (Tried the image actual size and Width and Height zero too). Am i doing something wrong or the Plugin was designed to just Draw Canvas Snapshots?

Sorry to bother you with this, but your Plugin is good and with great functionalities.
B
36
S
5
G
2
Posts: 28
Reputation: 2,448

Post » Wed Jul 02, 2014 9:22 am

can you send me an example capx? i'll get to it tonight...

i've tested it with canvassnapahot only, so i'm not sure what's happening here.

thanks for testing and reporting!
Be nice until it's time to not be nice
B
36
S
10
G
9
Posts: 293
Reputation: 6,712

Post » Wed Jul 02, 2014 12:30 pm

My current project is a mess. When i got home from work today i will try to reproduce the bug in a clean project and give you the .capx and the feed back. Thanks!
B
36
S
5
G
2
Posts: 28
Reputation: 2,448

Post » Wed Jul 02, 2014 11:02 pm

@drzanuff

All is good now.

Pode's plugin was returning a PNG url string, and this plugin supported only JPEG until today. Please re-download.

I've tested with Pode's plugin and it worked in Chrome.

Also, ive updated jsPDF to a newer version, and did some minor improvements.

If you come up with some feature requests, please share, some of jsPDF api's aren't exposed in this plugin, so there's a possibility i can implement it.

Cheers!

edit: Add image action now takes one more argument, DataURL type, please choose between "PNG", "JPEG" and "JPG".
Be nice until it's time to not be nice
B
36
S
10
G
9
Posts: 293
Reputation: 6,712

Post » Thu Jul 03, 2014 2:46 am

Wow! You work fast! I was preparing the .capx to send to you but you already nailed it! For an initial test, it's working using the Pode's plugin. I'm still getting an error when using a URL link for the image, but i don't know if it is a Cross-Domain issue. I need to work early tomorrow morning, so tomorrow i will make some more testing and give you a feed back.

Thanks! I hope this plugin can be completed so it can be a the default third- party C2 PDF plugin.
B
36
S
5
G
2
Posts: 28
Reputation: 2,448

Next

Return to Work in Progress Addons

Who is online

Users browsing this forum: No registered users and 1 guest