emehrkay Posted November 9, 2009 Share Posted November 9, 2009 I need a way to take html created with a wysiwyg editor and a few options (bkg image&color etc) and be able to print it as it was defined with the editor. All css stylings are lost when the user goes to print, so my solution would be to convert that html string into a GD image. I figure this shouldnt be too difficult as long as the style is inline with the html. I figured it would be useful for others so I would try to make it a generic lib. I just need some help identifying which gd functions would be needed to do what as I have never really used it before. Here is the process that I've thought out so far, tell me if I am missing anything and help me out in some areas [*]Define Defaults -- font, font size, font color, font bkg color, and image x y [*]Read and parse html string this step will read each html element removing the style attribute and using the applicable defintions to style the element. ie <span style="background-color: #red;">test</span> would create a red box with test as the text. If the element doesnt have one of the default settings, use the default that was defined before. The result would be an array with all of the elements' types and GD rules. array(array('type'=> 'text', 'value' => 'test' 'font_color' => '#red')) etc. [*]convert the findings on each element to the GD equivalent in this step I would have to make it follow html rules as much as possible, all block level elements are treated as such etc [*]save the image to disk (possible stream in the future) and discard the resource functions/methods that id need [*]imagettfbbox [*]imagefilledrectangle [*]imagecreatetruecolor [*]imagecolorallocate [*]gd one that loads existing images (I cannot identify this) [*]hex to rgb and back [*]add on... Any suggestions? Does this already exist? Am I in over my head? HELP! I'll make it a google code project once I get something going (well, if it proves to be of any use) Thanks Link to comment https://forums.phpfreaks.com/topic/180863-need-help-writing-a-simplemaybe-lib-that-would-take-html-and-convert-to-gd-img/ Share on other sites More sharing options...
dgoosens Posted November 9, 2009 Share Posted November 9, 2009 I think you'd be much better off with a PDF... Have a look at PHPLiveDocX http://www.phplivedocx.org/2009/02/03/generate-pdf-docx-doc-and-rtf-files-with-php/ Haven't used it in a while... so I am not aware of the latest modifications... But it used to work really nice... Link to comment https://forums.phpfreaks.com/topic/180863-need-help-writing-a-simplemaybe-lib-that-would-take-html-and-convert-to-gd-img/#findComment-954155 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.