Pdfcrowd Blog

Product updates, tips & tricks

In our latest series, we've explored how to leverage the Pdfcrowd cloud-based API for converting web pages and HTML files to PDF, previously using languages such as C and C++. As Rust offers a safer alternative to these languages, this article will guide you through integrating the Pdfcrowd HTML to PDF API into your Rust applications to achieve robust document conversion solutions. You can download the complete source code from GitHub.

In this article, we will show how to convert a webpage or an HTML document to PDF in C using the Pdfcrowd API.

We will show the convert() function that provides the conversion functionality. We will demonstrate how to use it to create PDF from various input sources, such as a URL, a local HTML file, or an HTML string. By the end of this article, you should have a good understanding of how to integrate the Pdfcrowd API into your C programs for HTML to PDF conversion.

The API is cloud-based and accessible over HTTP. We will use libcurl to communicate with the API. libcurl is a widely used library available on all major platforms.

To quickly incorporate the Pdfcrowd API into your own code, you can download the complete C code with examples.

This screencast will show you how to easily create a PDF document from a HTML file or a web page in PHP. You will also learn how to serve the PDF file from your PHP web application and download it in the browser.

 

The Pdfcrowd HTML to PDF API makes it easy to programmatically create fillable PDF forms from standard HTML forms. The API supports most of the HTML form features and, together with support for digital signatures (see Create Digital Signature in PDF), provides an easy way to create PDF forms.

This feature is available starting with Pdfcrowd API client libraries version 5.6.

Simple Example

Add an HTML form field, for example a text input:

<p>Enter name: <input type="text"></p>

Enable generation of fillable PDF forms with the setEnablePdfForms() method:

client.setEnablePdfForms(true)

The resulting PDF will display an interactive input text field.

See: Example PDF, HTML and Code

A digital signature is a piece of information placed in a PDF document that makes it possible to verify the authenticity of the document. The Pdfcrowd API allows you to programmatically create PDFs containing a digital signature field. Such PDFs can be digitally signed in, for example, Adobe Reader or Preview.

This feature is available starting with Pdfcrowd API client libraries version 5.0.

Quick Start

To add a signature field to a document, set the pdfcrowd-signature class on a DIV element and specify its dimensions.

<div class="pdfcrowd-signature" 
     style="width: 2in; height: 1in; border: 1pt solid black;">
</div>

Our HTML to PDF API will transform this element to a signature field in the resulting PDF.

Postman, a versatile platform for API management, serves as an excellent tool for interacting with the Pdfcrowd Conversion API. This guide provides a comprehensive tutorial on how to use Postman to convert between PDF, HTML, and various image formats using the Pdfcrowd API. Whether you're a developer familiar with Postman or someone exploring API functionalities for document conversion, this guide will walk you through the process step-by-step.

In this tutorial you will learn how to add header and footer to PDF created by Pdfcrowd API. We will use PHP for illustrative purposes, but the code would be essentially the same in all languages the API supports.

Step-by-Step Example

Let's start with instantiating the Pdfcrowd client and setting the page format to Letter:

$client = new \Pdfcrowd\HtmlToPdfClient($user_name, $api_key);
$client->setPageSize('Letter');

The next step is to design our HTML footer and header. We can use special CSS classes that will be expanded as follows:

  • pdfcrowd-page-count - the total page count of printed pages
  • pdfcrowd-page-number - the current page number
  • pdfcrowd-source-url - the source URL of the main document

Overview

The Pdfcrowd API v2 is the new generation of our API. It is not 100% backward compatible but the changes are mostly syntactic and the migration from API v1 should be straightforward.

If you want to switch your current API v1 plan to API v2, please follow these steps:

  1. Activate the free API v2 trial in your account page.
  2. Follow the instructions below and migrate your API v1 implementation to API v2.
  3. If the API v2 works to your satisfaction, choose from our API v2 plans.
  4. If you no longer need the API v1 implementation, you can cancel the API v1 plan.