Try PDFShift for free and see for yourself
Rely on a leading conversion service.
Thousands of users trust us to quickly convert documents with a high-fidelity result.
-
1M+
Conversions made -
2.5s
Average conversion time -
2 hours
Average support response -
99.99%
SLA
Integrate PDFShift with just three lines of code
We believe that developers should focus their time on things that matter, not setting up yet another PDF library. Because we eliminate needless complexity and provide an up-to-date service, you can get up and running with PDFShift in just a couple of minutes.
// Step 1, install PDFShift
npm install pdfshift
// Step 2, import PDFShift
const pdfshift = require('pdfshift')('user_api_key');
const fs = require('fs');
// Step 3, execute
pdfshift.convert('https://en.wikipedia.org/wiki/PDF', {"landscape": false, "use_print": false}).then(function (binary_file) {
fs.writeFile('wikipedia.pdf', binary_file, "binary", function () {})
}).catch(function({message, code, response, errors = null}) {})
import requests
response = requests.post(
'https://api.pdfshift.io/v2/convert/',
auth=('user_api_key', ''),
json={"source": "https://en.wikipedia.org/wiki/PDF", "landscape": False, "use_print": False}
)
response.raise_for_status()
with open('wikipedia.pdf', 'wb') as f:
f.write(response.content)
# We also have a package to simplify your work:
# https://pypi.org/project/pdfshift/
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.pdfshift.io/v2/convert/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode(array("source" => "https://en.wikipedia.org/wiki/PDF", "landscape" => false, "use_print" => false)),
CURLOPT_HTTPHEADER => array('Content-Type:application/json'),
CURLOPT_USERPWD => 'user_api_key:'
));
$response = curl_exec($curl);
file_put_contents('wikipedia.pdf', $response);
// We also have a package to simplify your work:
// https://packagist.org/packages/pdfshift/pdfshift-php
require 'uri'
require 'net/https'
require 'json' # for hash to_json conversion
uri = URI("https://api.pdfshift.io/v2/convert/")
data = {"source" => "https://en.wikipedia.org/wiki/PDF"}
Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
request = Net::HTTP::Post.new(uri.request_uri)
request.body = data.to_json
request["Content-Type"] = "application/json"
request.basic_auth 'your_api_key', ''
response = http.request(request)
if response.code == '200'
# Since Ruby 1.9.1 only:
File.binwrite("wikipedia.pdf", response.body)
else
# Handle other codes here
puts "#{response.code} #{response.body}"
end
end
import java.io.File;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.time.Duration;
import org.json.JSONObject;
public class Application {
private static final String API_KEY = "your_api_key";
public static void main(String... args) throws Exception {
var jsonObject = new JSONObject();
jsonObject.put("source", "https://en.wikipedia.org/wiki/PDF");
var httpRequest = HttpRequest.newBuilder()
.uri(URI.create("https://api.pdfshift.io/v2/convert"))
.timeout(Duration.ofSeconds(20))
.header("Content-Type", "application/json")
.header("Authentication", "Basic " + API_KEY)
.POST(HttpRequest.BodyPublishers.ofString(jsonObject.toString()))
.build();
var httpClient = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_1_1)
.build();
var response = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofInputStream());
var statusCode = response.statusCode();
if (statusCode == 200 || statusCode == 201) {
// Save the file locally
var targetFile = new File("src/main/resources/wikipedia.pdf");
Files.copy(response.body(), targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
} else {
// error occurred
}
}
}
using System;
using RestSharp;
using Newtonsoft.Json;
using System.IO;
using RestSharp.Authenticators;
using RestSharp.Serialization;
using System.Net.Mail;
using System.Net;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
namespace PDFShiftExample
{
class Program
{
static void Main(string[] args)
{
IRestClient client = new RestClient("https://api.pdfshift.io/v2/convert");
client.Authenticator = new HttpBasicAuthenticator("your_api_key", "");
IRestRequest request = new RestRequest(Method.POST);
var json = new
{
source = "https://en.wikipedia.org/wiki/PDF"
};
request.AddJsonBody(json);
IRestResponse response = client.Execute(request);
if (!response.IsSuccessful)
{
// Check why status is not int 2xx.
}
else
{
File.WriteAllBytes("wikipedia.pdf", response.RawBytes);
}
}
}
}
package main
import (
"bytes"
"encoding/json"
"io/ioutil"
"log"
"net/http"
)
func main() {
API_KEY := "your_api_key"
message := map[string]interface{}{
"source": "https://en.wikipedia.org/wiki/PDF",
}
bytesRepresentation, err := json.Marshal(message)
if err != nil {
log.Fatalln(err)
}
client := http.Client{}
request, err := http.NewRequest("POST", "https://api.pdfshift.io/v2/convert", bytes.NewBuffer(bytesRepresentation))
if err != nil {
log.Fatalln(err)
}
request.Header.Set("Content-Type", "application/json")
request.Header.Set("Authorization", "Basic " + API_KEY)
resp, err := client.Do(request)
if err != nil {
log.Fatalln(err)
}
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalln(err)
}
// write the response to file
ioutil.WriteFile("wikipedia.pdf", body, 0644)
} else {
// An error occurred
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
log.Println(result)
log.Println(result["data"])
}
}
curl \
-u 'user_api_key:' \
-d source="https://en.wikipedia.org/wiki/PDF" \
-d landscape="false" \
-d use_print="false" \
https://api.pdfshift.io/v2/convert/ \
-o wikipedia.pdf
# That's all!
Features
Parallel conversions
Process multiple documents in parallel to increase conversion speed.
Asynchronous request
Use our powerful webhook system to be notified once a conversion is done.
Advanced Options
Set custom headers and footers with pagination, inject custom CSS and javascript, encrypt your documents and many more!
Raw HTML support
No need to make your private page public. Simply send us your raw HTML data instead and we will convert it.
High-Fidelity PDF
Generate a high-fidelity document, close to your original HTML, in a few seconds.
Privacy-focused
That's why your documents are not stored on our server (except when explicitly requested) and are not kept for more than 2 days.
They trust us.
See what our users have to say about PDFShift.
Stop rolling your own PDF generator - PDFShift has done it better.

Works exactly as advertised.

Easy and developer-oriented API.

Perfect rendering, easy to setup and use.

Super easy way to create PDFs.

Very easy and reliable.
Pricing
pricing plan tailored to your needs.
+ Custom HTTP Headers, Custom Header & Footer, Encryption, Watermark, Async, Parallel Conversion, HTML/CSS support...
All our features are available on all on our plans. We don't filter the features depending on your level of subscription...
Contact Our Sales Team
Our team is happy to answer your sales questions.
Fill out the form below and we will be in touch as soon as possible