以pdf格式显示内容,类似于innerHTML

时间:2016-02-12 06:54:09

标签: javascript pdf

我有一个HTML到PDF转换器,它将以PDF格式显示网页的内容。到目前为止,我能够获取信息,但数据以不同的顺序显示。

当我在网页上显示 vDIV.innerHTML 时,它会正确显示。但我尝试在PDF上做类似的事情,但我无法做到。以下是我下载PDF的工作代码。

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>fromHTML EX</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  <script src="https://parall.ax/parallax/js/jspdf.js"></script>

  <script type="text/javascript">
  function PDF1()
{
    var doc = new jsPDF();
    var elementHandler = {

    };

    vDiv = document.getElementById("divExport");
    var vTable = '<br>';
    vTable += '<table class="wrs_export">';
    vTable += '<tr class="wrs_export">';
    vTable += '<th class = "wrs_export">Radio ID</th>';
    vTable += '<th class = "wrs_export">Description</th>';
    vTable += '<th class = "wrs_export" colspan="2">Additional Info</th>';
    vTable += '<th class = "wrs_export">Location</th>';
    vTable += '<th class = "wrs_export">Start Time</th>';
    vTable += '<th class = "wrs_export">Duration</th>';
    vTable += '<th class = "wrs_export">Result</th>';
    vTable += '<th class = "wrs_export">Failure Type</th>';
    vTable += '<th class = "wrs_export">Corrective Action</th>';
    vTable += '</tr>';

    vDiv.innerHTML = vTable;

    doc.fromHTML(
      vTable,
      150,
      15,
      {
        'width': 180,'elementHandlers': elementHandler
      });
      doc.open("datauri");
}

根据网页,信息以顺序方式显示,但我以垂直方式显示。我试图将vDiv.innerHTML放在doc.fromHTML中,但我仍然无法在网页中显示完全相同的内容。我错过了什么?请帮忙

0 个答案:

没有答案