HNHacker News
TopNewBestAskShowJobs

abhinav22

909 karma · joined October 10, 2020

Maths. Lisp. Finance.

Website: math.dev

submissionscomments
abhinav22··on Show HN: PDFs from HTML
Anything with paged.js makes me an auto fan :)

This could be very interesting for those with Python workflows, thanks for sharing

abhinav22··on Show HN: PDFs from HTML
From my limited experience with wkhtmltopdf, a solution based on paged.js should work better

But maybe that’s because I didn’t fully learn wkhtmltopdf

PrinceXML is very good but is a paid solution. I found paged.js, at least for my purposes, on par with PrinceXML

abhinav22··on Show HN: PDFs from HTML
Thanks! :) Will fix it after work.
abhinav22··on Show HN: PDFs from HTML
Thanks Adam! I know I come across as one of the biggest fans of paged.js, but it’s such an inspirational project!

The idea to polyfill the required functionality for CSS Print Rules is pure genius, as somebody who looked at all the alternatives. It’s a great example of thinking outside the box.

Thanks again!!

abhinav22··on Show HN: PDFs from HTML
I will look into this and add it in (if possible), please do check back in a couple of weeks (maximum).

Would you be able to expand on what you mean (sorry I’m being dense), otherwise I will Google it tomorrow

Thanks for the kind words

abhinav22··on Show HN: PDFs from HTML
Thanks!

Yes I know what you mean - it doesn’t work well in certain browsers, devices etc. Aimed at desktop users and Chrome in particular (I saw a bug in Safari version). The aim is less to be a readable pdf in-browser, but rather a high quality pdf after exporting to pdf. The in browser print preview is just a nice side effect (but I might actually reuse this for other projects as I like it quite a bit!).

I think the issue with the toc is that it’s dynamically created; so while I was able to use responsive web design for the rest, it didn’t work so well for the toc. I’ll have a look at it though :) I think there may be a way to get it to work

abhinav22··on Show HN: PDFs from HTML
Also feel free to email me / send me a message on GitHub if you need any help in customizing parts of your CSS. I feel like I have become a guru in this now and can quickly figure out how to use it for specific goals :D

I may write a book on typesetting with CSS, the quality of what is on the web is not the best, but it seems like a huge time sink at the same time...

abhinav22··on Show HN: PDFs from HTML
Thanks :) It’s all free, I will figure out how to add the license tomorrow as I don’t know what’s the right one - basically don’t want people to have any issues with GPL so if I understand then MIT is the right one?

Also paged.js is the property of their team, together with the script of toc.js whilst MathJax is the property of their team too. Have to figure out how to word it.

But if anyone is reading in the meantime, it is open source, no need to attribute anything back to me for my parts. If you are using the text of the guide, you could mention my name, but don’t sweat it either - it wasn’t particularly involved in terms of writing (the hard part was choosing which parts to write about so it’s not too complex but also not too barebone).

abhinav22··on Show HN: PDFs from HTML
Hi dang, hope you are well. May I kindly ask why not? I spent two weeks writing the CSS / HTML / JavaScript, and did well documented code - in fact the output serves as both documentation of the code and also output from it (in my own stupid way, I was thinking I was following Donald Knuth’s Literate Programming Approach :D).

The repo (https://github.com/ashok-khanna/pdf) contains all the necessary code and is intended for others to reuse in their projects. Some of it isn’t straightforward, despite the guide looking easy - I had to figure out how CSS selectors and counters work for example, how MathJax interacted with Paged.Js.

I think the confusion comes from it being labeled as a “guide”, in fact it’s a full set of code to give the required functionality for high quality PDFs from HTML, using paged.js, the guide is just the self documentation as I figured I might as well use documentation for the sample output. Otherwise, I’d be genuinely curious on what constitutes Show HN vs normal posts?

I think the repo description and the way the output is confusing / unclear - the primary goal is very much meant to be a code base for people to reuse as I’ve noticed for many programmers, the design side can be a bit more elusive.

Separately, would it be possible to add beautiful back to the title - it’s not really about producing PDFs from html as browsers can already do that, and there are many other tools. The main aim is to have the functionality to produce very high quality typeset PDFs from HTML, which until now, I only felt PrinceXML did well and that’s a paid solution. Maybe we could say the title is “High quality PDFs from HTML using Paged.JS”? I know there has been a separate discussion on another thread on the overuse of the word beautiful in describing code - my view is that it has its place when it relates to output / UI.

Thanks for reading, and no issues otherwise (no need to reply).

abhinav22··on Show HN: PDFs from HTML
It really does. The team at paged.js are simply amazing and deserve so much credit.

It’s such a big deficiency in the modern web, we really need Chrome / Safari / etc to implement the W3C standard or something better

abhinav22··on Show HN: PDFs from HTML
Should be able to - somebody with intermediate Wordpress knowledge (unfortunately I don’t know php) should be able to integrate within a day in my opinion, based on my understanding of web development
abhinav22··on Show HN: PDFs from HTML
Indeed - that makes a lot of sense
abhinav22··on Show HN: PDFs from HTML
The table of contents is itself hyperlinked. And at the bottom of each page is a link to return to the table of contents.

Let me know if that works well?

abhinav22··on Show HN: PDFs from HTML
I work in financial reporting, doing very similar things to what you mentioned here. Mind dropping me an email at Ashok.khanna@hotmail.com and we could discuss further? Would love to chat to others facing similar dilemmas :)
abhinav22··on Show HN: PDFs from HTML
Do you have a repo I could play around with? I had the same issue, but for my use case I figured a work around - primarily by using classes. I could spend a few minutes and see if I can get it working for you.

