Forum How do I...?

flash files corupting the pdf document

samWhisker
Hi

Been using Prince for a while now and its being very useful!

one issue i have is when i save a page with flash and save it to a pdf, the pdf gets corrupt and therefore wont open

so 2 questions basically, here is the flash embed code (looks pretty standard to me) can anyone see any errors with it?

<object id="player0_api" width="100%" height="100%" type="application/x-shockwave-flash" data="assets/swf/banner.swf">
<param value="true" name="allowfullscreen">
<param value="always" name="allowscriptaccess">
<param value="high" name="quality">
<param value="false" name="cachebusting">
<param value="#000000" name="bgcolor">
<param value="config={}" name="flashvars">
</object>


if not should i be doing some error checking on the server for this type of thing? everything i have read it just says a grey box appears with the word flash it? this of course would be the dream as opposed to it just crashing :-) i have actually ran it through doc raptor and i get the fabled grey box!

Are there any settings on the server that i am missing?

Cheers
Sam
mikeday
This should not cause problems. How are you running Prince? Can you try running it from the command-line on this file?
samWhisker
hi sorry for being a pain, but i am tearing my hair out, ha!

ok so i am using the php wrapper, this is my code

include("prince.php");

$prince = new Prince('/usr/local/bin/prince');

//vars
$errs = array();

$build_page = buildDocument($html); // this function returns this - <object id="player0_api" width="100%" height="100%" type="application/x-shockwave-flash" data="http://stayappy.co.uk/Projects/XpressBook/Build/assets/swf/flowplayer-3.2.7.swf"><param value="true" name="allowfullscreen"><param value="always" name="allowscriptaccess"><param value="high" name="quality"><param value="false" name="cachebusting"><param value="#000000" name="bgcolor"><param value="config={}" name="flashvars"></object>

$htmlString= $build_page; 
$cssPath = $_SERVER['DOCUMENT_ROOT'] . '/Projects/XpressBook/Build/assets/css/';

//config

$prince->addStyleSheet($cssPath . 'main.css');
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="XpressBook.pdf"');

if ($prince->convert_string_to_passthru($htmlString))
{
   echo 'Report OK!';
} else {
   echo '<pre>';
		print_r($errs);
	echo '</pre>';
} 


it works fine for everything else i throw at it, even if i remove the params so i just have this

<object id="player0_api" width="100%" height="100%" type="application/x-shockwave-flash" data="http://stayappy.co.uk/Projects/XpressBook/Build/assets/swf/flowplayer-3.2.7.swf"></object>


it creates the pdf but has no flash grey box?

should i be including an extra style sheet?

Thanks for all your help so far
mikeday
Note that Flash content will not actually appear in the generated PDF file, just want to make sure that is clear. :)

You will need to call $prince->setHTML(true); to make sure that the document is parsed as HTML and not XML, as currently the empty <param> elements will confuse the parser.
samWhisker
Amazing!

Thank you so much. i have never been happier to see a grey box!

All is sorted now and it works a treat

Thanks Sam