DEV Community

GuGuData
GuGuData

Posted on

HTML to PDF API by GuGuData: Effortlessly Convert Web Pages to PDF

HTML to PDF API by GuGuData: Effortlessly Convert Web Pages to PDF

GuGuData's HTML to PDF API provides a seamless solution for developers and businesses looking to convert HTML content or web pages into PDF documents efficiently. This powerful API supports converting both HTML strings and URLs into high-quality PDFs, making it an essential tool for web content archiving, reporting, and document generation.

Why Choose GuGuData’s HTML to PDF API?

Our HTML to PDF API is designed with advanced features to ensure efficient and high-quality PDF generation:

1. Superior Conversion Efficiency

Experience exceptional performance with our API's superior conversion efficiency, enabling rapid generation of PDFs from HTML content or web pages.

2. Supports HTML and URL Conversion

Whether you have raw HTML content or a URL of a web page, our API can handle both. This flexibility allows you to convert dynamic web pages or static HTML content into PDFs effortlessly.

3. Preserves CSS Styling

Our API fully supports CSS styling within HTML content, ensuring that the converted PDFs retain the original look and feel of the web page or HTML document.

4. Provides Permanent Links

Each converted PDF comes with a permanent storage file address, making it easy to share, access, and integrate into your applications or workflows.

5. Secure and Compliant

With full support for HTTPS (TLS v1.0 / v1.1 / v1.2 / v1.3) and compatibility with Apple ATS, our API ensures secure data transmission and compliance with industry standards.

6. Nationwide Multi-Node CDN Deployment

Our API is deployed across multiple CDN nodes nationwide, ensuring fast and reliable access with minimal latency.

7. Fast API Response Times

Thanks to load balancing across multiple servers, our API delivers extremely fast response times, even under heavy load.


Key Features

  • Efficient PDF Generation: High-performance conversion engine for rapid PDF generation.
  • Supports HTML and URLs: Convert both HTML strings and web page URLs into PDFs.
  • CSS Styling Support: Maintains the original styling of HTML content in the PDF.
  • Permanent PDF Links: Access your converted PDFs via permanent URLs.
  • HTTPS and TLS Support: Secure data transmission with full HTTPS and TLS support.
  • Apple ATS Compatible: Fully compatible with Apple's App Transport Security.
  • Nationwide CDN: Fast and reliable API access with nationwide CDN deployment.
  • Load Balancing: Optimized performance through multi-server load balancing.

API Documentation

The HTML to PDF API is straightforward to use and integrates seamlessly with your existing applications. Below are the details on how to implement the API.

API Endpoint

To convert HTML content or a URL to PDF, make a POST request to the following endpoint:

POST https://api.gugudata.io/v1/imagerecognition/html2pdf
Content-Type: application/json; charset=utf-8
Enter fullscreen mode Exit fullscreen mode

For testing purposes, you can use our demo endpoint:

https://api.gugudata.io/v1/imagerecognition/html2pdf/demo
Enter fullscreen mode Exit fullscreen mode

Request Parameters

Parameter Name Type Required Default Value Description
appkey string Yes YOUR_APPKEY The APPKEY obtained after registration.
type string Yes YOUR_VALUE Defines the input type. Options are HTML or URL. Note: If type is URL, ensure that the page is publicly accessible and not protected by authentication or anti-crawling mechanisms.
content string Yes YOUR_VALUE The content to convert. If type=HTML, provide the HTML content string. If type=URL, provide the URL of the web page to convert.
landscape integer No 0 Controls the page orientation of the generated PDF. Use 1 for landscape mode and 0 (default) for portrait mode.

Sample Request

{
  "appkey": "YOUR_APPKEY",
  "type": "HTML",
  "content": "<html><body><h1>Hello, World!</h1></body></html>",
  "landscape": 0
}
Enter fullscreen mode Exit fullscreen mode

Response Parameters

Parameter Name Type Description
DataStatus.StatusCode int API response status code.
DataStatus.StatusDescription string Description of the status code.
DataStatus.ResponseDateTime string Timestamp of the response.
DataStatus.DataTotalCount int Total data count, generally used for pagination calculations.
Data string Permanent link to the converted PDF file.

Sample Response

{
  "DataStatus": {
    "StatusCode": 100,
    "StatusDescription": "Normal return",
    "ResponseDateTime": "2021-05-13T00:00:00Z",
    "DataTotalCount": 1
  },
  "Data": "https://yourpdfstorage.com/path/to/converted.pdf"
}
Enter fullscreen mode Exit fullscreen mode

How to Get Started

  1. Obtain Your APPKEY: Register at GuGuData to obtain your APPKEY for API authentication.

  2. Choose Input Type: Decide whether you will convert HTML content or a web page URL.

  3. Make a POST Request: Send a POST request to the API endpoint with the required parameters.

  4. Retrieve PDF Link: Receive the permanent link to your converted PDF in the API response.

  5. Integrate and Automate: Incorporate the API into your applications or workflows for automated PDF generation.


Use Cases

  • Web Content Archiving: Save web pages as PDFs for archival purposes.
  • Dynamic Report Generation: Convert HTML reports into PDFs for distribution.
  • Automated Invoice Generation: Generate PDFs from HTML templates for invoicing systems.
  • Content Sharing: Easily share web content in PDF format via permanent links.

Conclusion

GuGuData's HTML to PDF API is an efficient and reliable solution for converting HTML content or web pages into PDF documents. With its high performance, support for CSS styling, and provision of permanent PDF links, it simplifies the process of PDF generation for a variety of applications.

Get started with GuGuData's HTML to PDF API today! and streamline your PDF conversion process with ease.

Top comments (0)