-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathphpToPDF.php
executable file
·33 lines (29 loc) · 926 Bytes
/
phpToPDF.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
function phptopdf_url($source_url,$save_directory,$save_filename)
{
$API_KEY = 'fzkj043yzn0xknz6s';
$url = 'http://phptopdf.com/urltopdf.php?key='.$API_KEY.'&url='.urlencode($source_url);
$resultsXml = file_get_contents(($url));
file_put_contents($save_directory.$save_filename,$resultsXml);
}
function phptopdf_html($html,$save_directory,$save_filename)
{
$API_KEY = 'fzkj043yzn0xknz6s';
$postdata = http_build_query(
array(
'html' => $html,
'key' => $API_KEY
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$resultsXml = file_get_contents('http://phptopdf.com/htmltopdf.php', false, $context);
file_put_contents($save_directory.$save_filename,$resultsXml);
}
?>