Overview

The primary goal of this project is to make the service extremely fast in processing and the most cost-effective among existing alternatives. We continue to work on improving and enriching the service, and we have many ideas on how to expand the service to make it even more convenient and higher quality

PDF creation transforms from a cumbersome process into an easy and enjoyable task for application developers with 2PDF. Converting HTML and URLs into PDFs or images happens instantly, ensuring quality and speed without compromise.

This means that the cost of 1 second of computation (based on the average duration of the process), with a file size of 100Kb (based on the average response size), will be only $0.00118686.
Therefore, for $1, you can convert ~843 corresponding files

Speed and Quality

Our 2PDF service can convert HTML to PDF in less than 2 seconds! For example, the website google.com is converted in approximately 0.5-0.6 seconds. Thanks to the use of advanced rendering engines, we guarantee that your documents will be converted quickly and meet high standards of quality.

Flexibility in Settings

2PDF offers extensive options for customizing output documents. You can manage various parameters such as page orientation, dimensions, margins, and much more to achieve the perfect result.

Security and Confidentiality

All files processed through 2PDF are not stored on our servers. They are processed in the cloud and immediately sent to the client, ensuring a high level of data confidentiality and security.

Responsible Pricing Policy

All charges we incur directly support the cloud server capacities needed for our clients' operations. For an operation that lasts about 1 second, the cost is $0.00018686 per second and $0.01 per megabyte of traffic.

Technology and Development

Our service is built on a serverless cloud architecture, enhancing flexibility and scalability while minimizing overhead. We utilize modern programming languages such as Rust, C#, JavaScript, and C++ to ensure high performance and optimization. This diverse technology stack allows us to efficiently handle a wide range of document conversion tasks.

Who Would Benefit Most from 2PDF?

2PDF is particularly valuable for developers, IT professionals, and businesses that require efficient document handling and conversion capabilities. Legal professionals, educational institutions, marketing teams, and e-commerce platforms will find 2PDF essential for converting various document types like legal documents, course materials, promotional materials, and online catalogs into PDFs.

Types of Documents and Use Cases

  • Legal and Administrative: Contracts, case files, applications, and forms can be converted seamlessly, maintaining the integrity and layout of original documents.
  • Education: Convert educational materials such as lecture notes, assignments, and presentations into PDF format for easy distribution and printing.
  • Marketing and Sales: Create promotional PDFs from HTML campaign pages, convert sales presentations and market analyses.
  • E-commerce: Generate PDF invoices, receipts, or product catalogs directly from HTML pages.

Experience the advantages of 2PDF today and enhance the efficiency of your work with PDFs and images. Speed, affordability, security, and quality—all available in one convenient solution. If you have any questions or need assistance, our team is always ready to help. Make creating PDFs and images easy with 2PDF!

Quick Start

Here are provided basic examples of POST requests for converting the website https://google.com into a PDF document, demonstrated across various programming languages

            
                

curl -X POST "https://api.2pdf.io/v1/url/pdf" \
    -H "Authorization: Bearer {API_KEY}" \
    -H "Content-Type: application/json" \
    -d '{
        "source": "https://github.com",
        "grayscale": "",
        "page_size": "A4",
        "image_quality": 50
    }'    
            
        
        
            

import requests

response = requests.post('https://api.2pdf.io/v1/url/pdf',
                         headers={'Authorization': 'Bearer {API_KEY}'},
                         json={"source": "https://github.com", "grayscale": "", "page_size": "A4", "image_quality": 50})
print(response.content)
 
        
    
        
            

fetch('https://api.2pdf.io/v1/url/pdf', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer {API_KEY}',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    source: "https://github.com",
    grayscale: "",
    page_size: "A4",
    image_quality: 50
  })
})
.then(response => {
  if (!response.ok) {
    throw new Error('Network response was not ok');
  }
  return response.json();
})
.then(json => {
  console.log(json);
})
.catch(error => {
  console.error('There has been a problem with your fetch operation:', error);
});
 
        
    
        
            

$apiKey = '{API_KEY}';

$url = 'https://api.2pdf.io/v1/url/pdf';

$data = array(
    'source' => 'https://github.com',
    'grayscale' => '',
    'page_size' => 'A4',
    'image_quality' => 50
);

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Authorization: Bearer ' . $apiKey,
    'Content-Type: application/json'
));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    echo $response;
    curl_close($ch);
}
 
        
    
        
            

var apiKey = "{API_KEY}";
var url = "https://api.2pdf.io/v1/url/pdf";

