html to pdf api free,HTML to PDF API - Easy PDF Server

By developers for developers

Use these code samples to integrate and deliver in minutes using our simple API:

Create PDF right now on our website:

API Key

URL or HTML

Create PDF from an HTML string in CURL:

curl -f 'https://api.easypdfserver.com/make-pdf' \

--data-binary '{"html":"YOUR-HTML-STRING", "key":

"YOUR-API-KEY"}' \

> download.pdf

or create PDF from a URL in CURL:

curl -f 'https://api.easypdfserver.com/make-pdf' \

--data-binary '{"url":"YOUR-URL", "key": "YOUR-API-KEY"}' \

> download.pdf

Create PDF from an HTML string in NodeJS:

const https = require('https'),

fs = require('fs');

const data = JSON.stringify({

key: 'YOUR-API-KEY',

html: 'YOUR-HTML-STRING',

});

const options = {

hostname: 'api.easypdfserver.com',

port: 443,

path: '/make-pdf',

method: 'POST',

headers: {

'Content-Type': 'application/json',

'Content-Length': data.length,

},

};

const req = https.request(options, res => {

let body = Buffer.alloc(0);

res.on('data', chunk => body = Buffer.concat([body, chunk]));

res.on('end', () => fs.writeFile('download.pdf', body, console.error));

});

req.on('error', console.error);

req.write(data);

req.end();

or create PDF from a URL in NodeJS:

const https = require('https'),

fs = require('fs');

const data = JSON.stringify({

key: 'YOUR-API-KEY',

url: 'YOUR-URL',

});

const options = {

hostname: 'api.easypdfserver.com',

port: 443,

path: '/make-pdf',

method: 'POST',

headers: {

'Content-Type': 'application/json',

'Content-Length': data.length,

},

};

const req = https.request(options, res => {

let body = Buffer.alloc(0);

res.on('data', chunk => body = Buffer.concat([body, chunk]));

res.on('end', () => fs.writeFile('download.pdf', body, console.error));

});

req.on('error', console.error);

req.write(data);

req.end();

Create PDF from an HTML string in PHP:

$key = 'YOUR-API-KEY';

$html = 'YOUR-HTML-STRING';

$postdata = http_build_query(

array(

'key' => $key,

'url' => $url,

)

);

$opts = array('http' =>

array(

'method' => 'POST',

'header' => 'Content-type: application/x-www-form-urlencoded',

'content' => $postdata

)

);

$context = stream_context_create($opts);

$result = file_get_contents('https://api.easypdfserver.com/make-pdf',false,$context);

file_put_contents('download.pdf',$result);

or create PDF from a URL in PHP:

$key = 'YOUR-API-KEY';

$url = 'YOUR-URL';

$postdata = http_build_query(

array(

'key' => $key,

'url' => $url,

)

);

$opts = array('http' =>

array(

'method' => 'POST',

'header' => 'Content-type: application/x-www-form-urlencoded',

'content' => $postdata

)

);

$context = stream_context_create($opts);

$result = file_get_contents('https://api.easypdfserver.com/make-pdf',false,$context);

file_put_contents('download.pdf',$result);

Create PDF from an HTML string in Python:

import requests

API_ENDPOINT = "https://api.easypdfserver.com/make-pdf"

r = requests.post(url = API_ENDPOINT, json = {"key":"YOUR-API-KEY",

"html":"YOUR-HTML-STRING"})

f = open("download.pdf", "w")

f.write(r.content)

f.close()

or create PDF from a URL in Python:

import requests

API_ENDPOINT = "https://api.easypdfserver.com/make-pdf"

r = requests.post(url = API_ENDPOINT, json = {"key":"YOUR-API-KEY",

"url":"YOUR-URL"})

f = open("download.pdf", "w")

f.write(r.content)

f.close()

Create PDF from an HTML string in Ruby:

require 'net/http'

require 'net/https'

require 'uri'

require 'json'

uri = URI.parse("https://api.easypdfserver.com/make-pdf")

data = { 'key': 'YOUR-API-KEY',

'html': 'YOUR-HTML-STRING'}.to_json

https = Net::HTTP.new(uri.host,uri.port)

https.use_ssl = true

req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})

req.body = data

res = https.request(req)

File.binwrite('download.pdf', res.body)

or create PDF from a URL in Ruby:

require 'net/http'

require 'net/https'

require 'uri'

require 'json'

uri = URI.parse("https://api.easypdfserver.com/make-pdf")

data = { 'key': 'YOUR-API-KEY',

'url': 'YOUR-URL'}.to_json

https = Net::HTTP.new(uri.host,uri.port)

https.use_ssl = true

req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})

req.body = data

res = https.request(req)

File.binwrite('download.pdf', res.body)

Need help? All plans come with email support! Ask us a question.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值