
JsPDF - HTML5 PDF generator - smanuel
http://parall.ax/products/jspdf
======
HarrietJones
Heh - This was first posted to hacker news over 1500 days ago.
[https://news.ycombinator.com/item?id=574854](https://news.ycombinator.com/item?id=574854)

~~~
aroman
It has definitely been posted to HN numerous times in the past. However, it
seems the reason it was posted again this time is because the jsPDF website
had a major design revamp.

At least, it looks very different from when I last used it ~6 months ago.

------
hexagon
Cannot get it to work for me. It shows only a blank page, both in the in-page
viewer, and the saved document locally. I am on a linux Mint 15 and Firefox 23

~~~
brokenparser
It's the same in Firefox Nightly 26.

~~~
fnordfnordfnord
Same for FF 23.0.1 on Windows something or other.

------
mikegioia
This is pretty awesome, but I think something that could PDF an html page
would be much more valuable. Currently I have to use some wkhtmltopdf server-
side trickery.

~~~
brianfryer
Use PhantomJS to Create PDFs from HTML:
[https://coderwall.com/p/5vmo1g](https://coderwall.com/p/5vmo1g)

~~~
paulwithap
What they don't tell you is that this method takes a long time and generates
huge files unless you used a patched version of qt. I've been meaning to write
a blog post on this.

~~~
pero
Please do.

------
agumonkey
Watching this under Firefox gives a nice JsPDF -> PDF.js homolinguistic loop.

------
ahmett
Github link is missing on that page.
[https://github.com/MrRio/jsPDF](https://github.com/MrRio/jsPDF)

------
HarrietJones
Previously hosted at JsPDF.Com. I'm not sure why it's moved, but I've used
this library and can attest to its awesomeness. It seems really stable to me.
I use it to create and print off 4 page employment applications.

Gotchas : 1 - It can be hard to get downloading working using the Flash shim
(For IE9 and below). It is possible though. 2 - Images have to be Base64
encoded, and that can be a royal pain.

I'm not the worlds best developer by a long chalk, but I had this library
wrapped in a reporting class in a couple of days, and I can now pretty easily
just throw some JS Structures at it, and have the tabular data printed out
with headers and footers. I wish I could share it.

~~~
e98cuenc
You can use the data url of the image, I made a small test here:
[http://cuenca-stuff.s3.amazonaws.com/jpgtopdf/index.html](http://cuenca-
stuff.s3.amazonaws.com/jpgtopdf/index.html)

(I don't know if by "base64" you mean "data url", which usually encodes the
raw data in base64...)

------
pippy
I much prefer wkhtmltopdf:
[https://wkhtmltopdf.googlecode.com/](https://wkhtmltopdf.googlecode.com/)

It essentially allows you to make an HTML page and convert it to a PDF. It has
powerful options around making footers, headers etc. The best part is you can
run jQuery on it. It comes in handy when you don't know what the data will be
like.

------
sgt
This is very interesting. Careful using only client-side technologies to
generate PDFs though. What if down the line you get another user requirement,
such as having a PDF generated and mailed to the user?

Assuming you are not using Node.js as a backend, that might pose a problem,
and cause you to possibly maintain the logic for two separate PDF generators.

------
RamiK
Wouldn't a TeX engine written in Ecmascript make more sense?

A Web2JS of sorts maybe...

Though I'm more inclined towards using XeTeX since it solves a lot of problems
without gluing a whole new language (LuaTex anyone?) in there.

~~~
FraaJad
I believe someone posted a link to Speedata tool which uses LuaTeX.
[https://news.ycombinator.com/item?id=6273668](https://news.ycombinator.com/item?id=6273668)

------
ncrit
Small Typo: "A HTML5 client-side solution for generating PDFs". I think it
should be "An HTML5 client-side solution for generating PDFs".

~~~
TAGrammarNazi
Fiercely off topic, but it depends on your pronunciation of "H"

~~~
dsego
Obligatory Mitchell & Webb
[http://www.youtube.com/watch?v=c3y0CD2CoCs](http://www.youtube.com/watch?v=c3y0CD2CoCs)

------
thinkersilver
I've been using this library and I really like it. If only it could do svg,
then embedding D3 charts would be a cinch. Keep up the good work, though.

------
sitharus
Looks good, but the typesetting is a little off and I don't see any examples
of paragraphs or line wrapping.

I built a PDF library for PHP many years ago and the hardest part was text,
typesetting is a hard problem.

Looks good for exporting images and charts though.

------
talles
Pretty useful, but didn't work on Firefox 23.0.1 here (just blank pdf).

On Chrome seems fine.

~~~
waldir
The version at [http://mrrio.github.io/jsPDF/](http://mrrio.github.io/jsPDF/)
works for me (on both Firefox and Chrome)

------
ya3r
This is really good. Specially the real-time rendering as one changes the
code. But it does not work with Unicode (I tried farsi) characters.

Why does most of things related to PDF do not work with unicode characters?

------
TheZenPsycho
Why isn't the api compatible (or at least sympathetic with) 2D canvas? If it
could do that, you'd be able to reuse so much code.

------
bachback
AFAIK there is not a free lib which approach the commercial pdf generators.
page-layouting can be complex.

------
gluxon
It's funny to see Firefox turn this back into HTML, CSS, and JavaScript with
PDF.js...

------
unz
Slightly off-topic, Pdf and Ps are just plain outdated for today. They're
unreadable on small screens and for people with bad eyesight, and no one sane
prints stuff out these days Html is better, but the real thing today is tablet
apps. All docs should be published as interactive 10/7/5 inch apps. Books
should also disappear and be replaced by that form factor. Scientific paper
authors also need to realize this and replace latex with app programming and
publish their work as apps.

~~~
zv
The advantages for PDF is printing. You can't just set correctly page margins
and other things with plain HTML.

~~~
unz
My point is - why is anyone printing anymore? Everyone can get their hands on
a tablet these days

