Skip to content

Vic-ai/docker-wkhtmltopdf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wkhtmltopdf Microservice

Alpine container service for wkhtmltopdf.
Uncompressed size: 209 MB.

Usage

Run Container docker run -d npulidom/img-api

Replace PORT with container exposed port.

curl -X POST -vv -F '[email protected]' http://localhost:PORT -o test.pdf

PHP example

<?php

	$html = "<html><body>Hello world</body></html>";

	// set request body
	$body = json_encode([
		"contents" => base64_encode($html),
		"options"  => ["page-size" => "Letter"] // remove margins using: ["B" => "0", "L" => "0", "R" => "0", "T" => "0"]
	]);

	// set header
	$headers = [
		"Content-Type: application/json",
		"Content-Length: ".strlen($body),
	];

	// curl options
	$options = [
		CURLOPT_URL            => "http://wkhtmltopdf/",
		CURLOPT_PORT           => 80,
		CURLOPT_POST           => 1,
		CURLOPT_POSTFIELDS     => $body,
		CURLOPT_HTTPHEADER     => $headers,
		CURLOPT_RETURNTRANSFER => true
	];

	// curl call
	$ch = curl_init();
	curl_setopt_array($ch, $options);
	$result = curl_exec($ch);
	curl_close($ch);

	// print result
	print_r(json_decode($result, true));
?>

About

docker wkhtmltopdf alpine image

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Python 72.3%
  • Shell 8.5%
  • Dockerfile 8.1%
  • HTML 6.9%
  • Makefile 4.2%