using (var client = new HttpClient())
{
    client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", apiKey);

    var data = new
    {
        source = "https://github.com",
        grayscale = "",
        page_size = "A4",
        image_quality = 50
    };

    var content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");

    var response = await client.PostAsync(url, content);

    if (response.IsSuccessStatusCode)
    {
        var responseContent = await response.Content.ReadAsStringAsync();
        Console.WriteLine(responseContent);
    }
    else
    {
        Console.WriteLine($"Error: {response.StatusCode}");
    }
}
 
        
    
        
            

var apiKey = "{API_KEY}";
                                
var url = "https://api.2pdf.io/v1/url/pdf";

HttpClient client = HttpClient.newHttpClient();

HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create(url))
        .header("Authorization", "Bearer " + apiKey)
        .header("Content-Type", "application/json")
        .POST(BodyPublishers.ofString("{"
                + "\"source\": \"https://github.com\","
                + "\"grayscale\": \"\","
                + "\"page_size\": \"A4\","
                + "\"image_quality\": 50"
                + "}"))
        .build();

client.sendAsync(request, BodyHandlers.ofString())
        .thenApply(HttpResponse::body)
        .thenAccept(System.out::println)
        .join(); 
 
        
    
        
            

fetch('https://api.2pdf.io/v1/url/pdf', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer {API_KEY}',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    source: "https://github.com",
    grayscale: "",
    page_size: "A4",
    image_quality: 50
  })
})
.then(response => {
  if (!response.ok) {
    throw new Error('Network response was not ok');
  }
  return response.json();
})
.then(json => {
  console.log(json);
})
.catch(error => {
  console.error('There has been a problem with your fetch operation:', error);
});
 
        
    

Authentication

The 2PDF API requires API keys for request authentication. You can acquire your API key on the API Key page

Your API key functions similarly to a password - please ensure its security
API authentication is executed through the Bearer Token method within the Authorization header. Every API request must be conducted over HTTPS
Authorization: Bearer
To get API KEY you should log in and order a new API KEY by pressing "Get production licence" button in left side Profile area or here

Pricing

Immediately after registration, you will receive a Trial API Key which can be used for 30 documents to facilitate testing and trials

Free
  • Sign in required
  • 30 docs limit
  • No credit card needed
Pay-As-You-Go
  • No limit on documents
  • $0.00018686 / second of computation *
  • $0.01 / megabyte traffic
  • PDF documents
  • Image files

Support

If you have any questions or would like to discuss potential collaboration, please do not hesitate to reach out to us. We are open to various proposals and always ready to assist. Our team will respond to your inquiries promptly.

Send us an email at: support@2pdf.io

PDF from URL

This POST interface enables the creation of a PDF document from a web address

POST https://api.2pdf.io /v1/url/pdf
Request headers:
Authorization: Bearer {API_KEY}
Content-Type: application/json
Request body:


{
  "source": "https://google.com",
  "grayscale": "",
  "page_size": "A4",
  "image_quality": 50
}
                            
Parameter Type Default Description
source string required A valid web address. Can be with or without https://, www.
dpi int32 96 Determines image quality and size in a PDF
image_quality int32 94 Jpeg compressing images use this quality
page_size string A4 Set paper size to: A4, Letter, etc...
margin_bottom string 10 Set the page bottom margin (mm)
margin_left string 10 Set the page left margin (mm)
margin_right string 10 Set the page right margin (mm)
margin_top string 10 Set the page top margin (mm)
orientation string Portrait Set orientation to Landscape or Portrait
title string The title of the generated pdf file
no_background Do not print background
no_images Do not load or print images
grayscale PDF will be generated in grayscale
Response:
Content-Type: application/pdf
Errors:
Code Status Description
200 OK Request successful
400 Bad request Request was invalid
401 Unauthorized You are unauthorized or API_KEY is not valid
404 Not found Resource was not found
422 Unprocessable Entity Cannot perform the operation with the current request parameters
500 Internal server error Server error, try again later or contact support

PDF from URL

This GET interface enables the creation of a PDF document from a web address

GET https://api.2pdf.io /v1/url/pdf/?api_key= {API_KEY} &source= {URL}
Query string:
Parameter Default Description
api_key required Your API key functions similarly to a password - please ensure its security
source required A valid web address. Can be with or without https://, www.
dpi 96 Determines image quality and size in a PDF
image_quality 94 Jpeg compressing images use this quality
page_size A4 Set paper size to: A4, Letter, etc...
margin_bottom 10 Set the page bottom margin (mm)
margin_left 10 Set the page left margin (mm)
margin_right 10 Set the page right margin (mm)
margin_top 10 Set the page top margin (mm)
orientation Portrait Set orientation to Landscape or Portrait
title The title of the generated pdf file
no_background Do not print background
no_images Do not load or print images
grayscale PDF will be generated in grayscale
Response::
Content-Type: application/pdf

