Work with PDF files via API

Send your files to our API and we'll do all the heavy lifting for you.

Get started for FREE   → Get 50 credits. No credit card required.
                        import fetch from "node-fetch";
import FormData from "form-data";
import fs from "fs";

const fileStream = fs.createReadStream("path/to/file.pdf");

const formData = new FormData();
formData.append("file", fileStream);
formData.append("quality", 2);
formData.append("grayscale", 1);

const token = "your_api_token";

fetch("https://webpdf.xyz/api/v1/pdf/compress", {
  method: "POST",
  headers: {
    Accept: "application/json",
    Authorization: `Bearer ${token}`,
    ...formData.getHeaders(),
  },
  body: formData,
});
                        
                    
                        $curl = curl_init();

$apiToken = 'your_api_token';

curl_setopt_array($curl, array(
    CURLOPT_URL => "https://webpdf.xyz/api/v1/pdf/compress",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => array("file" => curl_file_create('path/to/file.pdf'), "quality" => 2, "grayscale" => true),
    CURLOPT_HTTPHEADER => array('Accept:application/json', "Authorization: Bearer {$apiToken}"),
));

$response = curl_exec($curl);
                        
                    
                            use Illuminate\Support\Facades\Http;

$response = Http::acceptJson()
    ->withToken('your_api_token')
    ->attach(
        'file', file_get_contents('path/to/file.pdf'), 'file.pdf')
    ->post(
        'https://webpdf.xyz/api/v1/pdf/compress',
        [
            'quality' => 2,
            'grayscale' => 0
        ]
    )
    ->json();
                        
                    
                            import requests

response = requests.post(
    'https://webpdf.xyz/api/v1/pdf/compress',
    headers={'Accept': 'application/json', 'Authorization': 'Bearer your_api_token'},
    files={'file': ('file.pdf', open('path/to/file.pdf', 'rb'), 'application/pdf')},
    data={'quality': 2, 'grayscale': 0}
).json()

print(response)
                        
                    
                            import okhttp3.*;

import java.io.File;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        OkHttpClient client = new OkHttpClient();

        RequestBody requestBody = new MultipartBody.Builder()
                .setType(MultipartBody.FORM)
                .addFormDataPart("file", "file.pdf",
                        RequestBody.create(MediaType.parse("application/pdf"), new File("path/to/file.pdf")))
                .addFormDataPart("quality", "2")
                .addFormDataPart("grayscale", "0")
                .build();

        Request request = new Request.Builder()
                .url("https://webpdf.xyz/api/v1/pdf/compress")
                .addHeader("Accept", "application/json")
                .addHeader("Authorization", "Bearer your_api_token")
                .post(requestBody)
                .build();
    }
}
                        
                    
                            require 'net/http'
require 'uri'
require 'json'
require 'mime/types'
require 'net/http/post/multipart'

url = URI.parse('https://webpdf.xyz/api/v1/pdf/compress')
file = File.open('path/to/file.pdf')

req = Net::HTTP::Post::Multipart.new url.path,
  "file" => UploadIO.new(file, "application/pdf", "file.pdf"),
  "quality" => '2',
  "grayscale" => '0'

req['Accept'] = 'application/json'
req['Authorization'] = 'Bearer your_api_token'

res = Net::HTTP.start(url.host, url.port, use_ssl: url.scheme == 'https') do |http|
  http.request(req)
end

file.close

                        
                    
                            package main

import (
    "bytes"
    "io"
    "mime/multipart"
    "net/http"
    "os"
)

func main() {
    file, _ := os.Open("path/to/file.pdf")
    defer file.Close()

    var requestBody bytes.Buffer
    writer := multipart.NewWriter(&requestBody)
    part, _ := writer.CreateFormFile("file", "file.pdf")
    io.Copy(part, file)
    writer.WriteField("quality", "2")
    writer.WriteField("grayscale", "0")
    writer.Close()

    req, _ := http.NewRequest("POST", "https://webpdf.xyz/api/v1/pdf/compress", &requestBody)
    req.Header.Set("Content-Type", writer.FormDataContentType())
    req.Header.Set("Accept", "application/json")
    req.Header.Set("Authorization", "Bearer your_api_token")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
}
                        
                    
                            use reqwest::Client;
