2013-06-26 3 views
0

Я работаю над созданием pdf-файлов с использованием библиотеки mpdf. Я хочу защитить паролем файлы PDF после их создания. Я не мог найти какой-либо вариант для этого на веб-сайте mpdf. Пожалуйста, дайте мне знать, есть ли какие-либо варианты. Код ниже, который я использую для mpdf.Защита паролем pdf-файл, созданный с использованием mpdf через php

<?php 

$html = "This a test password protected pdf"; 

//============================================================== 
//============================================================== 
//============================================================== 
include("MPDF56/mpdf.php"); 

/*$mpdf = new mPDF('', // mode - default '' 
'', // format - A4, for example, default '' 
0,  // font size - default 0 
'', // default font family 
15, // margin_left 
15, // margin right 
16,  // margin top 
16, // margin bottom 
9,  // margin header 
9,  // margin footer 
'L'); // L - landscape, P - portrait*/ 

$mpdf=new mPDF('c','A4','','',1,1,1,1,0,0); 
$mpdf->SetDisplayMode('fullpage'); 
$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list 
// LOAD a stylesheet 
$stylesheet = file_get_contents('./pdf_additional_files/style.css'); 
$mpdf->WriteHTML($stylesheet,1); // The parameter 1 tells that this is css/style only and no body/html/text 
$mpdf->WriteHTML($html,2); 
$mpdf->Output('mpdf.pdf','I'); 
exit; 
//============================================================== 
//============================================================== 
//============================================================== 
?> 

ответ

0

Таким образом, просто задержать присвоение результата в вашем успехе обратного вызова

setTimeout(function(){ 
     $('.result').html(data); 
     $("#imgSpinner1").hide(); 
    },2000); 
+0

все равно загрузчик не появляется ... обновил код выше. –

0

попробовать это ниже скрипт с изменениями

<script> 
// Wrap this function in a closure so we don't pollute the namespace 
(function worker() { 
var randomnumber=Math.floor(Math.random()*11) 

//this will start showing your loader 
$('.result').show(); 

$.ajax({ 
    type: "POST", 
    url: "data.php?limit1=0&limit2="+randomnumber, 
    beforeSend: function() { 
    $("#imgSpinner1").show(); 
}, 
success: function(data) { 
    setTimeout(function(){ 
     $('.result').html(data); 
     $("#imgSpinner1").hide(); 
    },2000); 
}, 
complete: function() { 

//this will hide your loader 
$('.result').hide(); 

    // Schedule the next request when the current one's complete 
    setTimeout(worker, 5000); 
} 
}); 
})(); 
</script> 
+0

данные поступают и мигают ... но загрузчик не отображается за этот интервал времени. –

+0

Этот html для загрузчика ????

DepH

+0

Да, это html для загрузчика и данных ... его аналогичные данные отображаются в течение 1 секунды, а затем уходят, и ничего не происходит через некоторое время, снова появляются данные и исчезают ... –

0
You have to load the image and display while processing. 

<script> 
// Wrap this function in a closure so we don't pollute the namespace 
(function worker() { 
$('#result').htmt('<img id="imgSpinner1" src="../images/ajax-loader.gif" />'); 
    var randomnumber=Math.floor(Math.random()*11) 
    $.ajax({ 
    type: "POST", 
    url: "data.php?limit1=0&limit2="+randomnumber, 
    beforeSend: function() { 
     $("#imgSpinner1").show(); 
    }, `enter code here` 
    success: function(data) { 
$('#result').html(''); 
     setTimeout(function(){ 
      $('.result').html(data); 
      $("#imgSpinner1").hide(); 
     },2000); 
    }, 
    complete: function() { 
     // Schedule the next request when the current one's complete 
     setTimeout(worker, 5000); 
    } 
    }); 
})(); 
</script> 

<div id="result"></div> 

<?php 
$user_ids = mysql_query("select user_name from customer_details limit ".$_REQUEST['limit1'].",".$_REQUEST['limit2'].""); 
$rows = array(); 
while ($row_user_names = mysql_fetch_assoc($user_ids)) 
{ 
    $rows[] = $row_user_names; 
} 
echo json_encode($rows); 
?> 

I hope this will help for you.. 
+0

Теперь он работает. Дайте мне некоторое время, дайте мне реализовать его. –

0

Ниже будет работать

$mpdf->SetProtection(array('print', 'copy'), $user_password, $owner_password); 
+0

Я тестировал, он работает – Braj

Смежные вопросы