webpage as image

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

First of all, i think that you didn't copy html2ps to your server root or that you can't open remote connections.
Secondly, there is an error in my script:
Instead of:

Code: Select all

exec('C:\Program_Files\ImageMagick-6.2.8-Q16\convert.exe "".$docroot.$html2ps_dir."\out\\'.$filename.'" "".$docroot."sample.jpeg"');
Put:

Code: Select all

exec('C:\Program_Files\ImageMagick-6.2.8-Q16\convert.exe "'.$docroot.$html2ps_dir.'\out\\'.$filename.'" "'.$docroot.'sample.jpeg"');
User avatar
gurjit
Forum Contributor
Posts: 314
Joined: Thu May 15, 2003 11:53 am
Location: UK

Post by gurjit »

same error.

all documents are copied to the following directory

"C:\Inetpub\wwwroot\html2ps_v194"

Then I went to the windows command and typed

convert logo: logo.gif
identify logo.gif
imdisplay logo.gif

and a wizard image was displayed

I installed ImageMagick-6.2.8-0-Q16-windows-dll.exe

am i missing anything?
User avatar
gurjit
Forum Contributor
Posts: 314
Joined: Thu May 15, 2003 11:53 am
Location: UK

Post by gurjit »

the error is in these lines:

Code: Select all

