Unparalleled suite of productivity-boosting Web APIs & cloud-based micro-service applications for developers and companies of any size.

APIAutomation

How to Use the ScreenshotLayer and PDFLayer APIs to Create a Web Page Archiver

How to Use the ScreenshotLayer and PDFLayer APIs to Create a Web Page Archiver

In today’s digital age, preserving web pages is critical for a variety of reasons, including compliance, research, and record-keeping. The ScreenshotLayer and PDFLayer APIs make it easier to build a powerful web page archiver. This post will walk you through the steps required to develop a web page archiver and demonstrate the capabilities of these two APIs in our API marketplace.

ScreenshotLayer is a compact RESTful API for capturing website screenshots, whereas PDFLayer is a simple utility for converting HTML to PDF. You may simply create a web page archiver that collects and preserves web pages in both image and PDF formats by combining these two APIs.

Prerequisites

Before you begin, make sure that you’ve got all of the following:

  • Basic knowledge of APIs and RESTful services.
  • A ScreenshotLayer account (sign up here).
  • A PDFLayer account (sign up here).

Step 1: How to Capture a Screenshot of the Web Page

Set Up ScreenshotLayer API

  1. After you join up, go to your account’s dashboard and look for your API Access Key (aka. API Key).
  2. Install your preferred REST client or use cURL to submit a request to the ScreenshotLayer API.

Sample Request:

The API will provide the URL of the recorded screenshot if the request is successful.

Step 2: How to Convert Web Page to PDF

Set Up PDFLayer API

  1. Navigate to your dashboard and retrieve your API Key.
  2. Using a REST client or cURL, send a request to the PDFLayer API.

Example Request:

The API will then return a URL to the PDF document.

Step 3: Store the Screenshot and PDF

  1. Download the screenshot and PDF using the URLs provided by the APIs.
  2. Store them in your preferred cloud storage or on your server for future reference.

How to Integrate ScreenshotLayer and PDFLayer APIs into Delphi Multi-platform Application?

After you have completed the above steps, you might get an idea of how to use it. In this part, we will build a cross-platform native application using the Delphi programming language and its FireMonkey GUI framework. First, get your Delphi Community Edition here from the official page! Then, create a new multi-device application [Delphi]!

Delphi

Here is the simple design for our demonstration application. You can observe the Structure of the components and create the same look and feel.

RAD

As you can see, we have two buttons for each API. With Delphi, you can use various ways to integrate RESTful API services; one is using REST Client Components, and another one is just HTTP components. The difference is that REST Client Components provide more power when manipulating data responses and stuff, while Net HTTP components provide the same functions with a bit more complex process if you are working with big data responses.

How to Download Image and Document Files in Delphi Using HTTP Requests?

In our demo, we utilized Net HTTP Client components to showcase how you can get streams of data, in our case, PDF and PNG files. Here is our main function: DownloadFile. This function has been utilized for both API endpoints because it they have similar and straightforward processes.

And this above function used like this:

This is the result:

web page archiver
Web Page Archiver – Results
Web Page Archiver - Built with Delphi
Web Page Archiver – Built with Delphi

Overall, with both APIs you can achieve similar result. But there is a difference, while the ScreenshotLayer API might work better in some cases, the PDFlayer might be able to read the HTML document better and generate clean PDF format of it. Because, PDFLayer has several features where you can just provide the HTML elements and turn them into PDF format with high accuracy. Get the complete source code from this repository.

Moreover, check out our latest articles and tutorials where you can learn how to automate various business tasks using robust APIs powered by APILayer:

Conclusion

With just a few steps, the ScreenshotLayer and PDFLayer APIs enable you to create a comprehensive web page archiver. This tool can be a valuable asset for businesses, researchers, and individuals looking to preserve digital content. The APIs’ ease of use, coupled with their efficient performance, makes the task of web archiving straightforward and hassle-free.

APILayer API Marketplace CTA Banner
Related posts
API

The Best Free APIs to Use in 2024 for Your Business

API

App Store Search API: How To Optimize Your App's Visibility

API

What is an API? Understanding All the Key Factors

AutomationSecurity

Easy Steps to Automate Data Security by Verifying New Phone Prospects with Zapier

Leave a Reply

Your email address will not be published. Required fields are marked *