Skip to content

A PHP script that converts an HTML file into an image (png) and displays it on a page.

Notifications You must be signed in to change notification settings

Avinodh/HTMLToImage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTMLToImage

A PHP script that dynamically converts an HTML file into an image (png) and displays it on a page. This is useful if you need to display pages, for example, from an eBook(.epub) or just plain old HTML files, securely. Content from a normal page can be fetched easily, whereas once it is converted into an image dynamically, getting the content from it would require it being run through an OCR script. I've included a sample xhtml file in the "Book" folder that represents a page from a typical ebook.

Drawbacks-

        1) No formatting/styling done in the HTML file will be reflected in the image. Keep in mind, this script does
        NOT render HTML, it is merely a tool for extracting its content. This is done by stripping the HTML of all its
        tags and running a few algorithms for dynamic resizing of image, text wrapping, etc. 
        
       2). The lines of text in the image don't look to pretty- irregular spacing, text overlapping on increasing                  font-size. These are issues that can be fixed by getting a deeper understanding of how the functions used work.
       
       3). The amount of text fit into the image is proportional to the browser window's size. Yet to figure out an                efficient system to save the cut-off text and add a navigation button to display that too
        
       4). Images present in the html file will not be rendered into the image. I still haven't fgiured out a way to               get an image inside another image. Also, the <img> tags get stripped out so that's another hurdle. 

About

A PHP script that converts an HTML file into an image (png) and displays it on a page.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published