[plugin] jsPDF

0 favourites
From the Asset Store
The I18N (Translation) is a Construct plugin created to translate text in game.
  • 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

    Plugin is now available on the repo (search for the "download zip" to download plugin)

  • 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.

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

    Thanks for trying out the plugin!

    Cheers!

  • drzanuff

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

    Cheers!

  • 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.

  • 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:

    [quote:3hvqpdut]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.

  • 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!

  • 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!

  • 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".

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • If your're trying with URL like this ( http://i.imgur.com/7ibIp6y.jpg ), it won't work.

    You should convert it somehow to Base64 uri, something that looks like this:

    data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA

    AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO

    9TXL0Y4OHwAAAABJRU5ErkJggg==

  • I've updated the plugin with some new features. Please check the first post for downloads and changelog.

    Cheers!

  • I've been busy to respond, but your plugin is working fine. Tonight i'll check the new version. It is pretty stable for now. Thank you!

  • JohnnySheffield Hi, I'm having some difficulties getting this plugin to work on phonegap, is it compatible? I've tried it on other platforms without a problem so I don't think it is user error.

  • i havent test it on phonegap yet...

    i'll look into phonegap support and report here my findings.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)