Overview
apilayer pdflayer provides an API for converting HTML and URLs into PDF documents. It targets developers and businesses that need to automate the creation of PDF files from dynamic web content or structured HTML. The service offers two primary conversion methods: converting a URL directly into a PDF or rendering raw HTML input into a PDF. This functionality is applicable in scenarios such as generating invoices, creating reports, archiving web pages, or producing printable versions of user-generated content.
The API is accessed via standard HTTP GET requests, with parameters passed in the URL query string. This design aims to simplify integration into various programming environments. Developers can specify output settings like page dimensions (e.g., A4, Letter), orientation (portrait or landscape), margins, and custom CSS to control the final appearance of the PDF. For example, a web application might use pdflayer to automatically generate a PDF receipt immediately after a transaction, pulling order details from a database and rendering them into a formatted PDF document. Another use case involves content management systems that need to offer a 'print to PDF' option for articles or blog posts, ensuring consistent formatting across different devices and browsers.
pdflayer also includes features to handle dynamic content, such as waiting for JavaScript to execute on a web page before conversion, which is crucial for modern single-page applications or pages with interactive elements. This ensures that the generated PDF accurately reflects the fully loaded state of the web page. The API supports various image formats within the HTML, and it can handle complex layouts, aiming to maintain the visual integrity of the original web content. The service is part of the apilayer suite of APIs, which are designed to provide various microservices for developers. According to apilayer's documentation, the HTML to PDF API is regularly updated to support modern web standards and rendering engines, which is critical for accurate PDF generation from contemporary web designs.
Beyond basic conversion, pdflayer allows for header and footer customization, enabling the addition of page numbers, company logos, or legal disclaimers to every page of the generated PDF. This level of control is important for professional documents and compliance requirements. For larger volumes, the API is designed to handle concurrent requests, supporting automated workflows where many PDFs need to be generated in a short period. This makes it suitable for batch processing tasks, such as generating monthly statements for all customers or archiving an entire website's content on a scheduled basis. For developers interested in comparing different PDF generation services, resources like DocRaptor's conversion examples can offer insights into alternative approaches and capabilities in the market.
Key features
- HTML to PDF Conversion: Converts raw HTML code directly into a PDF document, allowing for dynamic content generation.
- URL to PDF Conversion: Renders any publicly accessible URL into a PDF file, useful for archiving web pages or creating printable versions of online content.
- Customizable Output: Control PDF page size (e.g., A4, Letter), orientation (portrait/landscape), margins, and scaling.
- CSS and JavaScript Support: Processes CSS styles for accurate rendering and waits for JavaScript execution to ensure dynamic content is included in the PDF.
- Header and Footer Customization: Add custom headers and footers to generated PDFs, including page numbers, dates, or branding elements.
- Asynchronous Conversion: Supports converting large or complex web pages asynchronously, preventing timeouts and improving reliability.
- Secure Access: API requests are secured via HTTPS, encrypting data in transit.
- Cross-Language Compatibility: Provides clear examples and documentation for integration across multiple programming languages, including PHP, Python, and Ruby.
Pricing
apilayer pdflayer offers a tiered pricing model, including a free tier and several paid plans that scale with the number of API requests. Pricing details are current as of May 2026. For the most up-to-date information, refer to the pdflayer pricing page.
| Plan Name | Monthly Requests | Monthly Price | Key Features |
|---|---|---|---|
| Free | 100 | $0 | Basic HTML/URL to PDF conversion |
| Basic | 2,000 | $9.99 | All Free features, increased request volume |
| Professional | 10,000 | $29.99 | All Basic features, higher request volume, priority support |
| Business | 50,000 | $69.99 | All Professional features, significantly higher request volume |
| Enterprise | Custom | Custom | Scalable volume, dedicated support, custom features |
Common integrations
pdflayer primarily functions as a standalone API, accessible via HTTP requests from any programming language or environment capable of making web calls. Its integration typically involves embedding API calls within custom applications or workflows rather than direct, pre-built connectors with specific third-party services. Developers integrate pdflayer by:
- Web Applications: Back-end services (e.g., Node.js, Python/Django, Ruby on Rails, PHP/Laravel) can call the pdflayer API to generate dynamic PDFs for users, such as invoices, reports, or downloadables.
- CRM/ERP Systems: Custom integrations can automate the generation of client-specific documents directly from data stored within CRM (e.g., Salesforce via a custom Apex trigger) or ERP systems.
- Cloud Functions/Serverless: Deploying pdflayer API calls within serverless functions (e.g., AWS Lambda, Google Cloud Functions) for on-demand PDF generation triggered by events.
- Workflow Automation Platforms: Although no direct connectors are listed, platforms like Tray.io or Zapier can be configured with custom HTTP modules to interact with the pdflayer API for automated document workflows. Developers can configure Tray.io connectors to send HTTP requests to pdflayer based on triggers from other services.
- Content Management Systems: Integrating into CMS platforms (e.g., WordPress with custom plugins, headless CMS) to provide a 'download as PDF' option for articles or pages.
Alternatives
- PDFShift: Offers a similar HTML to PDF conversion API with a focus on ease of use and high-quality rendering.
- DocRaptor: Provides robust HTML to PDF and XLS conversion, known for its advanced CSS support and print-quality output.
- ConvertAPI: A versatile file conversion API that supports a wide range of formats, including HTML to PDF, with extensive documentation.
- Google Cloud Document AI: While not a direct HTML to PDF converter, it offers capabilities for processing and extracting data from documents, which can be part of a broader document workflow.
- Puppeteer (Headless Chrome): An open-source Node.js library that provides a high-level API to control headless Chrome or Chromium, capable of generating PDFs from web pages programmatically.
Getting started
To begin using pdflayer, you need an API access key, which is obtained upon signing up for an account on their website. The API is primarily accessed via HTTP GET requests. Below is a cURL example demonstrating how to convert a URL into a PDF, followed by a Python example for converting raw HTML.
cURL Example: Convert a URL to PDF
This example demonstrates how to convert a public URL into a PDF. Replace YOUR_ACCESS_KEY with your actual API key.
curl "https://api.pdflayer.com/api/convert?access_key=YOUR_ACCESS_KEY&url=https://apispine.com&fullpage=1&landscape=0"
Python Example: Convert HTML to PDF
This Python snippet uses the requests library to send raw HTML content for conversion into a PDF. The html parameter should be URL-encoded for best practice.
import requests
import urllib.parse
ACCESS_KEY = 'YOUR_ACCESS_KEY'
html_content = """
<!DOCTYPE html>
<html>
<head>
<title>My PDF Document</title>
<style>
body { font-family: Arial, sans-serif; margin: 50px; }
h1 { color: #333; }
p { color: #666; font-size: 14px; }
</style>
</head>
<body>
<h1>Welcome to apispine!</h1>
<p>This is a sample PDF generated from HTML using apilayer pdflayer.</p>
<p>Current date: May 28, 2026</p>
</body>
</html>
"""
# URL-encode the HTML content
encoded_html = urllib.parse.quote(html_content)
api_url = f"https://api.pdflayer.com/api/convert?access_key={ACCESS_KEY}&html={encoded_html}&fullpage=1&output=json"
try:
response = requests.get(api_url, stream=True)
response.raise_for_status() # Raise an exception for HTTP errors
# If the API returns a direct PDF stream
if 'application/pdf' in response.headers.get('Content-Type', ''):
with open('output.pdf', 'wb') as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
print("PDF generated successfully as output.pdf")
else:
# If the API returns a JSON response (e.g., with a download URL or error)
print("API response:")
print(response.json())
except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")
For more detailed information and additional language examples, refer to the pdflayer API documentation.