use std::path::Path;

#[tokio::main]
async fn main() {
    let client = Client::new();
    let form = reqwest::multipart::Form::new()
        .file("file", "path/to/file.pdf")
        .unwrap()
        .text("quality", "2")
        .text("grayscale", "0");

    let res = client.post("https://webpdf.xyz/api/v1/pdf/compress")
        .bearer_auth("your_api_token")
        .multipart(form)
        .send()
        .await
        .unwrap();

    let body = res.text().await.unwrap();
    println!("{}", body);
}
                        
                    
                            curl -X POST https://webpdf.xyz/api/v1/pdf/compress \
     -H "Accept: application/json" \
     -H "Authorization: Bearer your_api_token" \
     -F "file=@path/to/file.pdf" \
     -F "quality=2" \
     -F "grayscale=0"
                        
                    

The Features
You Love & Need

We squeeze all the juice from any PDF.
Here are the most important features.

PDF Compress

Shrink big PDF files into smaller file sizes based on your printing or quality needs.

Merge or split PDF

Merge multiple PDF files into one, or split a big PDF file into smaller chunks.

Extract data from PDF

Get raw text, full scale images, metadata from any PDF file so you can use them into your application.

OCR PDF

Turn any image based PDF into text, make it searchable, scale pages to the correct size.

Protect or Unlock PDF

Password protect your PDF files and even remove the password from existing PDFs.

Convert PDF to image

Turn PDFs into high resolution images to use them accross your application.

Flexible Plans

Tailored subscription plans to fit your ever-changing needs.
Use your montly credits for any operation you want.

Free

$ 0 / month


  • Web tools
  • API
  • 50 credits / month
  • Max 5 MB / file
  • Max 5 files / request
  • Max 10 req. / minute
  • Async processing
  • Callback URL
  • Support
Get Started

Starter

$ 4 / month


  • Web tools
  • API
  • 2000 credits / month
  • Max 30 MB / file
  • Max 5 files / request
  • Max 30 req. / minute
  • Async processing
  • Callback URL
  • Email support
Choose Plan

Pro

$ 12 / month


  • Web tools
  • API
  • 7500 credits / month
  • Max 75 MB / file
  • Max 10 files / request
  • Max 60 req. / minute
  • Async processing
  • Callback URL
  • Priority support
Choose Plan

Popular

Expert

$ 24 / month


  • Web tools
  • API
  • 20000 credits / month
  • Max 150 MB / file
  • Max 10 files / request
  • Max 120 req. / minute
  • Async processing
  • Callback URL
  • Priority support
Choose Plan

Looking for more?

WebPDF can help you scale with higher volume plans. Ask us about a dedicated plan.

Contact us

Spend Credits
Based On Your Needs

You get charged only for successful requests.

  • Change PDF images DPI

    5 credits/req.
    requests
  • Change PDF version

    1 credits/req.
    requests
  • Compress PDF

    5 credits/req.
    requests
  • Convert PDF to image

    5 credits/req.
    requests
  • Protect PDF against copy & paste

    5 credits/req.
    requests
  • Extract metadata from PDF

    1 credits/req.
    requests
  • Extract images from PDF

    5 credits/req.
    requests
  • Extract text from PDF

    3 credits/req.
    requests
  • Flatten PDF Forms

    1 credits/req.
    requests
  • Flatten PDF Annotations

    1 credits/req.
    requests
  • Grayscale PDF

    2 credits/req.
    requests
  • OCR PDF

    5 credits/req.
    requests
  • Merge multiple PDFs

    5 credits/req.
    requests
  • Password protect PDF

    2 credits/req.
    requests
  • Remove PDF pages

    5 credits/req.
    requests
  • Rescale PDF page size

    2 credits/req.
    requests
  • Fix PDF page orientation

    2 credits/req.
    requests
  • Split PDF into multiple

    5 credits/req.
    requests
  • Unlock PDF

    3 credits/req.
    requests
  • Watermark PDF pages

    2 credits/req.
    requests
  • Optimize PDF for web

    3 credits/req.
    requests

Not looking for an API?
We got web tools too!

Try them for FREE without an account.