Skip to content

Instantly share code, notes, and snippets.

@pdfcrowd
pdfcrowd / html_to_pdf.rs
Last active April 20, 2024 08:50
Convert a web page or HTML file to PDF in Rust. Complete tutorial: https://pdfcrowd.com/blog/convert-html-to-pdf-in-rust/
use std::fs::File;
use std::error::Error;
use reqwest::blocking::Client;
use reqwest::blocking::multipart::{Form, Part};
// API endpoint and Pdfcrowd credentials
static API_ENDPOINT: &'static str = "https://api.pdfcrowd.com/convert/latest/";
static USERNAME: &'static str = "demo";
static API_KEY: &'static str = "ce544b6ea52a5621fb9d55f8b542d14d";