Skip to content

Instantly share code, notes, and snippets.

@apexdodge
Created June 13, 2019 22:19
Show Gist options
  • Select an option

  • Save apexdodge/b382ea0596e1abede5b4aaef0a0b37e9 to your computer and use it in GitHub Desktop.

Select an option

Save apexdodge/b382ea0596e1abede5b4aaef0a0b37e9 to your computer and use it in GitHub Desktop.
function HtmlToPdfController($scope, $http) {
$scope.printToPdf = function () {
$http.defaults.headers.common.Authorization = 'YOUR-API-KEY'; //replace with our API key from portal.api2pdf.com
var endpoint = "https://v2018.api2pdf.com/chrome/html"
var payload = {
html: "<p>Hello from AngularJS</p>", //set your HTML here!
inlinePdf: true
}
$http.post(endpoint, payload).then(
function(response) {
console.log(response) //your PDF is in this response. Do something with it!
},
function(error) {
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment