Troubleshooting PDFKit and wkhtmltopdf in Rails

I’ve spent the past couple of days trying to generate PDF files successfully with PDFkit and wkhtmltopdf. It’s been a frustrating process to say the least.


1. You can’t use files with any other extension than .html when passing a file to, they must be .html files.

2. If you are trying to include assets in the PDF by making requests to your local server, you’ll need to run a web server capable of handling multiple processes (Unicorn or similar), otherwise the request will hang. I got around this by just including the required assets inline in the page.

3. Be careful with the file content that you’re passing to PDFKit, certain HTML syntax cannot be converted to PDF successfully.

4. If the page you are converting to a PDF is dependent on javascript generating content that might not be immediately visible, you will need to pass a javascript_delay option to E.g. :javascript_delay => 1000.

5. To have a better chance at debugging the issue causing you trouble, set the verbose option to true in a PDFkit initializer.

6. Get familiar with using wkhtmltopdf. PDFKit is just a Ruby wrapper around wkhtmltopdf, so try and reproduce the command that PDFKit is running by manually entering it in your terminal. This way you can rule out wkhtmltopdf being the troublemaker and narrow it down to an issue on the web server.

Why Do We Still Have Jobs?

Have you ever thought about how we are born into this world without the right to simply exist in a self sustaining manner outside the scope of the current system? To live a simple life with access to the basic necessities of life is not something that’s currently permissible. In a world where every piece of land is owned, and the majority of life’s necessities are privately produced for profit, the majority of us don’t have any real choice apart from submitting ourselves to the market system in order to trade our time for money.

Life doesn’t have to be this way. Today, based on studies in the UK and the US, it’s estimated that at least 47% of the jobs that currently exist are capable of being replaced with automated technology, and when we take into account the amount of jobs we have today that are absolutely redundant, we’re talking about being able to use automated machinery to produce everything that we need. When you really think about it, there’s an endless list of jobs that only exist today purely as a symptomatic response to the adverse effects this system creates in the first place.

Just one example of an industry that is vastly exaggerated, and thrives off of systemic induced suffering is the medical industry. This type of industry shouldn’t actually require anywhere near the amount of energy that’s currently put into it. But the demand for medical treatment is absolutely huge. If we think about why such a demand truly exists, it is evident that it is born out of the mental and physical illness which stems from the toxic lifestyles that this system promotes and facilitates in the first place. What I mean by this, is that because the market system is inherently based on competition, self maximization and the false idea that inequality and suffering is inevitable, we are constantly exposed to the damaging outcomes of such divisive and distorted ideas. The market spits out physical and mental trauma in many ways, such as environmentally destructive production methods, the need for perpetuated inequality and social division, and the imposition of a psychological value system that rewards the most individualistic, narcissistic and competitive traits of our character. It is clear that the prevalent sickness that we see in all of it’s forms is an outcome of what the market system itself is intrinsically based on.

We can use this type of reasoning to understand why there is so much over production and human labour in all sectors. The economic system succeeds because of false, unnecessary situations that create demands that need not exist in the first place, and if we don’t have these problems and vulnerabilities for markets to base business around, and we don’t use these inefficient systems for producing and delivering the products and services that are desired, then there wouldn’t be enough jobs to keep us all in employment, this is what it’s all about. The fundamental purpose behind why we’re running around doing all this completely unnecessary shit, is the cyclical need for economic consumption. The economic system demands that we continuously buy and sell through the market in order to prevent it’s inevitable collapse, and in the view of the market, it doesn’t matter what kind of business you are participating in. Whether it’s manufacturing weapons, or whether it’s through the means of destroying another countries infrastructure, only to move in and rebuild it. It doesn’t really matter, as long as what you’re doing can be profitable in some manner, you might even be contributing to what is referred to as economic “progress”. This is why the market cannot be ethical, it is blind to ethical behaviour. There is no built in mechanism or incentive for business to worry about ethics. It is solely about producing more and more, regardless of the how. Environmental concerns cannot be realistically addressed, as efficiency, preservation and sustainability are counter productive to the current model. All that really matters is that we continuously buy and consume whatever rubbish the market throws out at us regardless of it’s social and environmental impact.

This need for continuous consumption is one of the reasons why the progress of technology gets stifled, and why it is so slow for more efficient and cleaner industries to replace the established ones. The market will always try to cling on to inferior and outdated methods of production due to a businesses need to self preserve and because with more efficient technologies and production methods comes a reduced need for us to actually be working. If such technology can also deliver the possibility of self sufficiency to the consumer, you can guarantee that this will be fought with a passion, as this results in exactly what cannot be allowed, efficiency and reduced market dependency.

What we can do with technology today is amazing. There is no scientific limitations that prevents us from being able to house, feed and clothe every person on the planet, only monetary. We can install automated indoor vertical farms all across the world for localized food production which are climate resistant and 100 times more productive than traditional farming. We can create cities based on true efficiency and sustainability like Jacque Fresco’s circular city design. We can reduce the need for human labour down to a minuscule of what it currently is, and in doing so, move on to a new age of freedom that allows us to pursue our passions and interests instead of basing our lives around these fabricated tasks that we are compelled to do.