PDF from HTML

This POST interface enables the creation of a PDF document from a HTML content (or text)

POST https://api.2pdf.io /v1/html/pdf
Request headers::
Authorization: Bearer {API_KEY}
Content-Type: application/json
Request body::


{
  "source": "<p>This is 2PDF test document!</p>",
  "grayscale": "",
  "page_size": "A4",
  "image_quality": 50
}
                            
Parameter Type Default Description
source string required HTML content or text
dpi int32 96 Determines image quality and size in a PDF
image_quality int32 94 Jpeg compressing images use this quality
page_size string A4 Set paper size to: A4, Letter, etc...
margin_bottom string 10 Set the page bottom margin (mm)
margin_left string 10 Set the page left margin (mm)
margin_right string 10 Set the page right margin (mm)
margin_top string 10 Set the page top margin (mm)
orientation string Portrait Set orientation to Landscape or Portrait
title string The title of the generated pdf file
no_background Do not print background
no_images Do not load or print images
grayscale PDF will be generated in grayscale
Response::
Content-Type: application/pdf
Errors:
Code Status Description
200 OK Request successful
400 Bad request Request was invalid
401 Unauthorized You are unauthorized or API_KEY is not valid
404 Not found Resource was not found
422 Unprocessable Entity Cannot perform the operation with the current request parameters
500 Internal server error Server error, try again later or contact support

Image from URL

This POST interface enables the creation of a Image from a web address

POST https://api.2pdf.io /v1/url/image
Request headers::
Authorization: Bearer {API_KEY}
Content-Type: application/json
Request body::


{
  "source": "https://google.com",
  "grayscale": "",
  "page_size": "A4",
  "image_quality": 50
}
                            
Parameter Type Default Description
source string required A valid web address. Can be with or without https://, www.
crop_h int32 Set height for cropping
crop_w int32 Set width for cropping
crop_x int32 Set x coordinate for cropping
crop_y int32 Set y coordinate for cropping
format string PNG Output file format
width int32 1024 Set screen width
height int32 0 Set screen height (default is calculated from page content)
quality int32 89 Output image quality (between 0 and 100)
Response::
Content-Type: application/png
Errors:
Code Status Description
200 OK Request successful
400 Bad request Request was invalid
401 Unauthorized You are unauthorized or API_KEY is not valid
404 Not found Resource was not found
422 Unprocessable Entity Cannot perform the operation with the current request parameters
500 Internal server error Server error, try again later or contact support

Image from URL

This GET endpoint enables the creation of a Image from a web address

GET https://api.2pdf.io /v1/url/image/?api_key= {API_KEY} &source= {URL}
Query string:
Parameter Default Description
api_key required Your API key functions similarly to a password - please ensure its security
source required A valid web address. Can be with or without https://, www.
crop_h Set height for cropping
crop_w Set width for cropping
crop_x Set x coordinate for cropping
crop_y Set y coordinate for cropping
format PNG Output file format
width 1024 Set screen width
height 0 Set screen height (default is calculated from page content)
quality 89 Output image quality (between 0 and 100)
Response::
Content-Type: application/png

Image from HTML

This POST interface enables the creation of a Image from a HTML content (or text)

POST https://api.2pdf.io /v1/html/image
Request headers::
Authorization: Bearer {API_KEY}
Content-Type: application/json
Request body::


{
  "source": "<p>This is 2PDF test document!</p>",
  "grayscale": "",
  "page_size": "A4",
  "image_quality": 50
}
                            
Parameter Type Default Description
source string required A valid web address. Can be with or without https://, www.
crop_h int32 Set height for cropping
crop_w int32 Set width for cropping
crop_x int32 Set x coordinate for cropping
crop_y int32 Set y coordinate for cropping
format string PNG Output file format
width int32 1024 Set screen width
height int32 0 Set screen height (default is calculated from page content)
quality int32 89 Output image quality (between 0 and 100)
Response::
Content-Type: application/png
Errors:
Code Status Description
200 OK Request successful
400 Bad request Request was invalid
401 Unauthorized You are unauthorized or API_KEY is not valid
404 Not found Resource was not found
422 Unprocessable Entity Cannot perform the operation with the current request parameters
500 Internal server error Server error, try again later or contact support