Live data from Hacker News

Pdfmake – PDF printing in pure JavaScript

pdfmake.org

31–40 of 49 posts

Re: Pdfmake – PDF printing in pure JavaScript

#31
post #30
post #27

Little of topic. What would be nice is to have something like "print to pdf, aka save page as pdf" via a browser using pdfjs.

"PDF" is a valid application-agnostic printer target on the Debian box I am using.

In OS X too. I believe Windows is the only OS that needs you to install a PDF printer.

Re: Pdfmake – PDF printing in pure JavaScript

#32
post #26
post #2

Just looked at the sample on the playground section of the website. No hyphenation, no ligatures, and overall the output looks ugly (compared to TeX). What is the advantage over simply creating an appropriate LaTeX/ConTeXt document in the background and serving that?

For the same reason everything eventually gets rewritten in Javascript: sometimes you want to do it in a browser. In my case, I have a Javascript app that stores critical information for offline use, and users want to be able to print that information nicely. So I generate PDFs in Javascript. This could make that much easier.

> For the same reason everything eventually gets rewritten in Javascript: sometimes you want to do it in a browser.

Indeed:

http://manuels.github.io/texlive.js/

Re: Pdfmake – PDF printing in pure JavaScript

#33
post #31
post #30

Earlier quoted context omitted.

"PDF" is a valid application-agnostic printer target on the Debian box I am using.

In OS X too. I believe Windows is the only OS that needs you to install a PDF printer.

On Windows, CutePDF uses Ghostscript for the virtual printer.

On iOS, Apple disabled the API for local virtual printers. There are various "html-to-pdf" apps, but these often perform a non-interactive fetch of the source web page, which use different auth/cookies and can result in a PDF which is different from the one displayed by Safari.

Re: Pdfmake – PDF printing in pure JavaScript

#34
post #2

Just looked at the sample on the playground section of the website. No hyphenation, no ligatures, and overall the output looks ugly (compared to TeX). What is the advantage over simply creating an appropriate LaTeX/ConTeXt document in the background and serving that?

[deleted]

Re: Pdfmake – PDF printing in pure JavaScript

#35
post #2

Just looked at the sample on the playground section of the website. No hyphenation, no ligatures, and overall the output looks ugly (compared to TeX). What is the advantage over simply creating an appropriate LaTeX/ConTeXt document in the background and serving that?

>overall the output looks ugly (compared to TeX)

what doesn't!

>What is the advantage over simply creating an appropriate LaTeX/ConTeXt document in the background and serving that?

the obvious advantage is that you wouldn't have to learn LaTeX/ConTeXt, no?

Re: Pdfmake – PDF printing in pure JavaScript

#37
post #24

Earlier quoted context omitted.

But the bus is free and it works fine.

but it comes with schoolbus-type problems and you look ridiculous.

Our customers don't see it so it doesn't matter how we "look". We can re-use existing design assets and UI elements. I can embed SVG charts drawn by D3, or anything else I can otherwise do with "an entire school bus".

Re: Pdfmake – PDF printing in pure JavaScript

#38
post #2

Just looked at the sample on the playground section of the website. No hyphenation, no ligatures, and overall the output looks ugly (compared to TeX). What is the advantage over simply creating an appropriate LaTeX/ConTeXt document in the background and serving that?

>overall the output looks ugly (compared to TeX) what doesn't! >What is the advantage over simply creating an appropriate LaTeX/ConTeXt document in the background and serving that? the obvious advantage is that you wouldn't have to learn LaTeX/ConTeXt, no?

Pdfmake could generate LaTeX, which can then be properly compiled to a pdf (potentially with texlive.js).

In Haskell this is possible with similar DSLs. Very useful to generate reports.

Re: Pdfmake – PDF printing in pure JavaScript

#39

Earlier quoted context omitted.

PhantomJS is a full web browser that just happens to output PDF's. This is a library to create PDF's with it's own layout model that shares nothing with HTML. Much simpler and low level.

Is it really simpler? I have to learn a DSL to create PDFs with this, whereas I can just use HTML in the other case.

Simpler as in the complexity of the library, a web browser is orders of magnitude more complex than this lib.

Simpler as in ease of use? Well that's subjective, some might find HTML easier than learning a new layout model, other might like something more focused on just PDF layout like this.

Re: Pdfmake – PDF printing in pure JavaScript

#40

Earlier quoted context omitted.

Is it really simpler? I have to learn a DSL to create PDFs with this, whereas I can just use HTML in the other case.

It's not like there is a direct translation from HTML to PDF. They don't really map 1:1. The PDF exported by a browser from an HTML page is an interpretation of that content. Converting from HTML is not a straightforward, reliable way to produce PDFs. Sometimes the process turns out beautiful, sometimes it turns out kind of shitty. Not to mention there are PDF features which are not supported by an HTML export (for e…

I sort of disagree, HTML as implemented in PhantomJs, wkhtmltopdf and all interactive browsers is incomplete for paged/print output. However HTML with CCS page media is pretty close to being a complete solution, unfortunately the only implementation currently is the commercial PrinceXML.

If someone (Apple or Google) would get wise and implement the full paged media spec then PhantomJS/wkhtmltopdf/your browser might be a viable option for full fidelity print output.

See: http://www.webkit.org/projects/printing/

http://www.princexml.com/

Until then our apps will have to suffer with one layout language for viewing (HTML) and have another for print like this lib.

Post reply on HN