Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/402.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 使用jsPDF将html导出为pdf_Javascript_Pdf_Pdf Generation_Jspdf_Export To Pdf - Fatal编程技术网

Javascript 使用jsPDF将html导出为pdf

Javascript 使用jsPDF将html导出为pdf,javascript,pdf,pdf-generation,jspdf,export-to-pdf,Javascript,Pdf,Pdf Generation,Jspdf,Export To Pdf,您好,我想导出html到pdf,我已经使用jsPDF所有工作pdf也导出,但我想得到相同的html在pdf中,html样式不工作,我可以做什么,有人可以帮我吗?他们是否有在jsPDF中使用html样式的方法??这是我的html代码。我从这个链接得到了一个脚本函数 查询日期 {{endetails.system_date_time|date:fullDate} 查询编号。 {{endetails.reference{u no} 副署长日期 {{endetails.departing_date |

您好,我想导出html到pdf,我已经使用jsPDF所有工作pdf也导出,但我想得到相同的html在pdf中,html样式不工作,我可以做什么,有人可以帮我吗?他们是否有在jsPDF中使用html样式的方法??这是我的html代码。我从这个链接得到了一个脚本函数


查询日期
{{endetails.system_date_time|date:fullDate}
查询编号。
{{endetails.reference{u no}
副署长日期
{{endetails.departing_date | date:fullDate}
离开。从…起
{{endails.从}出发}
归还日期
{{endetails.returning_date | date:fullDate}
旅行。到
{{endails.traveling{u to}}
顾客
{{endetails.name}
总价
{{total.total{u amount}}
酒店详情
酒店名称
{{product.hotel_name}}
房间数目
{{product.no_of_rooms}}
位置
{{product.city_code}
房间视图
{{product.product\u hotel\u room\u views.roomview\u name}
签到
{{product.check|u in | date:fullDate}
房间类型
{{product.product\酒店\房间\类型.房间\类型\名称}
结账
{{product.check|date:fullDate}
董事会基础
{{product.product\u hotel\u board\u basis.bb\u name}
夜数
乘客-房间
成人:{{item.maintals}}和儿童:{{item.Child}
预算
{{产品.应付款}
比率
{{product.rate}
航班详情
副饱和城市
{{产品{航班.出发{城市}
到达城市
{{产品{航班抵达{城市}
除名日期
{{product_flight.DEPUATURE|date:fullDate}
到达日期
{{product_flight.ARMINATION|date:fullDate}
乘客

姓名:{{item_-flight_-pass.title}.{{item_-flight_-pass.first_-Name}{{{item_-flight_-pass.last_-Name} 预算{{product_flight.Budget} 总{{产品{飞行。总{销售} 委员会{产品飞行.委员会} 汽车详情 拿起 {{product_car.pickup}} 减少 {{product_car.dropoff}} 提货日期 {{product_car.datein}日期:fullDate} 下车日期 {{product_car.dateout}日期:fullDate} 上车时间 {{product_car.timein}日期:fullDate} 下车时间 {{product_car.timeout}日期:fullDate} 车型 {{product_car.type} 预算{{产品应付款} 总计{{product_car.buyamount} 委员会{product_car.commissionon} 旅游详情 旅游详情 拿起 {{product\u tour.pick\u up} 减少 {{product\u tour.drop\u off} 提货日期 {{product_tour.出发日期{124;日期:fullDate} 下车日期 {{product_tour.dateout}日期:fullDate} 上车时间 {{product_tour.timein}日期:fullDate} 下车时间 {{product_tour.timeout}日期:fullDate} 预算{product_tour.PAYMED} 总计{product_tour.buyamount} 委员会{product_tour.commissionon} 轨道细节 离开 {{product_rail.departurecity} 进站 {{product_rail.ARVILCITY} 类型 {{product_rail.type} 预算{{product_rail.Budget}} 总计{{product_rail.amount} 报价{{产品{铁路.报价} 传输详细信息 来自城市 {{产品从{城市}转移} 进城 {{产品转移到{城市} 车型 {{产品_转移.车辆_类型}
   <div class="panel col-xs-12 col-sm-12 col-md-11" style="" id="quotation">


    <header><img src="~/images/doc/header_footer/TOUR_Header.png" width="600" /></header>
    <table width="600" border="0" style="font-size:12px;border:none;" ng-repeat="endetails in enquiryQuote" id="enq_details">

        <tr>
            <td><b>Enquiry Date</b></td>
            <td>{{endetails.system_date_time | date:fullDate}}</td>
            <td><b>Enquiry ref.</b></td>
            <td>{{endetails.reference_no}}</td>
        </tr>
        <tr>
            <td><b>Dep. date</b></td>
            <td>{{endetails.departing_date | date:fullDate}}</td>
            <td><b>Depart. from</b></td>
            <td>{{endetails.departing_from}}</td>
        </tr>
        <tr>
            <td><b>Ret. date</b></td>
            <td>{{endetails.returning_date | date:fullDate}}</td>
            <td><b>Travel. to</b></td>
            <td>{{endetails.travelling_to}}</td>
        </tr>

        <tr>
            <td><b>Customer</b></td>
            <td>{{endetails.name}}</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
    </table>

    <table width="300" border="0" style="font-size:12px;border:none;" ng-repeat="total in invoice_total">
        <tr>
            <td><b>Total Price</b></td>
            <td>{{total.total_amount}}</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
    </table>

    <table width="600" border="0" style="" ng-repeat="product in invheader[0].invoice_hotel">
        <tr>
            <td><font color="red;">Hotel Details</font></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td style="width:150px;"><b>Hotel name</b></td>
            <td style="width:300px;">{{product.hotel_name}}</td>
            <td style="width:150px;"><b>No of rooms</b></td>
            <td style="width:300px;">{{product.no_of_rooms}}</td>
        </tr>
        <tr>
            <td style="width:150px;"><b>Location</b></td>
            <td style="width:300px;">{{product.city_code}}</td>
            <td style="width:150px;">Room view</td>
            <td style="width:300px;">{{product.product_hotel_room_views.roomview_name}}</td>
        </tr>
        <tr>
            <td style="width:150px;"><b>Checkin</b></td>
            <td style="width:300px;">{{product.check_in| date:fullDate}}</td>
            <td style="width:150px;">Room type</td>
            <td style="width:300px;">{{product.product_hotel_room_types.room_type_name}}</td>
        </tr>
        <tr>
            <td style="width:150px;"><b>Checkout</b></td>
            <td style="width:300px;">{{product.check_out| date:fullDate}}</td>
            <td style="width:150px;">Board basis</td>
            <td style="width:300px;">{{product.product_hotel_board_basis.bb_name}}</td>
        </tr>
        <tr>
            <td style="width:150px;"><b>No of nights</b></td>
            <td style="width:300px;">&nbsp;</td>
            <td style="width:150px;">&nbsp;</td>
            <td style="width:300px;">&nbsp;</td>
        </tr>
        <tr>
            <td colspan="4">
                <b>Passengers - Rooms</b>
                <div ng-repeat="item in product.product_hotel_room"><b>Adult :</b> {{item.adults}} and <b>Child :</b> {{item.child}}</div>
            </td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td><b>Budget</b></td>
            <td>{{product.payable}}</td>
            <td><b>Rate</b></td>
            <td>{{product.rate}}</td>
        </tr>

    </table>
    <table width="600" border="0" style="" ng-repeat="product_flight in invheader[0].invoice_flight">
        <tr>
            <td><font color="red;">Flight Details</font></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td style="width:150px;"><b>Depatur City</b></td>
            <td style="width:300px;">{{product_flight.departure_city}}</td>
            <td style="width:150px;"><b>Arrival City</b></td>
            <td style="width:300px;">{{product_flight.arrival_city}}</td>

        </tr>
        <tr>
            <td style="width:150px;"><b>Depature date</b></td>
            <td style="width:300px;">{{product_flight.depature_date | date:fullDate}}</td>
            <td style="width:150px;"><b>Arrival Date</b></td>
            <td style="width:300px;">{{product_flight.arrival_date | date:fullDate}}</td>
        </tr>

        <tr>
            <td colspan="4">
                <b>Passengers</b>
                <br />
                <div ng-repeat="item_flight_pass in product_flight.invoice_flight_passengers"><b>Name :</b>{{item_flight_pass.title}}.{{item_flight_pass.first_name}}&nbsp;{{item_flight_pass.last_name}} </div>
            </td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td><b>Budget</b>&nbsp;&nbsp; {{product_flight.budget}}</td>
            <td><b>Total</b>&nbsp;&nbsp; {{product_flight.total_sell_amt}} </td>
            <td><b>Commision</b>&nbsp;&nbsp; {{product_flight.commission_on}}</td>
            <td>&nbsp;</td>
        </tr>
    </table>
    <table width="600" border="0" style="" ng-repeat="product_car in invheader[0].invoice_car">
        <tr>
            <td><font color="red;">Car Details</font></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td style="width: 178px;"><b>Pick Up</b></td>
            <td style="width:300px;">{{product_car.pickup}}</td>
            <td style="width: 178px;"><b>Drop off</b></td>
            <td style="width:300px;">{{product_car.dropoff}}</td>
        </tr>
        <tr>
            <td style="width: 178px;"><b>Pick Up date</b></td>
            <td style="width:300px;">{{product_car.datein | date:fullDate}}</td>
            <td style="width: 178px;"><b>Drop off Date</b></td>
            <td style="width:300px;">{{product_car.dateout | date:fullDate}}</td>
        </tr>

        <tr>
            <td style="width: 178px;"><b>Pick Up Time</b></td>
            <td style="width:300px;">{{product_car.timein | date:fullDate}}</td>
            <td style="width: 180px;"><b>Drop off Time</b></td>
            <td style="width:300px;">{{product_car.timeout | date:fullDate}}</td>
        </tr>

        <tr>
            <td style="width:165px;"><b>Car Type</b></td>
            <td style="width:300px;">{{product_car.type}}</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>

        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td><b>Budget</b>&nbsp;&nbsp;{{product_car.payable}}</td>
            <td><b>Total</b>&nbsp;&nbsp;{{product_car.buyamount}}</td>
            <td><b>Commision</b>&nbsp;&nbsp;{{product_car.commissionon}}</td>
            <td>&nbsp;</td>
        </tr>
    </table>
    <table width="600" border="0" style="" ng-repeat="product_tour in invheader[0].invoice_tour">

        <tr>
            <td><font color="red;">Tour Details</font></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td>Tour Details</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td style="width:150px;"><b>Pick Up</b></td>
            <td style="width:300px;">{{product_tour.pick_up}}</td>
            <td style="width:150px;"><b>Drop off</b></td>
            <td style="width:300px;">{{product_tour.drop_off}}</td>
        </tr>
        <tr>
            <td style="width:165px;"><b>Pick Up date</b></td>
            <td style="width:300px;">{{product_tour.departure_date | date:fullDate}}</td>
            <td style="width:165px;"><b>Drop off Date</b></td>
            <td style="width:300px;">{{product_tour.dateout | date:fullDate}}</td>
        </tr>

        <tr>
            <td style="width:165px;"><b>Pick Up Time</b></td>
            <td style="width:300px;">{{product_tour.timein | date:fullDate}}</td>
            <td style="width:165px;"><b>Drop off Time</b></td>
            <td style="width:300px;">{{product_tour.timeout | date:fullDate}}</td>
        </tr>

        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td><b>Budget</b>&nbsp;&nbsp;{{product_tour.payable}}</td>
            <td><b>Total</b>&nbsp;&nbsp;{{product_tour.buyamount}}</td>
            <td><b>Commision</b>&nbsp;&nbsp;{{product_tour.commissionon}}</td>
            <td>&nbsp;</td>
        </tr>
    </table>
    <table width="600" border="0" style="" ng-repeat="product_rail in invheader[0].invoice_rail">
        <tr>
            <td><font color="red;">Rail Details</font></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td style="width:150px;"><b>Departure</b></td>
            <td style="width:300px;">{{product_rail.departurecity}}</td>
            <td style="width:150px;"><b>Arrival</b></td>
            <td style="width:300px;">{{product_rail.arrivalcity}}</td>
        </tr>
        <tr>
            <td style="width:165px;"><b>Type</b></td>
            <td style="width:300px;">{{product_rail.type}}</td>

        </tr>

        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td><b>Budget</b>&nbsp;&nbsp;{{product_rail.budget}}</td>
            <td><b>Total</b>&nbsp;&nbsp;{{product_rail.amount}}</td>
            <td style="width:165px;"><b>Quote Price</b>&nbsp;&nbsp;{{product_rail.quote_price}}</td>
            <td>&nbsp;</td>
        </tr>
    </table>

    <table width="600" border="0" style="" ng-repeat="product_transfer in invheader[0].invoice_transfers">
        <tr>
            <td><font color="red;">Transfers Details</font></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td style="width:150px;"><b>From City</b></td>
            <td style="width:300px;">{{product_transfer.from_city}}</td>
            <td style="width:150px;"><b>To City</b></td>
            <td style="width:300px;">{{product_transfer.to_city}}</td>
        </tr>
        <tr>
            <td style="width:165px;"><b>Vehicle Type</b></td>
            <td style="width:300px;">{{product_transfer.vehicle_type}}</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>

        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td><b>Budget</b>&nbsp;&nbsp;{{product_transfer.budget}}</td>
            <td><b>Buy Amount</b>&nbsp;&nbsp;{{product_transfer.amount}}</td>
            <td style="width:165px;"><b>Payable</b>&nbsp;&nbsp;{{product_transfer.payable}}</td>
            <td>&nbsp;</td>
        </tr>
    </table>
    <table width="600" border="0" style="" ng-repeat="product_cruise in invheader[0].invoice_cruise">
        <tr>
            <td><font color="red;">Cruise Details</font></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td style="width:150px;"><b>Departure City</b></td>
            <td style="width:300px;">{{product_cruise.departure_city}}</td>
            <td style="width:150px;"><b>Arrival City</b></td>
            <td style="width:300px;">{{product_cruise.arrival_city}}</td>
        </tr>
        <tr>
            <td style="width:165px;"><b>Type</b></td>
            <td style="width:300px;">{{product_cruise.vehicle_type}}</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>

        <tr>
            <td style="width:165px;"><b>Departure date</b></td>
            <td style="width:300px;">{{product_cruise.departure_date | date:fullDate}}</td>
            <td style="width:165px;"><b>Arrival Date</b></td>
            <td style="width:300px;">{{product_cruise.arrival_date | date:fullDate}}</td>
        </tr>

        <tr>
            <td style="width:165px;"><b>Depature Time</b></td>
            <td style="width:300px;">{{product_cruise.departure_time | date:fullDate}}</td>
            <td style="width:165px;"><b>Arivalo Time</b></td>
            <td style="width:300px;">{{product_cruise.arrival_time | date:fullDate}}</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td><b>Budget</b>&nbsp;&nbsp;{{product_cruise.budget}}</td>
            <td><b>Amount</b>&nbsp;&nbsp;{{product_cruise.amount}}</td>
            <td style="width:165px;"><b>Commistion Amount</b>&nbsp;&nbsp;{{product_cruise.commission_amount}}</td>
            <td>&nbsp;</td>
        </tr>
    </table>

    <table width="600" border="0" style="" ng-repeat="product_insurance in invheader[0].invoice_insurance">
        <tr>
            <td><font color="red;">Insurance Details</font></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td style="width:150px;"><b>Departure City</b></td>
            <td style="width:300px;">{{product_insurance.departure_city}}</td>
            <td style="width:150px;"><b>Arrival City</b></td>
            <td style="width:300px;">{{product_insurance.arrival_city}}</td>
        </tr>
        <tr>
            <td style="width:165px;"><b>Type</b></td>
            <td style="width:300px;">{{product_insurance.vehicle_type}}</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>

        <tr>
            <td style="width:165px;"><b>Departure date</b></td>
            <td style="width:300px;">{{product_insurance.departure_date | date:fullDate}}</td>
            <td style="width:165px;"><b>Arrival Date</b></td>
            <td style="width:300px;">{{product_insurance.arrival_date | date:fullDate}}</td>
        </tr>

        <tr>
            <td style="width:165px;"><b>Depature Time</b></td>
            <td style="width:300px;">{{product_insurance.departure_time | date:fullDate}}</td>
            <td style="width:165px;"><b>Arivalo Time</b></td>
            <td style="width:300px;">{{product_insurance.arrival_time | date:fullDate}}</td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td><b>Budget</b>&nbsp;&nbsp;{{product_insurance.budget}}</td>
            <td><b>Amount</b>&nbsp;&nbsp;{{product_insurance.amount}}</td>
            <td style="width:165px;"><b>Commistion Amount</b>&nbsp;&nbsp;{{product_insurance.commission_amount}}</td>
            <td>&nbsp;</td>
        </tr>
    </table>


    <footer><img src="~/images/doc/header_footer/TOUR_Footer.png" width="600" /></footer>

</div>
<div class="rightpan" id='printablediv'>
<p>Print Content</p>
<input type='button' id="cmd" value="Download" class="button1 sbtbutton" />
<div>
<div style="display: none;" id="editor"></div>


<script src="http://code.jquery.com/jquery-2.1.1.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.5.3/jspdf.min.js"></script>

<script>
    var element = $("#printablediv"); // global variable
var getCanvas; // global variable

$("#cmd").on('click', function () {

    html2canvas(element, {
        onrendered: function (canvas) {
            $("#editor").append(canvas);
            getCanvas = canvas;

            var img = canvas.toDataURL("image/png"),
            doc = new jsPDF({
                unit: 'px',
                format: 'a4'
            });
            doc.addImage(img, 'JPEG', 20, 20);
            doc.save('Vistordetails.pdf');
            form.width(cache_width);
        }
    });
});