1

This is what I have so far.

enter image description here

http://gyazo.com/3605597b9b8135f021c1c3481ff34acb.png?1329009331

It successfully writes the source to the image, but I want it to render as HTML and then write the HTML formatted string to the image.

This is what I want it to look like, but in image form.

enter image description here

http://gyazo.com/5afdb47793844f7648210ecd540da1c3.png?1329009540

Thanks for looking. I am so frustrated with this, haha.

Jared Farrish
  • 48,585
  • 17
  • 95
  • 104
Steve
  • 632
  • 4
  • 16
  • I've done this in .Net by instantiating an in-memory browser and using it to render an image. You might be able to get away with converting to an RTF but I don't know of anything that will render HTML graphically in PHP – Basic Feb 12 '12 at 01:39
  • You will need to find a class that converts HTML to the image format you're using. [HTML to PDF](http://stackoverflow.com/questions/560583/which-is-the-best-pdf-library-for-php) is quite common, but I've not the HTML to image conversion. I'm sure they're out there. – Jared Farrish Feb 12 '12 at 01:39
  • Of course, you could create a PDF and then [convert to an image format](http://stackoverflow.com/questions/467793/how-do-i-convert-a-pdf-document-to-a-preview-image-in-php). I'm sure it'd take some tweaking of the PDF, but I assume it's possible. – Jared Farrish Feb 12 '12 at 01:41
  • Alright, thanks guys. I'll try TCPDF and convert it using ImageMagick. If it works, I'll post back. – Steve Feb 12 '12 at 01:48
  • I used DOMPDF and it successfully created a file with the correct formatting, but all the semicolons from the PHP source code are moved to a new line. I don't think this will ever work out.. haha. Here is the result of the dompdf conversion. http://chaos.am/~/syntax/sample.pdf – Steve Feb 12 '12 at 02:12

1 Answers1

0

I think there is only one way to print multi colored text by using the standard PHP GD and Image functios. You must print it by having a seperate imagestring call for each color.

This works only for monospace font types, where all the characters having the same size.

If you want something "prettier" you must be using some other way.

Attila
  • 3,206
  • 2
  • 31
  • 44