PDF Generation
Convert any web page into a high-quality PDF document. Perfect for archiving, reporting, and document generation.
Overview
Convert any web page to a PDF document by setting response_type=pdf. The API renders the page using a headless Chrome browser and generates a high-quality PDF.
TIP — Best Practice
Enable JavaScript rendering (
js=true) for pages that load content dynamically to ensure all content is captured in the PDF.
Basic Request
Set response_type=pdf to generate a PDF of the web page.
GET https://api.ujeebu.com/scrape?response_type=pdf
curl -X GET 'https://api.ujeebu.com/scrape?url=https://example.com&response_type=pdf&js=true' \
-H "ApiKey: YOUR_API_KEY" \
-o page.pdfconst fs = require('fs');
const response = await fetch(
'https://api.ujeebu.com/scrape?url=https://example.com&response_type=pdf&js=true',
{
headers: { 'ApiKey': 'YOUR_API_KEY' }
}
);
const buffer = await response.arrayBuffer();
fs.writeFileSync('page.pdf', Buffer.from(buffer));import { UjeebuClient } from '@ujeebu-org/ujeebu-sdk';
import fs from 'fs';
const client = new UjeebuClient(process.env.UJEEBU_API_KEY);
const pdf = await client.getPdf('https://example.com', {
js: true
});
fs.writeFileSync('page.pdf', pdf);import requests
response = requests.get(
'https://api.ujeebu.com/scrape',
params={
'url': 'https://example.com',
'response_type': 'pdf',
'js': 'true'
},
headers={'ApiKey': 'YOUR_API_KEY'}
)
with open('page.pdf', 'wb') as f:
f.write(response.content)from ujeebu_python import UjeebuClient
ujeebu = UjeebuClient(api_key="YOUR_API_KEY")
pdf = ujeebu.get_pdf(
url='https://example.com',
params={'js': True}
)
with open('page.pdf', 'wb') as f:
f.write(pdf)import okhttp3.*;
import java.io.*;
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.ujeebu.com/scrape?url=https://example.com&response_type=pdf&js=true")
.addHeader("ApiKey", "YOUR_API_KEY")
.build();
Response response = client.newCall(request).execute();
// Save to file
try (FileOutputStream fos = new FileOutputStream("page.pdf")) {
fos.write(response.body().bytes());
}<?php
$url = 'https://api.ujeebu.com/scrape?' . http_build_query([
'url' => 'https://example.com',
'response_type' => 'pdf',
'js' => 'true'
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'ApiKey: YOUR_API_KEY'
]);
$pdf = curl_exec($ch);
curl_close($ch);
file_put_contents('page.pdf', $pdf);package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
url := "https://api.ujeebu.com/scrape?url=https://example.com&response_type=pdf&js=true"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("ApiKey", "YOUR_API_KEY")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
// Save to file
file, _ := os.Create("page.pdf")
defer file.Close()
io.Copy(file, resp.Body)
fmt.Println("PDF saved successfully")
}package main
import (
"fmt"
"os"
"github.com/ujeebu/ujeebu-go"
)
func main() {
client, _ := ujeebu.NewClient("YOUR-API-KEY")
pdf, credits, err := client.PDF(ujeebu.ScrapeParams{
URL: "https://example.com",
JS: true,
})
if err != nil {
panic(err)
}
// Save to file
err = os.WriteFile("page.pdf", pdf, 0644)
if err != nil {
panic(err)
}
fmt.Printf("PDF saved successfully. Credits used: %d\n", credits)
}Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url |
string |
Yes | - |
The URL to convert to PDF. |
response_type |
string |
Yes | html |
Set to 'pdf' to generate a PDF. |
js |
boolean |
No | false |
Enable JavaScript rendering before PDF generation. |
wait_for |
`string | number` | No | null |
timeout |
number |
No | 60 |
Maximum seconds before request timeout. |
block_ads |
boolean |
No | false |
Block advertisements in the PDF. |
block_resources |
boolean |
No | false |
Block images, CSS, fonts for faster generation. |
json |
boolean |
No | false |
Return PDF as base64-encoded JSON instead of binary. |
proxy_type |
string |
No | rotating |
Proxy type: 'rotating', 'premium', 'residential', 'custom'. |
Response Formats
Binary Response (Default)
By default, the API returns the PDF as binary data with Content-Type: application/pdf. Save it directly to a file.
JSON Response
When json=true, the PDF is returned as a base64-encoded string:
{
"success": true,
"pdf": "JVBERi0xLjQKJeLjz9MKNCAwIG9iaiAKPDwKL1N1YnR5cGUgL0xpbms...",
"screenshot": null,
"html_source": null,
"html": null
}
curl -X GET 'https://api.ujeebu.com/scrape?url=https://example.com&response_type=pdf&json=true' \
-H "ApiKey: YOUR_API_KEY"const response = await fetch(
'https://api.ujeebu.com/scrape?url=https://example.com&response_type=pdf&json=true',
{ headers: { 'ApiKey': 'YOUR_API_KEY' } }
);
const data = await response.json();
const pdfBuffer = Buffer.from(data.pdf, 'base64');
fs.writeFileSync('page.pdf', pdfBuffer);import { UjeebuClient } from '@ujeebu-org/ujeebu-sdk';
import fs from 'fs';
const client = new UjeebuClient(process.env.UJEEBU_API_KEY);
// SDK returns binary by default
const pdf = await client.getPdf('https://example.com', {
js: true
});
fs.writeFileSync('page.pdf', pdf);import requests
import base64
response = requests.get(
'https://api.ujeebu.com/scrape',
params={'url': 'https://example.com', 'response_type': 'pdf', 'json': 'true'},
headers={'ApiKey': 'YOUR_API_KEY'}
)
data = response.json()
pdf_bytes = base64.b64decode(data['pdf'])
with open('page.pdf', 'wb') as f:
f.write(pdf_bytes)from ujeebu_python import UjeebuClient
ujeebu = UjeebuClient(api_key="YOUR_API_KEY")
# SDK returns binary by default
pdf = ujeebu.get_pdf(
url='https://example.com',
params={'js': True}
)
with open('page.pdf', 'wb') as f:
f.write(pdf)import okhttp3.*;
import org.json.*;
import java.util.Base64;
import java.io.*;
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.ujeebu.com/scrape?url=https://example.com&response_type=pdf&json=true")
.addHeader("ApiKey", "YOUR_API_KEY")
.build();
Response response = client.newCall(request).execute();
JSONObject data = new JSONObject(response.body().string());
// Decode base64 PDF
byte[] pdfBytes = Base64.getDecoder().decode(data.getString("pdf"));
// Save to file
try (FileOutputStream fos = new FileOutputStream("page.pdf")) {
fos.write(pdfBytes);
}<?php
$url = 'https://api.ujeebu.com/scrape?' . http_build_query([
'url' => 'https://example.com',
'response_type' => 'pdf',
'json' => 'true'
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['ApiKey: YOUR_API_KEY']);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
$pdfBytes = base64_decode($data['pdf']);
file_put_contents('page.pdf', $pdfBytes);package main
import (
"encoding/base64"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
)
func main() {
url := "https://api.ujeebu.com/scrape?url=https://example.com&response_type=pdf&json=true"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("ApiKey", "YOUR_API_KEY")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
var result map[string]interface{}
json.Unmarshal(body, &result)
// Decode base64 PDF
pdfBytes, _ := base64.StdEncoding.DecodeString(result["pdf"].(string))
// Save to file
os.WriteFile("page.pdf", pdfBytes, 0644)
fmt.Println("PDF saved successfully")
}package main
import (
"fmt"
"os"
"github.com/ujeebu/ujeebu-go"
)
func main() {
client, _ := ujeebu.NewClient("YOUR-API-KEY")
// SDK returns binary by default
pdf, credits, _ := client.PDF(ujeebu.ScrapeParams{
URL: "https://example.com",
JS: true,
})
os.WriteFile("page.pdf", pdf, 0644)
fmt.Printf("PDF saved successfully. Credits used: %d\n", credits)
}Use Cases
Report Generation
Generate PDF reports from dynamic dashboards:
curl -X GET 'https://api.ujeebu.com/scrape?url=https://dashboard.example.com/report&response_type=pdf&js=true&wait_for=.chart-loaded' \
-H "ApiKey: YOUR_API_KEY" \
-o report.pdfconst fs = require('fs');
const response = await fetch(
'https://api.ujeebu.com/scrape?url=https://dashboard.example.com/report&response_type=pdf&js=true&wait_for=.chart-loaded',
{ headers: { 'ApiKey': 'YOUR_API_KEY' } }
);
const buffer = await response.arrayBuffer();
fs.writeFileSync('report.pdf', Buffer.from(buffer));import { UjeebuClient } from '@ujeebu-org/ujeebu-sdk';
import fs from 'fs';
const client = new UjeebuClient(process.env.UJEEBU_API_KEY);
const pdf = await client.getPdf('https://dashboard.example.com/report', {
js: true,
wait_for: '.chart-loaded'
});
fs.writeFileSync('report.pdf', pdf);import requests
response = requests.get(
'https://api.ujeebu.com/scrape',
params={
'url': 'https://dashboard.example.com/report',
'response_type': 'pdf',
'js': 'true',
'wait_for': '.chart-loaded'
},
headers={'ApiKey': 'YOUR_API_KEY'}
)
with open('report.pdf', 'wb') as f:
f.write(response.content)from ujeebu_python import UjeebuClient
ujeebu = UjeebuClient(api_key="YOUR_API_KEY")
pdf = ujeebu.get_pdf(
url='https://dashboard.example.com/report',
params={'js': True, 'wait_for': '.chart-loaded'}
)
with open('report.pdf', 'wb') as f:
f.write(pdf)import okhttp3.*;
import java.io.*;
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.ujeebu.com/scrape?url=https://dashboard.example.com/report&response_type=pdf&js=true&wait_for=.chart-loaded")
.addHeader("ApiKey", "YOUR_API_KEY")
.build();
Response response = client.newCall(request).execute();
try (FileOutputStream fos = new FileOutputStream("report.pdf")) {
fos.write(response.body().bytes());
}<?php
$url = 'https://api.ujeebu.com/scrape?' . http_build_query([
'url' => 'https://dashboard.example.com/report',
'response_type' => 'pdf',
'js' => 'true',
'wait_for' => '.chart-loaded'
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['ApiKey: YOUR_API_KEY']);
$pdf = curl_exec($ch);
curl_close($ch);
file_put_contents('report.pdf', $pdf);package main
import (
"io"
"net/http"
"os"
)
func main() {
url := "https://api.ujeebu.com/scrape?url=https://dashboard.example.com/report&response_type=pdf&js=true&wait_for=.chart-loaded"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("ApiKey", "YOUR_API_KEY")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
file, _ := os.Create("report.pdf")
defer file.Close()
io.Copy(file, resp.Body)
}package main
import (
"os"
"github.com/ujeebu/ujeebu-go"
)
func main() {
client, _ := ujeebu.NewClient("YOUR-API-KEY")
pdf, _, _ := client.PDF(ujeebu.ScrapeParams{
URL: "https://dashboard.example.com/report",
JS: true,
WaitFor: ".chart-loaded",
})
os.WriteFile("report.pdf", pdf, 0644)
}Invoice Archiving
Archive web-based invoices as PDF documents:
curl -X GET 'https://api.ujeebu.com/scrape?url=https://billing.example.com/invoice/12345&response_type=pdf&js=true' \
-H "ApiKey: YOUR_API_KEY" \
-H "UJB-Cookie: session=abc123" \
-o invoice.pdfconst fs = require('fs');
const response = await fetch(
'https://api.ujeebu.com/scrape?url=https://billing.example.com/invoice/12345&response_type=pdf&js=true',
{
headers: {
'ApiKey': 'YOUR_API_KEY',
'UJB-Cookie': 'session=abc123'
}
}
);
const buffer = await response.arrayBuffer();
fs.writeFileSync('invoice.pdf', Buffer.from(buffer));import { UjeebuClient } from '@ujeebu-org/ujeebu-sdk';
import fs from 'fs';
const client = new UjeebuClient(process.env.UJEEBU_API_KEY);
const pdf = await client.getPdf(
'https://billing.example.com/invoice/12345',
{ js: true },
{ 'UJB-Cookie': 'session=abc123' }
);
fs.writeFileSync('invoice.pdf', pdf);import requests
response = requests.get(
'https://api.ujeebu.com/scrape',
params={
'url': 'https://billing.example.com/invoice/12345',
'response_type': 'pdf',
'js': 'true'
},
headers={
'ApiKey': 'YOUR_API_KEY',
'UJB-Cookie': 'session=abc123'
}
)
with open('invoice.pdf', 'wb') as f:
f.write(response.content)from ujeebu_python import UjeebuClient
ujeebu = UjeebuClient(api_key="YOUR_API_KEY")
pdf = ujeebu.get_pdf(
url='https://billing.example.com/invoice/12345',
params={'js': True},
headers={'UJB-Cookie': 'session=abc123'}
)
with open('invoice.pdf', 'wb') as f:
f.write(pdf)import okhttp3.*;
import java.io.*;
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.ujeebu.com/scrape?url=https://billing.example.com/invoice/12345&response_type=pdf&js=true")
.addHeader("ApiKey", "YOUR_API_KEY")
.addHeader("UJB-Cookie", "session=abc123")
.build();
Response response = client.newCall(request).execute();
try (FileOutputStream fos = new FileOutputStream("invoice.pdf")) {
fos.write(response.body().bytes());
}<?php
$url = 'https://api.ujeebu.com/scrape?' . http_build_query([
'url' => 'https://billing.example.com/invoice/12345',
'response_type' => 'pdf',
'js' => 'true'
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'ApiKey: YOUR_API_KEY',
'UJB-Cookie: session=abc123'
]);
$pdf = curl_exec($ch);
curl_close($ch);
file_put_contents('invoice.pdf', $pdf);package main
import (
"io"
"net/http"
"os"
)
func main() {
url := "https://api.ujeebu.com/scrape?url=https://billing.example.com/invoice/12345&response_type=pdf&js=true"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("ApiKey", "YOUR_API_KEY")
req.Header.Set("UJB-Cookie", "session=abc123")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
file, _ := os.Create("invoice.pdf")
defer file.Close()
io.Copy(file, resp.Body)
}package main
import (
"os"
"github.com/ujeebu/ujeebu-go"
)
func main() {
client, _ := ujeebu.NewClient("YOUR-API-KEY")
pdf, _, _ := client.PDF(ujeebu.ScrapeParams{
URL: "https://billing.example.com/invoice/12345",
JS: true,
Headers: map[string]string{
"UJB-Cookie": "session=abc123",
},
})
os.WriteFile("invoice.pdf", pdf, 0644)
}Web Page Archiving
Create PDF archives of web pages for compliance or records:
curl -X GET 'https://api.ujeebu.com/scrape?url=https://news.example.com/article&response_type=pdf&js=true&block_ads=true' \
-H "ApiKey: YOUR_API_KEY" \
-o article.pdfconst fs = require('fs');
const response = await fetch(
'https://api.ujeebu.com/scrape?url=https://news.example.com/article&response_type=pdf&js=true&block_ads=true',
{ headers: { 'ApiKey': 'YOUR_API_KEY' } }
);
const buffer = await response.arrayBuffer();
fs.writeFileSync('article.pdf', Buffer.from(buffer));import { UjeebuClient } from '@ujeebu-org/ujeebu-sdk';
import fs from 'fs';
const client = new UjeebuClient(process.env.UJEEBU_API_KEY);
const pdf = await client.getPdf('https://news.example.com/article', {
js: true,
block_ads: true
});
fs.writeFileSync('article.pdf', pdf);import requests
response = requests.get(
'https://api.ujeebu.com/scrape',
params={
'url': 'https://news.example.com/article',
'response_type': 'pdf',
'js': 'true',
'block_ads': 'true'
},
headers={'ApiKey': 'YOUR_API_KEY'}
)
with open('article.pdf', 'wb') as f:
f.write(response.content)from ujeebu_python import UjeebuClient
ujeebu = UjeebuClient(api_key="YOUR_API_KEY")
pdf = ujeebu.get_pdf(
url='https://news.example.com/article',
params={'js': True, 'block_ads': True}
)
with open('article.pdf', 'wb') as f:
f.write(pdf)import okhttp3.*;
import java.io.*;
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.ujeebu.com/scrape?url=https://news.example.com/article&response_type=pdf&js=true&block_ads=true")
.addHeader("ApiKey", "YOUR_API_KEY")
.build();
Response response = client.newCall(request).execute();
try (FileOutputStream fos = new FileOutputStream("article.pdf")) {
fos.write(response.body().bytes());
}<?php
$url = 'https://api.ujeebu.com/scrape?' . http_build_query([
'url' => 'https://news.example.com/article',
'response_type' => 'pdf',
'js' => 'true',
'block_ads' => 'true'
]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['ApiKey: YOUR_API_KEY']);
$pdf = curl_exec($ch);
curl_close($ch);
file_put_contents('article.pdf', $pdf);package main
import (
"io"
"net/http"
"os"
)
func main() {
url := "https://api.ujeebu.com/scrape?url=https://news.example.com/article&response_type=pdf&js=true&block_ads=true"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("ApiKey", "YOUR_API_KEY")
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
file, _ := os.Create("article.pdf")
defer file.Close()
io.Copy(file, resp.Body)
}package main
import (
"os"
"github.com/ujeebu/ujeebu-go"
)
func main() {
client, _ := ujeebu.NewClient("YOUR-API-KEY")
pdf, _, _ := client.PDF(ujeebu.ScrapeParams{
URL: "https://news.example.com/article",
JS: true,
BlockAds: true,
})
os.WriteFile("article.pdf", pdf, 0644)
}Spin up an API key in 60 seconds
Free tier: 5,000 credits, no card, full access to every endpoint on this page.