doulan9287 2015-05-28 06:06
浏览 118

如何延迟pdf扫描,直到页面加载完全pdfcrowd api在PHP?

I am using pdfcrowd API for generating PDF from my dynamic PHP webpage, in which I am getting some data from DB and also running some jQuery functions with setTimeout function having 2 to 3 seconds delay at the bottom of page inside document ready function of jQuery.

This jQuery functions I am using to set page layout height dynamically based on content using Lightweight Responsive jQuery - Waterfall plugin, which takes some time to do that.

So, when I try to download PDF, it downloads page without running my JavaScript/jQuery function, which delay approx 2 to 3 second in it.

Code detail that I am using:

MyWebPage Code looks something like this:

//HTML + PHP code here at top of page

//jQuery code to set page height dynamically

function setContainerHeight(containerDiv) {
 //function code here..
$(document).ready(function() {
        function() {
            setTimeout(function() {setContainerHeight(containerDiv);},2000);

Download Page

$pdf = $client->convertURI($myWebPageUrl);

// Set HTTP response headers
header("Content-Type: application/pdf");
header("Cache-Control: no-cache");
header("Accept-Ranges: none");
header("Content-Disposition: attachment; filename=\"Resume.pdf\"");
// send the generated PDF 
echo $pdf;

Please help me in this, how I can delay the PDF scan until my page loads completely.

Thanks in advance.

  • 写回答

2条回答 默认 最新

  • douye8500 2015-05-28 12:42

    Since you can't hold webpage to render, as your JavaScript function is running after page load as usingsetTimeout, you should do whatever is required with page load only.

    So, You should try calling your function setContainerHeight() after plugin work completion, means you should try call back function of plugin.

    And remember to remove setTimeout as they will not be required, after using callback function. Moreover, if your plugin doesn't have callback, so you should mind calling your function from plugin file, though this is not correct way, but it should do the trick.

    In your case, you should search for function named sorting in your waterfall API and add your function call in last of it.

    Hopefully, this helps you..!!!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
  • douyuan1752 2015-05-28 06:15

    Your question does not clarify what the problem really is, may be a problem of the javascript not knowing when the PDF file has loaded fully, can you call it by an ajax call? If you are loading the PDF to an IFrame you could try this:

    $("#iFrameId").on("load", function () {

    If the problem is in php, may be the output of the PDF beeing slowed by the api you could stop the output buffer until the process is done by:

    ob_start(); //at the begining
    //Your code until echo
    ob_end_flush(); //at the end



  • ¥80 用PE可以更改原win11系统的环境变量吗?
  • ¥20 win10商店接入问题
  • ¥15 java 这种树形框吗
  • ¥40 找同学帮敲Python代码
  • ¥15 MYSQL 订单的商品明细重复计算问题
  • ¥15 微信实时共享位置修改
  • ¥100 TG的session协议号转成直登号号后客户端登录几分钟后自动退出设备
  • ¥50 共模反馈回路的小信号增益
  • ¥15 arduino ssd1306函数与tone函数放歌代码不兼容问题
  • ¥70 0.96版本hbase的row_key里含有双引号,无法deleteall