39 : array
40 {
41 $pagewidth = "21cm";
42 if (preg_match("/page-width\=\"([^\"]+)\"/", $content, $matches)) {
43 $pagewidth = $matches[1];
44 }
45 $pageheight = "29.7cm";
46 if (preg_match("/page-height\=\"([^\"]+)\"/", $content, $matches)) {
47 $pageheight = $matches[1];
48 }
49
50 $pagesize = 'custom';
51 if (((strcmp($pageheight, "29.7cm") === 0) || (strcmp($pageheight, "297mm") === 0))
52 && ((strcmp($pagewidth, "21cm") === 0) || (strcmp($pagewidth, "210mm") === 0))) {
53 $pagesize = "a4";
54 } elseif (((strcmp($pagewidth, "29.7cm") === 0) || (strcmp($pagewidth, "297mm") === 0))
55 && ((strcmp($pageheight, "21cm") === 0) || (strcmp($pageheight, "210mm") === 0))) {
56 $pagesize = "a4landscape";
57 } elseif (((strcmp($pageheight, "21cm") === 0) || (strcmp($pageheight, "210mm") === 0))
58 && ((strcmp($pagewidth, "14.8cm") === 0) || (strcmp($pagewidth, "148mm") === 0))) {
59 $pagesize = "a5";
60 } elseif (((strcmp($pagewidth, "21cm") === 0) || (strcmp($pagewidth, "210mm") === 0))
61 && ((strcmp($pageheight, "14.8cm") === 0) || (strcmp($pageheight, "148mm") === 0))) {
62 $pagesize = "a5landscape";
63 } elseif (((strcmp($pageheight, "11in") === 0))
64 && ((strcmp($pagewidth, "8.5in") === 0))) {
65 $pagesize = "letter";
66 } elseif (((strcmp($pagewidth, "11in") === 0))
67 && ((strcmp($pageheight, "8.5in") === 0))) {
68 $pagesize = "letterlandscape";
69 }
70
75 if (preg_match("/fo:flow[^>]*margin\=\"([^\"]+)\"/", $content, $matches)) {
76
77 $marginbody = $matches[1];
78 if (preg_match_all("/([^\s]+)/", (string) $marginbody, $matches)) {
79 $marginBody_top = $matches[1][0];
80 $marginBody_right = $matches[1][1];
81 $marginBody_bottom = $matches[1][2];
82 $marginBody_left = $matches[1][3];
83 }
84 } elseif (preg_match("/fo:region-body[^>]*margin\=\"([^\"]+)\"/", $content, $matches)) {
85 $marginbody = $matches[1];
86 if (preg_match_all("/([^\s]+)/", (string) $marginbody, $matches)) {
87 $marginBody_top = $matches[1][0];
88 $marginBody_right = $matches[1][1];
89 $marginBody_bottom = $matches[1][2];
90 $marginBody_left = $matches[1][3];
91 }
92 }
93
94 $xsl = file_get_contents(__DIR__ . '/../../xml/fo2xhtml.xsl');
95 if ($content !== '' && (is_string($xsl) && $xsl !== '')) {
96 $args = [
97 '/_xml' => $content,
98 '/_xsl' => $xsl
99 ];
100
101 $content = $this->xlstProcess->process($args, []);
102 }
103
104 $content = preg_replace("/<\?xml[^>]+?>/", "", $content);
105
106
107 $content = str_replace([" ", " "], "<br />", $content);
108
109 return [
110 'pageformat' => $pagesize,
111 'pagewidth' => $pagewidth,
112 'pageheight' => $pageheight,
113 'margin_body_top' => $marginBody_top,
114 'margin_body_right' => $marginBody_right,
115 'margin_body_bottom' => $marginBody_bottom,
116 'margin_body_left' => $marginBody_left,
117 'certificate_text' => $content
118 ];
119 }
final const DEFAULT_MARGIN_BODY_RIGHT
final const DEFAULT_MARGIN_BODY_BOTTOM
final const DEFAULT_MARGIN_BODY_TOP
final const DEFAULT_MARGIN_BODY_LEFT