This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Some things about using convertfile function

santi900 wrote on 2010-10-19:
I"ll try to explain.
I have a php site that requires authentification, i have some dinamic pages automatically saved in local files on the server with ob_start... At first i used the converthtml to print this static files and, after putting the css inline the html code, it worked, but not the images was printed.
I "ve tried with the convertfile function instead of converthtml because i understand the second can"t print images (or yes?).
But no images printed with convertfile funtion and css is still inline.

Here is the portion of code related to:

//... other parameters and class correctly working
$client->enableImages(TRUE);  // necesary??
	
	try
	{
	//html working:
	//	header("Content-type: application/pdf");
        //	header("Content-Disposition: attachment; filename="impresion.pdf"");
        //      echo $client->convertHtml($html);
		

	  //convertFile
    	$client->convertFile("C:/wamp/www/srvf/pdf.html", fopen("file.pdf", "wb"));

        //opening this html file on navigator shows as expected, imges, styles... but It builds pdf in the same path without images 

	}



When i active the headers code lines with convertFile it gives an error opening the pdf (not with convertHtml function)
Is it necessary to write the full path of the file?
Any ideas for printing images?
The images are gif format, i suppose they are supported... aren"t them?

Thanks in advance, great work!!

Santiago
support wrote on 2010-10-19:
Santiago,

there are two ways how to print images:

  1. If the images are publicly available, use an absolute path in your html:
    <img src="http://yourdomain.com/your-image.gif">
    

  2. Or pack the images together with your html code to a zip file and send it using convertFile(). Use a relative path in this case:
    <img src="your-image.gif">
    



>> Is it necessary to write the full path of the file?
It does not matter for Pdfcrowd, but you should probably use the full path to be sure that your script can find it.


Does this help?
santi900 wrote on 2010-10-19:
Sure, thank you

best regards