&encoding=&method=fpdf&pdfversion=1.3&output=2", "r"); 
while(!feof($handle)) 
{ 
        $content .= fread($handle, 4096);
User avatar
gurjit
Forum Contributor
Posts: 314
Joined: Thu May 15, 2003 11:53 am
Location: UK

Post by gurjit »

now i get one error here

Code: Select all

$content .= fread($handle, 4096);
which says

Code: Select all

Notice: Undefined variable: content in c:\inetpub\wwwroot\imagemagic.php on line 16
Problem
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

Make sure that you have "$content = '';" before the while loop.
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

Read "README.TXT" of html2ps and see under requirements that you have what the script needs.
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

Oops...

I forgot to mention that you need to install GhostScript also:
Project Home: http://www.cs.wisc.edu/~ghost/
Download Page: http://sourceforge.net/project/showfile ... up_id=1897 (choose "gs854w32.exe" if you have intel [i386]).
User avatar
gurjit
Forum Contributor
Posts: 314
Joined: Thu May 15, 2003 11:53 am
Location: UK

Post by gurjit »

which gost script do i download from the page for windows xp?

also i have installed php 5.1.4-installer and do not have GD2, how do I go about installing this on my windows?
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

Which processor(architecture) you have? Intel, AMD?
The type of Windows opertion system doesn't make any different!

P.S
Take "AFPL Ghostscript"...
If you have Intel, take the i386 version and if you have AMD, take AMD64 version.
User avatar
gurjit
Forum Contributor
Posts: 314
Joined: Thu May 15, 2003 11:53 am
Location: UK

Post by gurjit »

installed gostscript, I have intel so I installed gs854w32.exe

now i get a message "No GD2 extension found. Check your PHP configuration"

i have installed php 5.1.4-installer and it does not have GD2 extension, where do i get it and add it?
User avatar
gurjit
Forum Contributor
Posts: 314
Joined: Thu May 15, 2003 11:53 am
Location: UK

Post by gurjit »

i installed GD2

now i get this error

Code: Select all

Warning: fopen(c:\Inetpub\wwwroot\html2ps_v194\public_html/cache/4655393d48e7bc1ee0ec1459a1a4806f) [function.fopen]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\html2ps_v194\public_html\image.class.php on line 54

Warning: fwrite(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\html2ps_v194\public_html\image.class.php on line 55

Warning: fclose(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\html2ps_v194\public_html\image.class.php on line 56

Warning: fopen(c:\Inetpub\wwwroot\html2ps_v194\public_html/cache/69d54a0f69982252aa36f00d09098550) [function.fopen]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\html2ps_v194\public_html\image.class.php on line 54

Warning: fwrite(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\html2ps_v194\public_html\image.class.php on line 55

Warning: fclose(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\html2ps_v194\public_html\image.class.php on line 56

Warning: fopen(c:\Inetpub\wwwroot\html2ps_v194\public_html\fpdf/font/arial.z) [function.fopen]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\html2ps_v194\public_html\fpdf\font\makefont\makefont.php on line 232
Can't write to file c:\Inetpub\wwwroot\html2ps_v194\public_html\fpdf/font/arial.zFetching: http://www.google.com Status code:302 Redirected to:http://www.google.co.uk/ Fetching: http://www.google.co.uk/ Status code:200 Guessed: 'http://www.google.co.uk/url?sa=p&pref=ig&pval=3&q=http://www.google.co.uk/ig%3Fhl%3Den' Guessed: 'http://www.google.co.uk/' Fetching: http://www.google.co.uk/ Status code:200 PHP Warning: fopen(c:\Inetpub\wwwroot\html2ps_v194\public_html/cache/4655393d48e7bc1ee0ec1459a1a4806f) [function.fopen]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\html2ps_v194\public_html\image.class.php on line 54 PHP Warning: fwrite(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\html2ps_v194\public_html\image.class.php on line 55 PHP Warning: fclose(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\html2ps_v194\public_html\image.class.php on line 56 Guessed: 'http://www.google.co.uk/intl/en_uk/images/logo.gif' Fetching: http://www.google.co.uk/intl/en_uk/images/logo.gif Status code:200 PHP Warning: fopen(c:\Inetpub\wwwroot\html2ps_v194\public_html/cache/69d54a0f69982252aa36f00d09098550) [function.fopen]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\html2ps_v194\public_html\image.class.php on line 54 PHP Warning: fwrite(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\html2ps_v194\public_html\image.class.php on line 55 PHP Warning: fclose(): supplied argument is not a valid stream resource in c:\Inetpub\wwwroot\html2ps_v194\public_html\image.class.php on line 56 Guessed: 'http://www.google.co.uk/search' Guessed: 'http://www.google.co.uk/imghp?hl=en&tab=wi' Guessed: 'http://www.google.co.uk/intl/en/options/' Guessed: 'http://www.google.co.uk/advanced_search?hl=en' Guessed: 'http://www.google.co.uk/preferences?hl=en' Guessed: 'http://www.google.co.uk/language_tools?hl=en' Radiobutton with empty 'value' attribute Guessed: 'http://www.google.co.uk/intl/en/ads/' Guessed: 'http://www.google.co.uk/services/' Guessed: 'http://www.google.co.uk/intl/en/about.html' PHP Warning: fopen(c:\Inetpub\wwwroot\html2ps_v194\public_html\fpdf/font/arial.z) [function.fopen]: failed to open stream: Permission denied in c:\Inetpub\wwwroot\html2ps_v194\public_html\fpdf\font\makefont\makefont.php on line 232
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

The major problem is the "premission denied" problem.
I never have worked with IIS, only with Apache. So, I don't know how you can solve the premission denied problem!...

I have another solution, but that one is not freeware:
http://www.guangmingsoft.net/index.htm has a project called "HTML Snapshot". You can download the demo and try it, it is much more faster and requires only simple install. Try it.

P.S
The PHP code for using "HTML Snapshot":

Code: Select all

<?php

$url = "http://www.google.com";
$path = getcwd()."\\";
$img = "1.jpg";
$timg = "1s.jpg";

$com = new COM("HTMLSNAP2.HtmlSnap.1");
$com->SnapUrl($url, $path.$img );
$com->GetThumbnailImage($path.$img, $path.$timg, 100, 100, 1);

print "Snapshot of ".$url.". Click to enlarge<br>";
print "<a href=".$img."><img src=".$timg."></a>";
 
?>
Post Reply