Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将HTML文件转换为PDF_Javascript_Php_Html_Pdf - Fatal编程技术网

Javascript 将HTML文件转换为PDF

Javascript 将HTML文件转换为PDF,javascript,php,html,pdf,Javascript,Php,Html,Pdf,我正在尝试将我的PHP页面转换为PDF文件。但我面临的问题是,在将顶部部分转换为pdf后,我无法查看,因为我已附加了图像。pdf的质量也变得模糊了 我的形象是: HTML/PHP <div id="content2" style="background: #fff;border-bottom: 10px solid #ffffff;padding: 15px;border: 1px solid #000;width: 80%;margin: 0 auto;position: relati

我正在尝试将我的PHP页面转换为PDF文件。但我面临的问题是,在将顶部部分转换为pdf后,我无法查看,因为我已附加了图像。pdf的质量也变得模糊了

我的形象是:

HTML/PHP

<div id="content2" style="background: #fff;border-bottom: 10px solid #ffffff;padding: 15px;border: 1px solid #000;width: 80%;margin: 0 auto;position: relative;overflow: hidden;margin-bottom: 15px;">
  <table width="100%">
    <tr>
      <td>
        <center>
          <font size="5">
            Nikita Agrawal
          </font>
          <br> Bangalore
          <br> India, 560078
        </center>
      </td>
    </tr>
  </table>
  <br>
  <br>
  <br>
  <table width="100%">
    <tr>
      <td>
        Date:
        <?php $date=date_create($row['Payment_Date']); echo date_format($date,'d/m/Y'); ?>
      </td>
    </tr>
  </table>
  <br>
  <br>
  <br>
  <table width="100%">
    <tr>
      <td>
        To,
        <br> XYZ
      </td>
    </tr>
  </table>
  <br>
  <br>
  <br>
  <table width="100%">
    <tr>
      <td>
        <b>
                    Sub:
                </b> Declaration regarding non-requirement to be registered under the Central/ State/ Integrated /
        <br> Union Territory Goods and Services Tax Act, 2017 (Act) against supply/services provided.
      </td>
    </tr>
  </table>
  <br>
  <table width="100%">
    <tr>
      <td>
        Dear Sir/Mam,
        <br>
        <br>
        <span style="border-bottom: 1px dotted;width: 100%;display: block;"></span>
      </td>
    </tr>
    <tr>
      <td>
        <br> This refers to our discussion/communication for asking us to provide you with details of GST registrations such as GST registration number and the address registered under GST obtained by us.
      </td>
    </tr>
    <tr>
      <td>
        <br> In this regard, we hereby state that since my turnover in the state below taxable limit, we are not required to get myself registered under the ACT. My Permanent Account Number (PAN) is
        <?= $row['pan']; ?>
      </td>
    </tr>
    <tr>
      <td>
        <br> We request you to treat this communication as a declaration regarding non-requirement to be registered under the Act. In the event that GST is proposed to be recovered from me/us by the tax authorities in relation to transaction with XYZ
        on account of non-registration under GST, I/we will be liable to pay the same and it will not be paid AABSyS IT Private Limited.
      </td>
    </tr>
    <tr>
      <td>
        <br> Thanks & Regards,
      </td>
    </tr>
    <tr>
      <td>
        <br>
        <br>
        <br>
        <br> Signature
      </td>
    </tr>
    <tr>
      <td>
        Name
        <br>
        <?= $row['firstname'].' '.$row['lastname']; ?>
      </td>
    </tr>
  </table>
</div>
<button class="btn btn-info" id="cmd2">Download Token</button>

尼基塔·阿格拉瓦尔

班加罗尔
印度,560078


日期:



XYZ


附属的: 关于不要求按照中央/州/综合性法规注册的声明/
2017年《联邦地区商品和服务税法》(法案)针对提供的供应/服务。
亲爱的先生/妈妈:,


这是指我们的讨论/沟通,要求我们向您提供GST注册的详细信息,如GST注册号和我们获得的GST下注册的地址。
在这方面,我们特此声明,由于我在该州的营业额低于应纳税限额,我们无需根据该法案进行注册。我的永久帐号(PAN)是
我方要求贵方将本函件视为关于不需要根据法案注册的声明。如果税务机关建议就与XYZ的交易向我/我们收回GST 由于未在GST下注册,我/我们将负责支付相同的费用,而不会向AABSyS it Private Limited支付。
谢谢和问候,



签名 名称
下载令牌
JavaScript

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js">
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.min.js">
</script>
<script>
    $('#cmd2').click(function() {
        var options = {
            //'width': 800,
        };
        var pdf = new jsPDF('p', 'pt', 'a4');
        pdf.addHTML($("#content2"), -1, 220, options, function() {
            pdf.save('admit_card.pdf');
        });
    });
</script>

$('#cmd2')。单击(函数(){
变量选项={
//“宽度”:800,
};
var pdf=新的jsPDF('p','pt','a4');
pdf.addHTML($(“#content2”),-1220,选项,函数(){
保存('accept_card.pdf');
});
});

根据问题,您有一个无法查看顶部的问题

我已经解决了一些设计更改和最重要的问题
pdf.addHTML(选择器、左、上、选项、回调)
第2个和第3个参数表示左和上间距,之前设置为-1220,这是您没有在pdf中获得正确设计的主要原因

