File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,19 @@ public function send($filename = null,$inline = false)
144
144
return true ;
145
145
}
146
146
147
+ /**
148
+ * Get the raw Image contents (triggers Image creation).
149
+ * @return string|bool The Image content as a string or `false` if the
150
+ * Image wasn't created successfully.
151
+ */
152
+ public function toString ()
153
+ {
154
+ if (!$ this ->_isCreated && !$ this ->createImage ()) {
155
+ return false ;
156
+ }
157
+ return file_get_contents ($ this ->_tmpImageFile ->getFileName ());
158
+ }
159
+
147
160
/**
148
161
* Set options
149
162
*
Original file line number Diff line number Diff line change @@ -102,6 +102,21 @@ public function testCanSetPageFromUrl()
102
102
unlink ($ outFile );
103
103
}
104
104
105
+ public function testToString ()
106
+ {
107
+ $ outFile = $ this ->getOutFile ('png ' );
108
+ $ binary = $ this ->getBinary ();
109
+
110
+ $ image = new Image ('<html><h1>Test</h1></html> ' );
111
+ $ image ->binary = $ binary ;
112
+
113
+ $ this ->assertTrue ($ image ->saveAs ($ outFile ));
114
+ $ this ->assertFileExists ($ outFile );
115
+
116
+ $ this ->assertEquals (file_get_contents ($ outFile ), $ image ->toString ());
117
+ unlink ($ outFile );
118
+ }
119
+
105
120
// Options
106
121
public function testCanOptionsInConstructor ()
107
122
{
You can’t perform that action at this time.
0 commit comments