Convert HTML to PDF with javascript and VueJs

June 12th, 2019 / by api2pdf /


VueJs is a popular client side javascript framework. It has risen in prominence as an alternative to juggernauts like ReactJs and Angular. Part of its allure comes from its simplicity and lower barrier to entry. While building a VueJs application, you may find yourself in need of generating PDFs. This can push you down a rabbit hole. In this article we will demonstrate how you can start converting HTML to PDF files from VueJs in minutes.

Convert HTML to PDF with VueJs

Using Api2Pdf’s REST API, you can quickly send HTML to convert to a PDF. The first thing to do is grab an API key from It only takes a minute.

Next, view the javascript code for the VueJs component below. Take note of the various sections – most notably replace “YOUR-API-KEY” with your api key you received from signing up and also replace the boilerplate HTML with your own HTML. You can modify the function to pull in HTML from elsewhere.

It uses Axios library to make the API call. You can view the full Api2Pdf documentation here.

To see a fully working example, view this JS Fiddle and don’t forget to replace the API key with your own.

Tags: , , , , , , , ,

Comments are closed.