Skip to content

Instantly share code, notes, and snippets.

@pdfcrowd
pdfcrowd / gist:1014068
Created June 8, 2011 09:10
Split table with <thead> using jQuery
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script>
// If *table* defines <thead> then this function replaces the table with N
// tables separated by a page break. Each new table starts with <thead> and its
// height is at most maxHeight pixels.
//
// *table* must not have the id attribute since it is cloned N-times. Use the
@pdfcrowd
pdfcrowd / header_and_footer.php
Created June 8, 2011 16:44
Pdfcrowd PHP API - Header & Footer
@pdfcrowd
pdfcrowd / pdfmail_api_v1.php
Last active February 15, 2020 21:18
Generate PDF using the Pdfcrowd API v1 and send it as an email attachment
// uses the PHP PEAR modules for sending MIME email
// http://pear.php.net/package/Mail
// http://pear.php.net/package/Mail_Mime
<?php
require 'pdfcrowd.php';
require_once('Mail.php');
require_once('Mail/mime.php');
@pdfcrowd
pdfcrowd / pdfmail2.php
Last active February 15, 2020 21:18
generate a PDF using the Pdfcrowd API and send it as an email attachment (II.)
<?php
require 'pdfcrowd.php';
try
{
// generate a PDF file
$client = new Pdfcrowd($username, $apikey);
$pdf = $client->convertHtml("Hello World");
@pdfcrowd
pdfcrowd / pdfcrowd.c
Created October 17, 2012 12:02
A simple C app that creates PDF from a local HTML file
/* compile with: $ gcc pdfcrowd.c -lcurl -o pdfcrowd */
#include <curl/curl.h>
/*
* return values:
* 0 success
* 1 curl fatal error
* 2 curl error
* >399 API error (HTTP status code)
*/
@pdfcrowd
pdfcrowd / pdfmail_api_v2.php
Created September 28, 2018 07:01
Generate PDF using the Pdfcrowd API v2 and send it as an email attachment
// uses the PHP PEAR modules for sending MIME email
// http://pear.php.net/package/Mail
// http://pear.php.net/package/Mail_Mime
<?php
require 'pdfcrowd.php';
require_once('Mail.php');
require_once('Mail/mime.php');
$client = new \Pdfcrowd\HtmlToPdfClient($username, $apikey);
@pdfcrowd
pdfcrowd / pdfmail2_api_v2.php
Created September 28, 2018 07:05
Generate a PDF using Pdfcrowd API v2 and send it as an email attachment (II.)
<?php
require 'pdfcrowd.php';
try
{
// generate a PDF file
$client = new \Pdfcrowd\HtmlToPdfClient($username, $apikey);
$pdf = $client->convertString('Hello World');
@pdfcrowd
pdfcrowd / gcp_ip_ranges.sh
Last active February 24, 2020 14:40
Output Google Cloud IP ranges
#!/bin/bash
dig @8.8.8.8 +short txt _cloud-netblocks.googleusercontent.com | \
sed 's/"//g; s/ip4://g; s/ip6://g;' | \
tr ' ' '\n' | \
grep include | cut -d ':' -f2 | \
xargs dig @8.8.8.8 +short txt | \
sed 's/"//g; s/ip4://g; s/ip6://g;' | tr ' ' '\n' | grep '/'
@pdfcrowd
pdfcrowd / html_to_pdf.c
Last active March 16, 2023 08:20
This code shows how to convert HTML to PDF in C using the Pdfcrowd API. You can find the tutorial here: https://pdfcrowd.com/blog/convert-html-to-pdf-in-c/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <curl/curl.h>
#define API_ENDPOINT "https://api.pdfcrowd.com/convert/latest/"
#define USERNAME "demo"
#define API_KEY "ce544b6ea52a5621fb9d55f8b542d14d"
/* structure for conversion options */
@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";