But yes, it’s a deficiency in the system currently

abhinav22··on Show HN: PDFs from HTML
Thanks - indeed there is likely a market for it. One of the issues is that to get a commercial app, you have to solve for most of the edge cases and make sure it has a good enough UI for the non sophisticated.

I was thinking about doing it, but it would be a lot of work to do right.

By right, I would want it to be the quality of sublime or emacs / vim :) :)

abhinav22··on Show HN: PDFs from HTML
Yes, that would be an advanced feature and I think likely out of the scope for paged.js. That said the table of contents page is hyperlinked - you can jump to sections, and I put a return to table of contents in the footer to aide with navigation. Hopefully that helps?
abhinav22··on Show HN: PDFs from HTML
Basically you can use CSS to manage their layout - dimensions, positioning, scaling, etc. Should work pretty well

If you want floating images (e.g. text on the left, images on the right), it may be a bit more difficult and not perfectly possible. This guide will help: https://www.pagedjs.org/page-floats/

One tricky part is if you want to have text within images and have them the same size as your main text (eg in MS Word where you can have shapes and text boxes). For that, you can probably get close enough with a simple image load, and more precise by using svg graphics, but it may result in a reasonable amount of complexity to make perfect (if at all).

For charts, use charts.js in my opinion.

abhinav22··on Show HN: PDFs from HTML
Yep - looks like Chrome only gets those right. I will speak to the paged.js guys and see where the bug is in the code.

Rest seems to work on Safari - let me know if any other issues and I’ll fix / update accordingly

abhinav22··on Show HN: PDFs from HTML
Justify works in iOS Safari (I just checked). I like to use it in my designs sometimes :)
abhinav22··on Show HN: PDFs from HTML
Thanks for flagging. It’s aimed for desktop users and a reasonable size screen (eg A4 or so), it’s not really a responsive design as it’s meant to be a tool to generate PDFs. So it won’t work in some browser dimensions (the paged.js code is reasonably complex).

That said it works in iOS as far as I can test. For some reason page numbers in table of contents not working perfectly in Safari but Chrome works pretty well.

I guess the conclusion is that this is aimed somewhat to desktop Chrome users as a specific tool for pdf generation.

abhinav22··on Show HN: PDFs from HTML
No, it’s more for pdf production from desktop. The print preview on the example web page works on iPhone and browsers but the aim is really for pdf and not for consumption via mobile etc
abhinav22··on Show HN: PDFs from HTML
I was a huge supporter of PrinceXML / DocRaptor for precisely the same reason - all the alternatives (that I knew at the time) were not good.

Paged.js was a revelation (thanks to HN for telling me about it!). It is based off CSS Print Specifications like PrinceXML (as is my understanding - I’m about 95% sure), and to me it’s even better because it utilizes all the other front end technologies directly from your browser - I think there are some use cases where PrinceXML won’t be able to get the same functionality.

For invoices, I think you should be able to easily switch over. Based on what I can see.

abhinav22··on Show HN: PDFs from HTML
Thanks for your kind words.

Would you be able to expand on what you mean by “report generation libraries”?

For example, I am building (in Common Lisp, but it’s trivial and can be done in any software) a tool to read content from a database and auto generate the HTML markup for producing pdf reports. This allows me to reuse content across reports and also leverage the full power of databases (text search in particular). As another example, I have many monthly financial metrics - I will store these in a database then use my lisp markup tool to generate the necessary HTML to produce the pdf report (via paged.js).

In addition, one can use headless chrome to automate the full workflow so that the reports are generated directly from your program and not via File > Print in your browser.

Was that what you were thinking of?

You can also add charts via charts.js.

The beauty of paged.js is that you can leverage many of the features of browsers and JavaScript libraries in your report generation.

I wasn’t able to get syntax highlighting for code blocks to work however, need to dig into that a bit more.

abhinav22··on Show HN: PDFs from HTML
Thank you! Paged.js is really such an awesome tool.

I was searching for many weeks for something like this, so I really think the word needs to get out there more. It could significantly improve the workflows of many people who are self writing / self publishing as it opens up the power of CSS and HTML (which allows to nicely defined formatting templates and use code to automate content generation) to pdf reports (which I think has its place).

I haven’t used pandoc, but I think a HTML/CSS/Paged.js workflow could challenge it.

At work I’m already converting many processes to it - I have a database of content and then use SQL queries to extract data and then generate beautiful PDFs through paged.js.

It also works well with mathematical typesetting (via MathJax).

abhinav22··on Show HN: Clayoven – beautiful website generator aimed at math-heavy sites
I think it is okay in this instance as it relates to an output generator (and beautiful output should be a key functionality of such a tool)
abhinav22··on Penny Stocks Are Booming, Which Is Good News for Swindlers
I agree. In fact it’s much worse because of the fee structure and lack of disclosure / transparency. Surprised the SEC haven’t jumped in on it as it’s blatantly aimed at avoiding the IPO regulatory process
abhinav22··on Penny Stocks Are Booming, Which Is Good News for Swindlers
One of the biggest scams I can see currently - hide the terms behind financial instruments, but take a 20 to 25% fee for making an investment!!

When the usual fees are 1.5% plus a performance fee

I really don’t understand why the SEC allows them to continue without proper disclosures on what they really are....

abhinav22··on Spreadsheet is a software development paradigm
Nice. Same in Australia
abhinav22··on What I learnt after burning $10M as an entrepreneur
Indeed! That would be amazing..

Very tempting, must resist going down that rabbit hole :-)

← PreviousPage 3 of 12Next →