安裝擴(kuò)展:
(1)下面是我在linux上的安裝過程,如果沒有安裝git請(qǐng)先yum install git
安裝casperjs
3. 將msyh.ttf和msyhbd.ttf復(fù)制到該目錄下,例如這兩個(gè)文件放在/root/Desktop下,使用命令:
4. 建立字體索引信息,更新字體緩存:
至此,字體已經(jīng)安裝完畢!
- <?php
- if (isset($_GET['url']))
- {
- set_time_limit(0);
- $url = trim($_GET['url']);
- $filePath = md5($url).'.png';
- if (is_file($filePath))
- {
- exit($filePath);
- }
- //如果不加這句就會(huì)報(bào)錯(cuò)“Fatal: [Errno 2] No such file or directory; did you install phantomjs?”,詳情參考http://mengkang.net/87.html
- putenv("PHANTOMJS_EXECUTABLE=/usr/local/bin/phantomjs");
- $command = "phantomjs phantomjs.js {$url} {$filePath}";
- @exec($command);
- exit($filePath);
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <meta name="keywords" content="" />
- <meta name="description" content="" />
- <title>快照生成</title>
- <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
- <style>
- * {margin: 0; padding: 0; } form {padding: 20px; } div {margin: 20px 0 0; } input {width: 200px; padding: 4px 2px; } #placeholder {display: none; }
- </style>
- </head>
- <body>
- <form action="" id="form">
- <input type="text" id="url" />
- <button type="submit">生成快照</button>
- <div>
- <img src="" alt="" id="placeholder" />
- </div>
- </form>
- <script>
- $(function(){
- $('#form').submit(function(){
- if (typeof($(this).data('generate')) !== 'undefined' && $(this).data('generate') === true)
- {
- alert('正在生成網(wǎng)站快照,請(qǐng)耐心等待...');
- return false;
- }
- $(this).data('generate', true);
- $('button').text('正在生成快照...').attr('disabled', true);
- $.ajax({
- type: 'GET',
- url: '?',
- data: 'url=' + $('#url').val(),
- success: function(data){
- $('#placeholder').attr('src', data).show();
- $('#form').data('generate', false);
- $('button').text('生成快照').attr('disabled', false);
- }
- });
- return false;
- });
- });
- </script>
- </body>
- </html>
新聞熱點(diǎn)
疑難解答