现在我已经设置为
pdf.addHTML($(“#content2”)、0、0、选项、回调也是

PHP


CSS


身体{
填充:0px;
左:0px;
顶部:0px;
背景色:#ffffff;
}
tr{
线高:20px;
}
#内容2{
背景:#fff;
边框底部:10px实心#ffffff;
填充:15px;
边框:1px实心#000;
宽度:80%;
保证金:自动15px;
位置:相对位置;
溢出:隐藏;
边缘底部:15px;
}
.100{
宽度:100%;
}
.填充20{
填充:20px 0px;
}
.rowborder{
边框底部:1个点;
宽度:100%;
显示:块;
}
海德丰先生{
字体大小:25px;
}
HTML


尼基塔·阿格拉瓦尔

班加罗尔
印度,560078


日期:



XYZ


附属的: 关于不要求按照中央/州/综合性法规注册的声明/
2017年《联邦地区商品和服务税法》(法案)针对提供的供应/服务。
亲爱的先生/妈妈:,


这是指我们的讨论/沟通,要求我们向您提供GST注册的详细信息,如GST注册号和我们获得的GST下注册的地址。
在这方面,我们特此声明,由于我在该州的营业额低于应纳税限额,我们无需根据该法案进行注册。我的永久帐号(PAN)是
我方要求贵方将本函件视为关于不需要根据法案注册的声明。如果税务机关建议就与XYZ的交易向我/我们收回GST 由于未在GST下注册,我/我们将负责支付相同的费用,而不会向AABSyS it Private Limited支付。
谢谢和问候,



签名
<?php
$row['Payment_Date'] = date('Y-m-d');
$row['firstname'] = "Nikita";
$row['lastname'] = "Agarwal";
$row['pan'] = 'AKC230L';
?>
<style type="text/css">
    body{
        padding:0px;
        left:0px;
        top:0px;
        background-color:#ffffff;
    }
    tr{
        line-height:20px;
    }
    #content2{
        background: #fff;
        border-bottom: 10px solid #ffffff;
        padding: 15px;
        border: 1px solid #000;
        width: 80%;
        margin: auto 15px;
        position: relative;
        overflow: hidden;
        margin-bottom: 15px;
    }
    .width100{
        width:100%;
    }
    .padding20{
        padding:20px 0px;
    }
    .rowborder{
        border-bottom: 1px dotted;
        width: 100%;
        display: block;
    }
    .headerfont{
        font-size:25px;
    }
</style>
<div id="content2" style="background: #fff;border-bottom: 10px solid #ffffff;padding: 15px;border: 1px solid #000;width: 80%;margin: 0 auto;position: relative; overflow: hidden;margin-bottom: 15px;">
    <table class="width100">
        <tr>
            <td>
                <center>
                    <font size="5">
                        Nikita Agrawal
                    </font>
                    <br>
                    Bangalore
                    <br>
                    India, 560078
                </center>
            </td>
        </tr>
    </table>
    <br>
    <br>
    <br>
    <table class="width100">
        <tr>
            <td>
                Date:
                <?php $date=date_create($row['Payment_Date']); echo date_format($date,'d/m/Y'); ?>
            </td>
        </tr>
    </table>
    <br>
    <br>
    <br>
    <table class="width100">
        <tr>
            <td>
                To,
                <br>
                XYZ
            </td>
        </tr>
    </table>
    <br>
    <br>
    <br>
    <table class="width100">
        <tr>
            <td>
                <b>
                    Sub:
                </b>
                Declaration regarding non-requirement to be registered under the Central/ State/ Integrated /
                <br>
                Union Territory Goods and Services Tax Act, 2017 (Act) against supply/services provided.
            </td>
        </tr>
    </table>
    <br>
    <table class="width100">
        <tr>
            <td>
                Dear Sir/Mam,
                <br>
                <br>
                <span style="border-bottom: 1px dotted;width: 100%;display: block;"></span>
            </td>
        </tr>
        <tr>
            <td>
                <br>
                This refers to our discussion/communication for asking us to provide you with details of GST registrations such as GST registration number and the address registered under GST obtained by us.
            </td>
        </tr>
        <tr>
            <td>
                <br>
                In this regard, we hereby state that since my turnover in the state below taxable limit, we are not required to get myself registered under the ACT. My Permanent Account Number (PAN) is
                <?= $row['pan']; ?>
            </td>
        </tr>
        <tr>
            <td>
                <br>
                We request you to treat this communication as a declaration regarding non-requirement to be registered under the Act. In the event that GST is proposed to be recovered from me/us by the tax authorities in relation to transaction with XYZ
                on account of non-registration under GST, I/we will be liable to pay the same and it will not be paid AABSyS IT Private Limited.
            </td>
        </tr>
        <tr>
            <td>
                <br>
                Thanks & Regards,
            </td>
        </tr>
        <tr>
            <td>
                <br>
                <br>
                <br>
                <br>
                Signature
            </td>
        </tr>
        <tr>
            <td>
                Name
                <br>
                <?= $row['firstname'].' '.$row['lastname']; ?>
            </td>
        </tr>
    </table>
</div>
<br/>
<button class="btn btn-info" id="cmd2">Download Token</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
</script>
<script src="https://cdn.rawgit.com/MrRio/jsPDF/master/libs/html2pdf.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.5/jspdf.min.js">
</script>
<script>
    $('#cmd2').click(function() {
        var options = {};
        var pdf = new jsPDF('p', 'pt', 'a4');
        pdf.addHTML($("#content2"), 0, 0, options, function() {
            pdf.save('admit_card.pdf');
        });
    });
</script>