-
Notifications
You must be signed in to change notification settings - Fork 0
/
HtmlResource.php
54 lines (45 loc) · 1.31 KB
/
HtmlResource.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace DynamicPDF\Api;
include_once __DIR__ . '/Resource.php';
include_once __DIR__ . '/ResourceType.php';
include_once __DIR__ . '/EndPointException.php';
/**
*
* Represents an Html resource used to create an HtmlInput object to create PDF from html file.
*
*/
class HtmlResource extends Resource
{
/**
*
* Initializes a new instance of the HtmlResource class.
*
* @param string $file The input html string.
* @param string $resourceName The name of the resource.
*/
public function __construct(string $file, string $resourceName = null)
{
parent::__construct();
$this->_Data = mb_convert_encoding($file, "UTF-8");
if ($resourceName == null) {
$this->ResourceName = md5(uniqid(rand(), true)) . $this->_FileExtension();
} else {
$this->ResourceName = $resourceName;
}
$this->_Type = ResourceType::Html;
$this->_MimeType = "text/html";
}
public $_Type = ResourceType::Html;
public $_MimeType;
public function _FileExtension()
{
return ".html";
}
public function GetJsonSerializeString()
{
$inputjson = array();
$inputjson['type'] = "html";
$inputjson['resourceName'] = $this->ResourceName;
return $inputjson;
}
}