function p2fconverssion_handler($file_path, $file_name)
{
    $p2f = new COM("Print2Flash3.Server");
    if ($p2f) {
        $p2f->DefaultProfile->PageFileName = "../_sfp__" . $file_name . "/page_%page%.swf";
        $p2f->DefaultProfile->OutputFormat = 2;
        //$p2f->DefaultBatchProcessingOptions->UseAutomation=8;
        $p2fBPO = $p2f->DefaultBatchProcessingOptions;
        $p2fBPO->BeforePrintingTimeout = 900000;
        $p2fBPO->ActivityTimeout = 900000;
        $p2f->ConvertFile(realpath("../" . $file_path . "/@@-OriginalDocs-@@/" . $file_name));
        echo "Conversion is done";
    }
}
 //$p2f->DefaultProfile->PageFileName = realpath( $org_file_path ).'/_sfp__'.$file_name.'/page_%page%.swf';
 $p2f->DefaultProfile->PageFileName = realpath($org_file_path) . '\\_sfp__' . $file_name . '\\page_%page%.swf';
 try {
     $p2fBPO = $p2f->DefaultBatchProcessingOptions;
     $p2fBPO->BeforePrintingTimeout = 300000;
     $p2fBPO->ActivityTimeout = 300000;
     $p2fBPO->UseAutomation = 8;
     if ($selectArea == "PersonalArea") {
         logit("print2flash.php", "Personal area");
         $p2fBPO->CreateLogFile = true;
         $p2fBPO->LogFileName = realpath($org_file_path) . "/Log" . $file_name . ".txt";
         $logfilename = realpath($org_file_path) . "/Log" . $file_name . ".txt";
     }
     $message = "<result><status>2. Starting conversion</status><message></message></result>";
     logit("print2flash.php", $message);
     $p2f->ConvertFile($file_path);
     //$p2f->ConvertFile("C:\wamp\www\AVContent\Upload\Personal\hari\My Documents");
     /*
     //ANOTHER WAY OF EXEVCUTING P2F to run in the background, however, still failing with big files
     $p2fServerEXE = "C:\\Program Files (x86)\\Print2Flash3\\p2fServer.exe";
     $MyDocsDIR = str_replace("/", "\\", realpath($org_file_path));
     logit("print2flash.php","exec("."\"".$p2fServerEXE."\" \"".$MyDocsDIR."\\@@-OriginalDocs-@@\\".$file_name."\" \"".$MyDocsDIR."\\_sfp__".$file_name."\" /ThumbnailPageRange:All /ThumbnailImageWidth:140 /ThumbnailJpegQuality:80 /ThumbnailImageHeight:140 /ThumbnailFormat:1 /ThumbnailFileName:\"".$MyDocsDIR."\\@@-Thumbnails-@@\\".$file_name."_files\\thumbnail_%page%.%ext%\" /OutputFormat:2 /PageFileName:\"".$MyDocsDIR."\\_sfp__".$file_name."\\page_%page%.swf\"".")");
     exec("\"".$p2fServerEXE."\" \"".$MyDocsDIR."\\@@-OriginalDocs-@@\\".$file_name."\" \"".$MyDocsDIR."\\_sfp__".$file_name."\" /ThumbnailPageRange:All /ThumbnailImageWidth:140 /ThumbnailJpegQuality:80 /ThumbnailImageHeight:140 /ThumbnailFormat:1 /ThumbnailFileName:\"".$MyDocsDIR."\\@@-Thumbnails-@@\\".$file_name."_files\\thumbnail_%page%.%ext%\" /OutputFormat:2 /PageFileName:\"".$MyDocsDIR."\\_sfp__".$file_name."\\page_%page%.swf\"");
     */
     logit("print2flash.php", "3. Finished converting " . $file_path . " to " . $swffile_fs);
     $message = "<result><status>OK</status><message>{$swffile_fs}</message></result>";
 } catch (Exception $e) {
     $message = "<result><status>4. Error</status><message>" . $e->getMessage() . "</message></result>";
     logit("print2flash.php", $message);
     return $e;
 }
        $p2f->DefaultProfile->ThumbnailPageRange = "All";
        $p2f->DefaultProfile->ThumbnailImageWidth = 140;
        $p2f->DefaultProfile->ThumbnailJpegQuality = 80;
        $p2f->DefaultProfile->ThumbnailImageHeight = 140;
        $p2f->DefaultProfile->ThumbnailFormat = 1;
        $p2f->DefaultProfile->ThumbnailFileName = realpath("../../../" . $file_path) . '/@@-Thumbnails-@@/' . $file_name . '_files\\thumbnail_%page%.%ext%';
        $p2f->DefaultProfile->PageFileName = realpath("../../../" . $file_path) . '/_sfp__' . $file_name . '/page_%page%.swf';
        $p2f->DefaultBatchProcessingOptions->UseAutomation = 8;
        try {
            $p2fBPO->LoggingLevel = 1;
            $p2fBPO = $p2f->DefaultBatchProcessingOptions;
            $p2fBPO->BeforePrintingTimeout = 900000;
            $p2fBPO->ActivityTimeout = 900000;
            $p2fBPO->CreateLogFile = true;
            $p2fBPO->LogFileName = realpath("../../../" . $file_path) . "/Log" . $file_name . ".txt";
            $message = "<result><status>2. Starting conversion</status><message></message></result>";
            logit("print2flashforApi.php", $message);
            $p2f->ConvertFile($absPath);
            logit("print2flashforApi.php", "3. Finished converting " . $file_path . " to " . $swffile_fs);
            $message = "<result><status>OK</status><message>{$swffile_fs}</message></result>";
            echo "Finished Converting";
        } catch (Exception $e) {
            $message = "<result><status>4. Error</status><message>" . $e->getMessage() . "</message></result>";
            logit("print2flash.php", $message);
            return $e;
        }
    }
} else {
    $message = "<result><status>4. Error</status><message>Something is wrong with uploading a file.</message></result>";
    echo "Something is wrong with uploading a file";
}
Exemple #4
0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php 
$fileName = "C:/wamp/www/Sample/3 MB.doc";
//$fileName="C:/wamp/www/Sample/2.pdf";
echo "Starting conversion";
$p2f = new COM("Print2Flash3.Server2");
if ($p2f) {
    //$p2f->DefaultBatchProcessingOptions->UseAutomation=8;
    $p2f->ConvertFile($fileName, "C:/wamp/www/Sample/ConvertedDoc.swf");
}
?>

</body>
</html>