【问题标题】:SWF to PDF conversion with PHP [duplicate]使用 PHP 将 SWF 转换为 PDF [重复]
【发布时间】:2012-11-20 13:38:20
【问题描述】:

可能重复:
swf to pdf using php

我是一只新蜜蜂,正面临挑战。任何人都可以告诉我是否可以使用 php 将 swf 转换为 pdf。此外,如果某个机构有任何关于此的代码,这对我来说将是一个真正的帮助。

提前致谢。

【问题讨论】:

标签: php pdf flash


【解决方案1】:

我为此使用 CutyCapt。它采用 HTML 并将其呈现为 PDF/PNG/等。如果安装了 Flash,它还将呈现嵌入在 HTML 中的任何 Flash。你需要:

代码:

$input = '/home/test/test.swf';
$output = '/home/test/test.pdf';

$html_file = '/tmp/' . uniqid('flash') . '.html';
$fh = fopen($html_file, 'w');

// some basic HTML to embed the flash
$html = <<<EOT
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
body, html {
    margin: 0;
    padding: 0;
}
</style>
</head>
<body>
<object width="1000" height="600" type="application/x-shockwave-flash" data="file://{$input}">
<param name="allowscriptaccess" value="always" />
<param name="allownetworking" value="always" />
<param name="wmode" value="transparent" />
</object>
</body>
</html>
EOT;

fwrite($fh, $html);
fclose($fh);

exec("xvfb-run --server-args=\"-screen 0, 1024x768x24\" CutyCapt --plugins=on --out-format=pdf --delay=500 --url=\"{$html_file}\" --out={$output}");

// cleanup
unlink($html_file);

【讨论】:

    猜你喜欢
    • 2011-07-17
    • 2012-12-05
    • 1970-01-01
    • 2012-11-05
    • 2010-10-18
    • 2010-09-21
    • 1970-01-01
    • 2013-01-11
    相关资源
    最近更新 更多